Is the merge operation really needed here?
The fact that EntityTransaction is used, implies the use of a resource-local entity manager.
A resource-local entity manager is always application-managed (because non-JTA transactions cannot be container-managed).
Furthermore, an application-managed entity manager always manages an extended persistence context.
That means that the lcte object is still managed by the entity manager after the first commit and the merge operation can be omitted (but it wouldn't hurt to leave it in).
Is this information worth adding to the explanation?
About Question enthuware.oce-jpad.v6.2.352 :
Moderators: Site Manager, fjwalraven
-
- Posts: 5
- Joined: Tue Jan 12, 2016 12:47 pm
- Contact:
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.352 :
Very sorry for late reply.
The only benefit of calling merge is that the merge operation will be cascaded to entities referenced by relationships from the entity if these relationships have been annotated with the cascade element value cascade=MERGE or cascade=ALL annotation. (Not applicable in this question because LifecycleCallbackTestEntity doesn't reference any other entities.)
thank you for your feedback!
Paul.
That is correct.Rollebol wrote:Is the merge operation really needed here?
The fact that EntityTransaction is used, implies the use of a resource-local entity manager.
A resource-local entity manager is always application-managed (because non-JTA transactions cannot be container-managed).
Yes, this is correct as well.Furthermore, an application-managed entity manager always manages an extended persistence context.
That means that the lcte object is still managed by the entity manager after the first commit and the merge operation can be omitted (but it wouldn't hurt to leave it in).
The only benefit of calling merge is that the merge operation will be cascaded to entities referenced by relationships from the entity if these relationships have been annotated with the cascade element value cascade=MERGE or cascade=ALL annotation. (Not applicable in this question because LifecycleCallbackTestEntity doesn't reference any other entities.)
Added.Is this information worth adding to the explanation?
thank you for your feedback!
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 5
- Joined: Tue Jan 12, 2016 12:47 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.352 :
Thank you for your excellent reply!
Who is online
Users browsing this forum: No registered users and 22 guests