-->
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.  [ 3 posts ] 
Author Message
 Post subject: sql-type definition in collection-element big_decimal
PostPosted: Sat May 01, 2004 9:27 am 
Newbie

Joined: Sun Apr 11, 2004 1:36 pm
Posts: 2
Location: Hamburg (Germany)
Hibernate 2.1.3
Spring 1.0
SQL Server 2000 with jtds 0.8rc1

I wrote this Mapping statement:

<map
name="articlesImpl"
table="composite_art_childs"
lazy="false"
sort="unsorted"
inverse="false"
cascade="all"
>

<key
column="composite_art_id"
/>

<index-many-to-many
class="de.pds.dom.dao.art.impl.ComponentArticleImpl"
column="article_id"
/>

<element
column="factor"
type="big_decimal"
not-null="false"
unique="false"
>
<column name="factor" sql-type="NUMERIC(19,4)"/>
</element>

</map>

In the element definition I don't use an Empty Element-Tag to define a sql-type for the element column. My Mapping is parsed and accepted by hibernate. I also have taken a look into the hibernate-mapping-2.0.dtd and my above statement is allowed.

Unfortunately this is ignored by hibernate I got this message in the log file:
[..]

2004-05-01 15:05:18,615 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <Unsuccessful: create table composite_art_childs (composite_art_id NUMERIC(19,0) not null, factor NUMERIC(19,255) null , article_id NUMERIC(19,0) not null, primary key (composite_art_id, article_id))>

2004-05-01 15:05:18,625 ERROR [net.sf.hibernate.tool.hbm2ddl.SchemaExport] - <Die Anzahl von Dezimalstellen (255) f


Top
 Profile  
 
 Post subject: Solution found: Strange Default for Numeric in Dialect
PostPosted: Sat May 01, 2004 5:19 pm 
Newbie

Joined: Sun Apr 11, 2004 1:36 pm
Posts: 2
Location: Hamburg (Germany)
Well, after some diving into the hbm2ddl and dialect code I found a solution / workaround:

<element
column="factor"
type="big_decimal"
length="4"
not-null="false"
unique="false"
/>


big_decimal is mapped to java.sql.Type.NUMERIC

The SQLServerDialect defines "Numeric(19,$l)" as default.
The scale is set by replacing $l with length from the mapping.
Maybe their could be a hint added in the documentation, about the meaning of length attribute for datatypes that are mapped to Numeric. At least for SQLServer and Sybase this seems to me to be a required attribute.

Maybe this helps anyone else.

Nils


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 01, 2004 5:20 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Also for Oracle. I'll add a hint in the documentation, thought that this is obvious.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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