-
Notifications
You must be signed in to change notification settings - Fork 934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ISession.Merge() not returning the entity id for the new entity on version 5.3.x #2632
Comments
This is a change coming from #1754. But it is unclear for me whether We should at least document it in the possible breaking changes of 5.3. |
I'm also not sure it's intended behavior. Current behavior might be considered useful if batch entities insert is used. |
Nope. It won't save it.. Seems there is now no way to save entity on merge without actual session flush. |
I am going to document it as a possible breaking change of 5.3, as part of releasing 5.3.6. @hazzik, what do think of this subject? |
I think |
There is no mechanism in NHibernate for triggering a flush when accessing the id property of an entity. I guess you mean In such case we should consider this issue as a regression needing to be fixed in 5.3.x. |
If you are referring to my comment - no I just meant that now saving is deferred till Regarding fix to behave like
changing last parameter Maybe we should also introduce |
I love this fix.
Why? |
There is... the one which @bahusoid just wrote above. |
Probably we would need this as well (from SaveOrUpdate event listener): object id = SaveWithGeneratedOrRequestedId(@event);
->>> source.PersistenceContext.ReassociateProxy(@event.Entity, id);
return id; |
Not sure... Maybe to allow safely Merge outside of transaction or for batch insert. Basically same reasons why #1754 is needed. |
When I read
I understand than given an entity reference named As far as I known there is no mechanism for this.
Anyway your answer confirms for me what I was guessing, you suggest forcing immediate id hydration during About what is the right choice, well But do we care much about JSR-220? Causing Having the choice could be better, but is it worth it? I am for having
No
nhibernate-core/src/NHibernate/Event/Default/DefaultMergeEventListener.cs Lines 286 to 293 in bad7e99
|
Ok. Let's just document the behaviour and move on. |
And document a missing breaking change for Merge, see #2632
And document a missing breaking change for Merge, see nhibernate#2632
See #3234 (comment) if you need old behavior. |
I updated the NHibernate from 5.2.7 to 5.3.0 and noticed that there is a difference between the returning object from the merge function. In version 5.3.x the merge function doesn't return the entity id if the entity is not in the database but in version 5.2.7 the merge function returns the entity id. I don't know this is a bug or not
Here is the code
The text was updated successfully, but these errors were encountered: