is it normal or bug, that flush() always occurs, even if the transaction rollbacks?
i have seam-managed hibernate session configured according to seam documentation
http://docs.jboss.com/seam/2.0.0.GA/reference/en/html/persistence.html#d0...
<property
name="transaction.flush_before_completion">true</property>
| <property
name="connection.release_mode">after_statement</property>
| <property
name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
| <property
name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
|
and a method
@Begin
| @End
| public void save(Person person){
| currentSession.save(person);
| currentSession.createSQLQuery("{call
initializePerson(:person_id)}")
| .setLong("person_id", person.getId())
| .executeUpdate();
| currentSession.refresh(person);
| if (!person.isInitialized()) throw new RuntimeException("Failed to
initialize person");
| }
|
as a result of the method's execution:
if person is uninitialized , it will be a rollbacked transaction due to the
RuntimeException. (Because it is a "System Exception" and they always cause a
transaction rollback
http://docs.jboss.com/seam/2.0.0.GA/reference/en/html/events.html#d0e4391 )
As expected the stored procedure "initializePerson" will be rollbacked.
But an insert of the method "currentSession.save(person)" will be executed.
Because the property transaction.flush_before_completion's value is true.
anonymous wrote : if hibernate.transaction.flush_before_completion is enabled, the session
will be automatically flushed during the before completion phase of the
transaction.(http://www.hibernate.org/hib_docs/reference/en/html/session-...
)
|
Thus we have 'partial' committed transaction. Imho, it isn't normal behaviour,
when an exception occurs.
Any suggestions to cause full rollbacking ?
(without disabling "flush_before_completion" property or enabling
FlushModeType.MANUAL, that seems the same))
Quote:
anonymous wrote : Note that Seam does not flush the session, so you should always enable
hibernate.transaction.flush_before_completion to ensure that the session is automatically
flushed before the JTA transaction
commits.http://docs.jboss.com/seam/2.0.0.GA/reference/en/html_single/#d0e...
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107106#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...