-->
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: sqlserver data type mapping
PostPosted: Mon Oct 29, 2007 12:51 pm 
Newbie

Joined: Mon Oct 29, 2007 12:24 pm
Posts: 10
I am having tremendous difficulty mapping the following sqlserver types:

    real
    money
    ntext


i have tried all of the following in the column type:

    currency
    long
    short
    float
    double
    big_decimal


All of them fail, complaining that they were looking for columns of a different type than that which they found in the database.

I am using sqlserver 2000 sp4 with jdbc drivers from datadirect. Has anyone had any success mapping to any of the above datatypes?

Here is an example of my .hbm.xml file. I am using hibernate thru the Grails framework.

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>

    <class name="OrderDetail" table="Order Details">
        <id name="id" column="OrderID" type="integer" />
        <property name="productid" column="ProductID" type="integer"/>
        <property name="unitprice" column="UnitPrice" type="big_decimal" />
   <property name="qty" column="Quantity" type="short" />
    </class>
</hibernate-mapping>


UnitPrice is a money datatype in the schema. The schema being used is the default Northwind db that comes with sql server.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 29, 2007 6:06 pm 
Newbie

Joined: Mon Oct 29, 2007 12:24 pm
Posts: 10
Here is the Datasource.groovy file I am using:

Code:
dataSource {
   pooled = false
   driverClassName = "com.ddtek.jdbc.sqlserver.SQLServerDriver"
   username = "sa"
   password = "*"
}
hibernate {
    cache.use_second_level_cache=true
    cache.use_query_cache=true
    cache.provider_class='org.hibernate.cache.EhCacheProvider'
}
// environment specific settings
environments {
   development {
      dataSource {
         //dbCreate = "create-drop" // one of 'create', 'create-drop','update'
         url = "jdbc:datadirect:sqlserver://localhost:1433;databasename=northwind"
      }
   }
   test {
      dataSource {
         dbCreate = "update"
         url = "jdbc:hsqldb:mem:testDb"
      }
   }
   production {
      dataSource {
         dbCreate = "update"
         url = "jdbc:hsqldb:file:prodDb;shutdown=true"
      }
   }
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 29, 2007 6:12 pm 
Newbie

Joined: Mon Oct 29, 2007 12:24 pm
Posts: 10
Wow, I really thought I had the ntext issue sorted out. Evidently lack of unicode support (e.g. ntext) is a known issue with the default sql server dialect.

It is suggested here http://confluence.atlassian.com/display/DOC/Known+Issues+For+SQL+Server#KnownIssuesForSQLServer-UnicodeCharactersNotSupportedByDefault that you change the default sqlserver dialect to this:

net.sf.hibernate.dialect.SQLServerIntlDialect

unfortunately, it doesn't appear to be working, I now get an error message saying
Quote:
"could not determine type for: ntext for column: [org.hibernate.mapping.Column(Notes)]"


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 29, 2007 6:31 pm 
Newbie

Joined: Mon Oct 29, 2007 12:24 pm
Posts: 10
so, the previous error was because I had the property type set to ntext. When I change this to text, I get a different error:

Quote:
wrong column type: Notes, expected: text


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.