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.  [ 6 posts ] 
Author Message
 Post subject: hibernatetool, NVARCHAR and mssql 2000
PostPosted: Mon Oct 23, 2006 7:11 am 
Newbie

Joined: Mon Oct 23, 2006 6:54 am
Posts: 15
Hibernate version:
Hibernate 3.2.0
tools 3.2 beta 8
Name and version of the database you are using:
MSSQL 2000
weblogic mssqlserver4v65.jar jdbc driver

Hi,

I am using the hibernatetool task to generate hmb and javafiles. My problem is that NVARCHAR is not generated to string but Serializable!

From my ant script:
<hibernatetool destdir="${build.dir}/generated">
<classpath>
<path location="${build.dir}/classes"/>
</classpath>
<jdbcconfiguration configurationfile="hibernate.cfg.xml" revengfile="hibernate.reveng.xml" packagename="no.xlink.hibernate.generated" />
<hbm2hbmxml />
<hbm2java/>
<hbm2cfgxml/>
</hibernatetool>

From the generated user java file:
public Serializable getNavn() {
return this.navn;
}

From the generated user hbm table:
<property name="navn" type="serializable">
<column name="Navn" />
</property>

I have tried to force all types to string in the hibernate.reveng.xml file but have had no luck :(

<type-mapping>
<sql-type jdbc-type="BIT" hibernate-type="string"/>
<sql-type jdbc-type="TINYINT" hibernate-type="string"/>
<sql-type jdbc-type="SMALLINT" hibernate-type="string"/>
<sql-type jdbc-type="INTEGER" hibernate-type="string"/>
<sql-type jdbc-type="BIGINT" hibernate-type="string"/>
<sql-type jdbc-type="FLOAT" hibernate-type="string"/>
<sql-type jdbc-type="REAL" hibernate-type="string"/>
<sql-type jdbc-type="DOUBLE" hibernate-type="string"/>
<sql-type jdbc-type="NUMERIC" hibernate-type="string"/>
<sql-type jdbc-type="DECIMAL" hibernate-type="string"/>
<sql-type jdbc-type="CHAR" hibernate-type="string"/>
<sql-type jdbc-type="VARCHAR" hibernate-type="string"/>
<sql-type jdbc-type="LONGVARCHAR" hibernate-type="string"/>
<sql-type jdbc-type="DATE" hibernate-type="string"/>
<sql-type jdbc-type="TIME" hibernate-type="string"/>
<sql-type jdbc-type="TIMESTAMP" hibernate-type="string"/>
<sql-type jdbc-type="BINARY" hibernate-type="string"/>
<sql-type jdbc-type="VARBINARY" hibernate-type="string"/>
<sql-type jdbc-type="LONGVARBINARY" hibernate-type="string"/>
<sql-type jdbc-type="NULL" hibernate-type="string"/>
<sql-type jdbc-type="OTHER" hibernate-type="string"/>
<sql-type jdbc-type="JAVA_OBJECT" hibernate-type="string"/>
<sql-type jdbc-type="STRUCT" hibernate-type="string"/>
<sql-type jdbc-type="ARRAY" hibernate-type="string"/>
<sql-type jdbc-type="BLOB" hibernate-type="string"/>
<sql-type jdbc-type="CLOB" hibernate-type="string"/>
<sql-type jdbc-type="REF" hibernate-type="string"/>
<sql-type jdbc-type="DATALINK" hibernate-type="string"/>
<sql-type jdbc-type="BOOLEAN" hibernate-type="string"/>
</type-mapping>

Any suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 23, 2006 7:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
oracle is most likely returning some other numerical value.

enable debug logging and you should be able to see it in the logs.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 23, 2006 7:55 am 
Newbie

Joined: Mon Oct 23, 2006 6:54 am
Posts: 15
Ok...
Here is everything from the log refereing to the field "Navn".
It looks to me like NVARCHAR from the MSSQL(not oracle) is not recognized?
Is there a way to change this behaviour?


[hibernatetool] BLH main DEBUG org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy - No preferred hibernate type found for org.hibernate.cfg.reveng.TableIdentifier(middlegentest.dbo.XUser) column: Navn falling back to 'serializable'
[hibernatetool] BLH main DEBUG org.hibernate.cfg.JDBCBinder - Sql type mismatch for Table: middlegentest.dbo.XUser column: Navn between DB and wanted hibernate type. Sql type set to -9(-9) instead of -3(VARBINARY)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 23, 2006 8:05 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so the type returned is -9.

you can use that in the jdbc-type attribute.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 23, 2006 8:21 am 
Newbie

Joined: Mon Oct 23, 2006 6:54 am
Posts: 15
Tanx it worked... I did not know that I could use numeric values... :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 23, 2006 8:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
from the docs:
"jdbc-type="integer value or name from java.sql.Types""

;)

_________________
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.  [ 6 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.