facebook

JPA did not create any record

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #271039 Reply

    feili
    Member

    Hi,

    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

    #271069 Reply

    Riyad Kalla
    Member

    Fei,
    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.

    #272438 Reply

    tommyc7
    Member

    I 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

    #272440 Reply

    feili
    Member

    Hi,

    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

    #272441 Reply

    tommyc7
    Member

    Thank you! I get it now!

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: JPA did not create any record

You must be logged in to post in the forum log in