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?
|