- This topic has 4 replies, 3 voices, and was last updated 17 years, 6 months ago by tommyc7.
-
AuthorPosts
-
feiliMemberHi,
I run SimpleJPAProject tutorial. I can read table but when I write to table it wrote nothing but the console message tell nothing wrong.
”
Jun 3, 2007 10:40:09 AM com.gis.jpa.test1.EntityManagerHelper log
INFO: saving Message instance
[TopLink Info]: 2007.06.03 10:40:09.843–ServerSession(32019423)–TopLink, version: Oracle TopLink Essentials – 2.0 (Build b40-rc (03/21/2007))
[TopLink Info]: 2007.06.03 10:40:10.171–ServerSession(32019423)–file:/C:/Documents%20and%20Settings/feili/workspace/SimpleJPA/bin/-SimpleJPA login successful
Jun 3, 2007 10:40:10 AM com.gis.jpa.test1.EntityManagerHelper log
INFO: save successful
”If I use DB Browser I can modify table. What is wrong here?
Thanks
Fei Li
Riyad KallaMemberFei,
Are you making sure to Start and Commit a transaction before/after the save operation? If you want to see the changes *in the database* you must commit the transaction, otherwise the changed object state is held in the session cache until it’s flushed to the DB.This is exactly the same how Hibernate works.
tommyc7MemberI am having the same problem. It’s not just a simple matter of coding the commit statement. The JPA classes are generated by reverse-engineering the database. If you code a commit statement and re-generate the classes, your commit code is gone again. This doesn’t seem right. Either it’s a bug or there has to be a way to generate the code with the commit statements already in there. Or I’m just completely missing something!
Any ideas?
Tnaks,
Tom
feiliMemberHi,
The automatically created code files are:
PRODUCTLINE ProductlineDAO, EntityManagerHelper
These are Entity Bean stuff. You will not put the transaction code there. In real application you put such code in a Session Bean, but the example does not have it. So you need to put it in the client code “RunJPA”. The transaction methods are in “EntityManagerHelper”. call them.
For the moment I do not have the example in my IDE. So the detail is yours.
Thanks
Fei Li
tommyc7MemberThank you! I get it now!
-
AuthorPosts