NH1914, and Assigned Identifiers ...

14 views
Skip to first unread message

Richard Brown (gmail)

unread,
Aug 9, 2009, 7:08:48 AM8/9/09
to nhibernate-...@googlegroups.com
I've been looking at http://nhjira.koah.net/browse/NH-1914.  Turns out the problem is a cascading SaveOrUpdate() to entities with assigned identifiers.
 
I've since found out this is a known issue with NHibernate.  Is there any reason not to fix this by hitting the database to determine if an instance (using assigned identifier) is transient vs. detached?
 
Cheers,
    Richard
 

Ayende Rahien

unread,
Aug 9, 2009, 7:19:59 AM8/9/09
to nhibernate-...@googlegroups.com
Richard,
Consider the number of queries that this would generate?

Richard Brown

unread,
Aug 9, 2009, 7:36:12 AM8/9/09
to nhibernate-...@googlegroups.com
I realise it's one select per insert in the cascade case - I just thought that was better than it not working at all?

Ayende Rahien

unread,
Aug 9, 2009, 7:50:11 AM8/9/09
to nhibernate-...@googlegroups.com
I am not sure if we shouldn't make it explicit that you should handle this scenario yourself. You usually have far more information about this than NH do.
I have no problem with the proposed fix, but I want to ensure that I can tell NH that it is new and avoid the extra select.

Richard Brown (Google)

unread,
Aug 9, 2009, 7:52:20 AM8/9/09
to nhibernate-...@googlegroups.com
So make it a new configuration setting?
 
(and throw a more explicit exception otherwise?)

Ayende Rahien

unread,
Aug 9, 2009, 7:55:59 AM8/9/09
to nhibernate-...@googlegroups.com
Yuck, no!
We have too much config already.
I think we can emit a warning if this is happening, and let the user call Session.Save() explicitly to tell NH about this.

Richard Brown (Google)

unread,
Aug 9, 2009, 7:57:39 AM8/9/09
to nhibernate-...@googlegroups.com
emit a warning == throw an exception?
Or a log warning?

Ayende Rahien

unread,
Aug 9, 2009, 8:00:11 AM8/9/09
to nhibernate-...@googlegroups.com
Log warning, you want to make this an explicitly supported scenario, no?
Take into account that NH Prof will show warning from NH, and even if the user isn't using NH Prof, the recommended log setting will show that to the user. 

Richard Brown (Google)

unread,
Aug 9, 2009, 8:02:51 AM8/9/09
to nhibernate-...@googlegroups.com
OK, load the entity from the DB, and emit a log warning to indicate that the user should consider using Save/Update directly instead.
 
Sounds like a good idea to me.

Richard Brown (gmail)

unread,
Aug 10, 2009, 5:54:00 AM8/10/09
to nhibernate-...@googlegroups.com
OK, I've got it working.  Given that it's a 'known' issue, does that mean it's a new feature, rather than a bug fix?
i.e., should I commit to trunk only for now?
 
(after review, we may vote to remove this 'feature'?)
 
Sent: Sunday, August 09, 2009 1:02 PM
Subject: Re: [nhibernate-development] Re: NH1914, and Assigned Identifiers ...

OK, load the entity from the DB, and emit a log warning to indicate that the user should consider using Save/Update directly instead.
 
Sounds like a good idea to me.

Sent: Sunday, August 09, 2009 1:00 PM
Subject: [nhibernate-development] Re: NH1914, and Assigned Identifiers ...

Log warning, you want to make this an explicitly supported scenario, no?
Take into account that NH Prof will show warning from NH, and even if the user isn't using NH Prof, the recommended log setting will show that to the user. 

...

Fabio Maulo

unread,
Aug 10, 2009, 9:25:05 AM8/10/09
to nhibernate-...@googlegroups.com
Please, first to 2.1.x then trunk.
Thanks.

2009/8/10 Richard Brown (gmail) <fluk...@googlemail.com>



--
Fabio Maulo

Richard Brown (gmail)

unread,
Aug 10, 2009, 11:13:09 AM8/10/09
to nhibernate-...@googlegroups.com
Should I update the releasenotes.txt?  It's not a 'breaking' change, but it's possible warnings might be generated where there were no warnings before.
 
(If people relied on cascaded updates to detached entities using assigned identifiers for example.)

Fabio Maulo

unread,
Aug 10, 2009, 11:16:38 AM8/10/09
to nhibernate-...@googlegroups.com
If it is not a breaking change and there is a WARN log there is no problem.
The issue description will appear in release note when we will release NH2.1.1
--
Fabio Maulo
Reply all
Reply to author
Forward
0 new messages