[JBoss Seam] - Re: persist() / remove() at end of long running conversation
by steve.ebersoleï¼ jboss.com
Historically Hibernate would always immediately perform an insert for entities using an IDENTITY based strategy. The reason was that the Hibernate save() method has a distinctly different semantic from persist(); namely save() requires the generated identifier value to be returned as a return value from the save call!
persist() is slightly different in that it's declared return type is void, thus the generated identifier does not need to be immediately available upon return from the persist() call. Thus I changed this behavior starting in 3.2 such that the insertion to generate and obtain the identifier value is delayed until a flush. However, that only occurs when we are outside a transaction. This should probably be extended such that we also delay in the case of FlushMode.MANUAL as well.
This should be easy to verify. Have a look at org.hibernate.event.def.AbstractSaveEventListener#performSaveOrReplicate. Specifically the part about 'shouldDelayIdentityInserts'. Currently, that is set via:
| boolean shouldDelayIdentityInserts = !inTxn && !requiresImmediateIdAccess;
|
Try changing that to:
| boolean shouldDelayIdentityInserts = !requiresImmediateIdAccess &&
| ( !inTxn || FlushMode.isManualFlushMode( source.getFlushMode() ) );
|
Let me know how it goes at : http://opensource.atlassian.com/projects/hibernate/browse/HHH-2439
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4020832#4020832
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4020832
19Â years, 2Â months
[JBoss Seam] - Entity relations with metadata
by MikeDougherty
Hello all,
I have a number of entities that relate to each other via a join table. So far the @Entity objects have mapped pretty well with @JoinTable/@JoinColumn. However, there is more data in the join table than just the id's of the entities it joins, such as EffectiveDate, EndDate, ModifiedDate, etc. There are also different join tables for each association (i.e. ENTITY_A_B_JOIN, ENTITY_B_C_JOIN, etc).
The easiest solution would very likely be to create an Association superclass and subclass for each join I need to make. But I would like to challenge myself a little more and see if there is a Cool Seam way of solving the problem.
Maybe using a combination of components.xml, injecting, and a generic class to come up with the solution. I haven't seen anything in the documentation that stands out as "the way" to do this. But maybe someone out there has done something similar and wouldn't mind pointing me to the appropriate features of Seam that will get me going in the right direction. Mind you, I'm not asking you to do my work for me, just point me to the sets of features, and creative uses thereof that will get me going.
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4020829#4020829
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4020829
19Â years, 2Â months