-->
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.  [ 4 posts ] 
Author Message
 Post subject: length attribute for numeric type in hbm2hbm in ant
PostPosted: Tue Nov 21, 2006 1:19 pm 
Regular
Regular

Joined: Wed Mar 15, 2006 1:48 pm
Posts: 91
I noticed as below if it is a string or char type defined in db there is a length attribute generated in hbm file. But I need length attribute for all numeric types as well for validation purpose. How can I achieve it in hbm2hbm in ant env.?

<property name="tankName" type="string">
<column name="tank_name" length="10" not-null="true">
<comment></comment>
</column>
</property>
<property name="capacity" type="java.lang.Short">
<column name="capacity" not-null="true">
<comment></comment>
</column>
</property>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 22, 2006 8:37 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
numeric types have scale and precision.

Having length does not make sense.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 22, 2006 1:39 pm 
Regular
Regular

Joined: Wed Mar 15, 2006 1:48 pm
Posts: 91
But how come does timestamp have a length as below? In db for a numeric type you have to specify length or default one when creating it, for example mediumint(7). For timestamp type there isn't a length at all which makes sense to me.

<property name="deliveryTime" type="timestamp">
<column name="deliveryTime" length="19">
<comment></comment>
</column>
</property>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 22, 2006 2:06 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Methinks you are confusing length and precision. Numeric types have scale and precision, character types have length. The length on TIME, TIMESTAMP and DATEs is a holdover from the bad old days when those fields were stored in a table as character fields (DB/2 before v6 for example). The JDBC contract still states that the aforementioned fields should return a length.


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