JBoss 4.0.4, Hibernate 3.0. Data do not saved!
Code in EJB component:
ctx = new InitialContext(); SessionFactory factory = (SessionFactory) ctx.lookup("java:/hibernate/SessionFactory"); Session hsession = factory.openSession(); Transaction tx = hsession.beginTransaction(); Orgs orgs = new Orgs("Hibernate test"); hsession.save(orgs); tx.commit(); hsession.close();
I saved / deleted / updated an object / collection but I can't see the changes in the database!
Hibernate will not execute any SQL until you either call Transaction.commit() (if using the Transaction API) or Session.flush() (if you are not) at the end of a session to flush your in-memory changes to the database.
If you are not using the Transaction API, you must then explicitly commit the transaction (by committing the JTA transaction or JDBC Connection).