A simple spring service with method doing insert and throwing Runtime
exception after insert.
Runtime exception should cause rollback.
@Transactional()
public void insertAndThrowRuntimeEx() {
Order order = new Order();
entityManager.persist(order);
throw new RuntimeException("Unexpected runtime exception");
}
Rollback appears correctly only when I configure dataSource with:
<jdbc:embedded-database id="dataSource" type="H2" /> <!--* with this
configuration there is correct rollback* -->
But when I use database in standalone mode, there is no rollback, or
rollback is not effective:
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource" <!-- *here inserted
record remains in database* -->
p:driverClassName="org.h2.Driver" p:url="*jdbc:h2:tcp*
://localhost/databases/test1"
p:username="sa" p:password="" />
*Why can transaction rollback work correctly in embedded-database mode, but
not in server mode ?*
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.