Joined: Thu Oct 14, 2004 6:49 pm Posts: 1
|
Everything works. I mean -- all records are created correctly.
But the problem that CMT (Container Managed Transactions) doesn't work with Hibernate. MySQL tables type is InnoDB, so it's not a problem.
I am calling this code from EJB Statless Session Bean which is running in "RequiresNew" transaction.
If I use ctx.setRollbackOnly() it have to do rollback in any case.
But it doesn't.
What could be the problem?
Hibernate version:
2.1
Mapping documents:
Code between sessionFactory.openSession() and session.close():
// work with Hibernate from this place
try {
Configuration config = new Configuration()
.addClass(Person.class)
.addClass(Pet.class);
SessionFactory sessionFactory = config.buildSessionFactory();
Session session = sessionFactory.openSession();
Transaction txn = session.beginTransaction();
Person john = new Person();
john.setFirstName(fname);
john.setLastName(lname);
Pet rover = new Pet();
rover.setName(petname);
john.addPet(rover);
rover.setFriend(john);
session.save(john);
txn.commit();
session.flush();
session.close();
} catch(Exception ex) {
System.out.println("Error: " + ex);
}
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
|
|