-->
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.  [ 7 posts ] 
Author Message
 Post subject: Nullable ids with 3.0 tools
PostPosted: Sat May 07, 2005 2:16 pm 
Beginner
Beginner

Joined: Sat Feb 26, 2005 12:09 pm
Posts: 27
Location: Helsinki, Finland
The id declarations in my mapping file look like this:
<id name="id" type="int" column="id">
<generator class="native"/>
</id>

The 2.x tools generated Integer fields which were obviously null when a new object was created using the no-args constructor.

The 3.0 Ant task (from CVS today) generates int fields which start out as zero. The persister complains about duplicate ids (multiple objects with 0 as the id).

How do I make the Ant task produce Integer ids?


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 07, 2005 7:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hmm this is caused by the fact we now obey that when a properties column can not be null then we generate the basic type...but i guess for primary keys we should not do that.

make a jira issue for it - thank you.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Issue filed
PostPosted: Sun May 08, 2005 4:44 am 
Beginner
Beginner

Joined: Sat Feb 26, 2005 12:09 pm
Posts: 27
Location: Helsinki, Finland
max wrote:
hmm this is caused by the fact we now obey that when a properties column can not be null then we generate the basic type...but i guess for primary keys we should not do that.


Is there a workaround?

max wrote:
make a jira issue for it - thank you.


Bug filed: http://opensource.atlassian.com/project ... se/HBX-258


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 08, 2005 4:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
actually i'm surprised this causes problems since hibernate3 should detect that 0 means unsaved for you.

but try to set unsaved-value="0" and see if that works for you.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 08, 2005 5:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
a work around is also to use <meta attribute="property-type">TheTypeYouWant</meta>

which i just fixed a bug around in the cvs so it should soon work in the anoncvs too.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 08, 2005 9:51 am 
Beginner
Beginner

Joined: Sat Feb 26, 2005 12:09 pm
Posts: 27
Location: Helsinki, Finland
unsaved-value="0" worked. Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 09, 2005 5:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
btw. i just tested this and unsaved-value="0" really should not be necessary!

How do you get the duplicate id error ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.