-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Insert order
PostPosted: Sat May 05, 2007 12:54 pm 
Newbie

Joined: Thu Nov 23, 2006 1:46 am
Posts: 8
Location: Brussels
Hey,

I had saving problem with hibernate, I can do all operation but not saving.
http://forum.hibernate.org/viewtopic.php?t=974118

After searching, i enabled the "show_sql" property, and i found that the inserting order is wrong.


Code:
Hibernate: insert into PUBLIC.ROOSTERS (FIELDNUM, DAY_NUM, START_TIME, END_TIME, ROOSTER_ID) values (?, ?, ?, ?, null)


The correct order is

ROOSter_ID,START_TIME, END_TIME,DAY_NUM,FIELDNUM

can this cause the saving problem? if yse how and where can i correct this

thx


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 05, 2007 2:04 pm 
Beginner
Beginner

Joined: Tue Sep 14, 2004 1:03 pm
Posts: 33
Location: Calgary, Alberta Canada
Quote:
Hibernate: insert into PUBLIC.ROOSTERS (FIELDNUM, DAY_NUM, START_TIME, END_TIME, ROOSTER_ID) values (?, ?, ?, ?, null)


<class name="model.beans.Rooster" table="ROOSTERS" schema="PUBLIC">
<id name="roosterId" type="java.lang.Long">
<column name="ROOSTER_ID" />
<generator class="assigned"></generator>
</id>
...


I notice that the ROOSTER_ID is null, in your previous post, you have set the ID property to "assigned" meaning that the application is supposed to take care of the ROOSTER_ID. Therefore, it looks like when you are creating a new ROOSTER your not giving it an ID before you are saving it.

If you wanted to use an identity, the generator should be:
<generator class="identity" />

Hope this helps,

Darin


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.