-->
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: Missing length attribute generating hbms from database
PostPosted: Mon Mar 19, 2012 8:28 am 
Newbie

Joined: Mon Mar 19, 2012 4:36 am
Posts: 2
We use the Eclipse reverse engineer to generate the *.hbm.xml-Files from the database. If the colum is defined as varchar the following mapping is generated.

Code:
<property name="my_column" type="java.lang.String">
    <column name="MY_COLUMN" length="50" />
</property>


If the column type changes to nvarchar the length attribute is missing.

Code:
<property name="my_column" type="java.lang.String">
    <column name="MY_COLUMN" />
</property>


Why doesn't it work with nvarchar?


Top
 Profile  
 
 Post subject: Re: Missing length attribute generating hbms from database
PostPosted: Mon Mar 19, 2012 10:42 am 
Newbie

Joined: Mon Mar 19, 2012 4:36 am
Posts: 2
What I do not understand is why the N-Types have no length in the JDBCToHibernateTypeHelper class.

Code:
org.hibernate.cfg.reveng.JDBCToHibernateTypeHelper
...

    // length is for string column
    public static boolean typeHasLength(int sqlType) {
       return (sqlType == Types.CHAR || sqlType == Types.DATE
             || sqlType == Types.LONGVARCHAR || sqlType == Types.TIME || sqlType == Types.TIMESTAMP
             || sqlType == Types.VARCHAR );
    }


I think that the following line is missing.
Code:
|| sqlType == Types.NCHAR || sqlType == Types.NVARCHAR || sqlType == Types.NCLOB


Top
 Profile  
 
 Post subject: Re: Missing length attribute generating hbms from database
PostPosted: Thu Nov 01, 2012 12:44 pm 
Newbie

Joined: Thu Nov 01, 2012 12:42 pm
Posts: 1
Does anyone have a work around for this issue - I am attempting to generate from a SQL Server schema with a lot of nvarchar fields and don't won't to code the length's by hand...

Thanks


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.