2

I just want to update a column table based on a condition. Here my code :

this.session.Query<EventEntity>()
     .Where(e => [...])
     .Update(c => new { Enabled = true });

This call generates the following SQL :

insert into HT_event SELECT evententit0_.Id as Id FROM event evententit0_ WHERE [...]
UPDATE event SET Enabled=? WHERE (Id) IN (select Id from HT_event)

Why NHibernate creates a temp table to store ids instead of directly generates a correct IN clause ? How can I disable this behavior ?

To give more information, I use a table per class hierarchy inheritance mapping with mapping by code. My EventEntity is an abstract class :

public abstract class EventEntity { ... }

public class EventMap : ClassMapping<EventEntity> { ... }

I have a few others entities that inherit from EventEntity

public abstract class MatchEntity { ... }

public class MatchMap : JoinedSubclassMapping<MatchEntity> { ... }

Thx for your help !

1 Answers1

0

Hibernate propose a way to customize the bulk id strategy, but it's not available for NHibernate at this moment : https://github.com/nhibernate/nhibernate-core/issues/2004.