Results 1 to 5 of 5
  1. #1
    smacker is offline Member
    Join Date
    Jan 2011
    Posts
    46
    Rep Power
    0

    Default a hibernate commit() question

    if let's say i have a User user
    and i have a Session sesh

    and i do
    Java Code:
    sesh.save(user);  
    sesh.commit();  
    sesh.commit();
    the question is what will the second commit do ?
    will it enter that same user twice with a diffrent id ?
    or will it forget his data after the first commit has happend(and do nothing)?
    thanks in advance to all helpers!

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,143
    Rep Power
    14

    Default Re: a hibernate commit() question

    What happened when you wrote a little example program to test this out?
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  3. #3
    smacker is offline Member
    Join Date
    Jan 2011
    Posts
    46
    Rep Power
    0

    Default Re: a hibernate commit() question

    well i thought it would solve a bigger problem i have which is this error :
    ERROR: Cannot insert explicit value for identity column in table 'Product' when IDENTITY_INSERT is set to OFF.
    i looked for answeres for it , but i don't want to solve it with PreparedStatement , it seems weird to me to use it , and when i do
    <id name="id" type="int">
    <column name="Id" />
    <generator class="identity" />
    </id>
    it still gives the same error , i thought if i use it difrently it might work , but still no luck
    any ideas how to fix the IDENTITY_INSERT programaticly is preferd so i could change it back at the end
    thanks!

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: a hibernate commit() question

    You've told it to generate the ids, so that's what it does.

    What exactly is it you are trying to do when you hit this error?
    If it's upload some db start up data then you will either roll your own using JDBC, or try and fit in one of the db management packages that let you maintain a db. The one I have in front of me id dbdeploy, but there are lots of others.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    pmtu is offline Member
    Join Date
    Oct 2014
    Posts
    4
    Rep Power
    0

    Default Re: a hibernate commit() question

    I think that you have 2 begin transaction and you must have to 2 commit() functions

Similar Threads

  1. EntityManager.setFlushMode(COMMIT) Vs. Query.setFlushMode(COMMIT)
    By CatchSandeepVaid in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 12-15-2009, 05:07 PM
  2. commit
    By swati.jyoti in forum NetBeans
    Replies: 1
    Last Post: 07-24-2009, 05:33 PM
  3. Intercept CVS/SVN team commit
    By dilipg003 in forum Eclipse
    Replies: 2
    Last Post: 05-12-2009, 06:17 PM
  4. Commit problem
    By egc_33 in forum Eclipse
    Replies: 0
    Last Post: 08-09-2008, 02:27 PM
  5. question about hibernate
    By bbq in forum JDBC
    Replies: 1
    Last Post: 07-09-2007, 04:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •