G
Giovanni Azua
hi,
I have a use-case that follows a similar pattern to what's written in the
snippet below. My problem is that the assertion fails meaning once the
Entity instance is persisted in the database by calling persist, that
instance does not get the Id assigned (I also tried calling refresh on that
instance). I have this situation only with OpenJPA though, using Hibernate
as JPA provider works fine.
Maybe is a missing OpenJPA property somewhere in the persistence.xml?
I will be trying meantime to switch to some other provider to test.
TIA,
regards,
Giovanni
EntityManager entityManager = ...
entityManager.getTransaction().begin();
Person myPerson = new Person("Pepito", 19);
entityManager.persist(myPerson);
assert myPerson.getId() != null : "Person Id must not be null";
entityManager.getTransaction().commit();
persistence.xml:
http://perfectjpattern.svn.sourcefo...esources/META-INF/persistence.xml?view=markup
orm.xml:
http://perfectjpattern.svn.sourcefo...c/test/resources/META-INF/orm.xml?view=markup
Person.java:
http://perfectjpattern.svn.sourcefo...ern/example/datamodel/Person.java?view=markup
I have a use-case that follows a similar pattern to what's written in the
snippet below. My problem is that the assertion fails meaning once the
Entity instance is persisted in the database by calling persist, that
instance does not get the Id assigned (I also tried calling refresh on that
instance). I have this situation only with OpenJPA though, using Hibernate
as JPA provider works fine.
Maybe is a missing OpenJPA property somewhere in the persistence.xml?
I will be trying meantime to switch to some other provider to test.
TIA,
regards,
Giovanni
EntityManager entityManager = ...
entityManager.getTransaction().begin();
Person myPerson = new Person("Pepito", 19);
entityManager.persist(myPerson);
assert myPerson.getId() != null : "Person Id must not be null";
entityManager.getTransaction().commit();
persistence.xml:
http://perfectjpattern.svn.sourcefo...esources/META-INF/persistence.xml?view=markup
orm.xml:
http://perfectjpattern.svn.sourcefo...c/test/resources/META-INF/orm.xml?view=markup
Person.java:
http://perfectjpattern.svn.sourcefo...ern/example/datamodel/Person.java?view=markup