Tuesday 8 November 2011

JPA EntityManager: persist() doesn't produce sql statement 'insert', i.e. doesn't save object in db

MySQL (/etc/mysql/my.cnf):

default-table-type=innodb

Note: InnoDB supports transactions but the default table type doesn't!

Use org.springframework.orm.jpa.JpaTransactionManager (not org.springframework.orm.hibernate3.HibernateTransactionManager)

Don't use org.springframework.orm.hibernate3.HibernateTransactionManager because you will have to
handle all the transaction management (open,close,flush) and if you forget to do so the persist()
and merge() will not product sql statements insert and updates, i.e. will not save objects into db.
(see reference)

Are transactions enabled? (are you sure?):

Spring @Transactional: Verifying transaction support / Local method calls (RECOMMENDED)

Transaction strategies: Understanding transaction pitfalls


Spring reference documentation of transactions

No comments:

Post a Comment