-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: persisting entities in a loop with FlushModeType.MANUAL
PostPosted: Wed Mar 18, 2009 5:01 pm 
Hibernate version: 3.2.4.sp1.cp04

Is it possible to do the following in Hibernate/JPA/Seam?

Say you have a for loop in which records are persisted to the db table based on user data (e.g. multiple serial number fields) entered in a JSF form submission.

Assum that the first n entities are persisted successfully to the PC using EntityManager or Session interface. Then there is a NPE or other exception for the n+1 entity.

Typically we wouldn't want the state of the PC to be sync'd with the db in this case (i.e. there should be a transaction which rolls back any pending insert native sql statements).

But what if there is a functional requirement which states "go ahead and persist the first n entities to the db and display messages in the JSF for the ones that failed after the exception is thrown"?

How can we achieve this? I'm particularly interested in knowing how to do this using MANUAL flushMode and the various EJB3 TransactionAttributeTypes (e.g. REQUIRED, REQUIRES_NEW, etc.)

Is it possible to manually flush the PC say at the end of each persist cycle for each entity? Or must you flush at the end of the transaction/conversation?


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.