I’m using EclipseLink in my J2SE project. I’m using mysql and JPA. I have a simple entity with primary key and String field. I can read from database using EntityManager#createQuery but when I try to persist or merge entity nothing is put in database and no exception are thrown. I can insert data manually without problems (using same credentials as in persistence.xml file). Please help! The problem isn’t related to jpa implementation I guess because changing provider in persistence.xml to Hibernate doesn’t help.
I’m using EclipseLink in my J2SE project. I’m using mysql and JPA. I have
Share
You need to do the
persist()ormerge()inside an active transaction. Then you need to call thecommit()method on the transaction object.Create a transaction by calling
getTransaction()on theEntityManagerinstance, getting back an EntityTransaction object and then callingbegin()on it. Callcommit()on it after your entity updates (such asmerge()) are done.See: http://download.oracle.com/javaee/6/api/javax/persistence/EntityTransaction.html