Tried that, doesn't work, don't really understand why the Entity doesn't have the id, it seems like ether the id gets nulled or the @PostPersist shows the entity state after the toString() is activated.. also tried with or without manager.flush() without any results.. so weird, don't have that problem with neither with Oracle or MSSql..
Sorry about that, here is the rest of the code. first the mysql-ds.xml
and here is the persistence.xml
the entity and table I have already added, here is the manager bean:
bare in mind that in the entity the toString() has been over written and there is a @PostPersist the prints out the id.
the executable is quit standard: creates a new Entity, sets the 'name' property, looks up the manager and use its create(test) method. after that prints out the entity. this is how you can see the null in the toString() in comparison to the @PostPersist.
You need to change the contract of the manager. Even when you access it in local JVM, you are not guaranteed how the EJB will treat it. It goes through a local proxy, which treats it like a remote object. The object that gets persisted is copied.
Basically, the manager needs to return the newly persisted object. Optionally the ID can be returned - this can lead to sticky problems with embedded owned objects that get changed.
This is where I hooked into my code, and called your code:
Here's how I modified your code:
output I obtained:
Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);