-->
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.  [ 2 posts ] 
Author Message
 Post subject: sql-type in hbm does not take any effect in SQLServer
PostPosted: Thu Mar 09, 2006 10:00 pm 
Newbie

Joined: Wed Mar 01, 2006 3:45 pm
Posts: 9
I defined a user type in SQLService called "PKID" for Primary Key columns. It's equivalent to "numeric(18,0)". So in my hbm files, I set the "id" mapping as:

Code:
   <id
        name="TblId"
        type="java.lang.Long"
    >
       <column name="TBL_ID" length="18" not-null="true" unique="true" sql-type="PKID" />
            <generator class="identity" />
    </id>


or

Code:
   <id
        name="TblId"
        type="java.lang.Long"
    >
       <column name="TBL_ID" length="18" not-null="true" unique="true" sql-type="numeric(18,0)" />
            <generator class="identity" />
    </id>


I event tried "decimal(18,0)" but regardless, when I get the actual sql statement from the database trace, the bind variable has always been declared as "bigint" type. e.g.:

Code:
declare
...,
@P bigint

select ...
from mytable
where tbl_id=@P


or

Code:
declare
...,
@P bigint

update mytable
set
...
where
tbl_id=@P


Please note: these are not the Hibernate sql in the log. They were from the trace file which the database server was actually preparing for execution.

So am I missing something? Does it work for you? if it did, could you please give me an exampl?

Hibernate version: 3

Mapping documents:

Code:
      <property name="hibernate.connection.pool_size">10</property>
      <property name="show_sql">true</property>
      <property name="hibernate.connection.isolation">1</property>
      <property name="hibernate.prepare_sql">true</property>
      <property name="hibernate.statement_cache.size">20</property>

      <property name="hibernate.prepare_sql">true</property>
      <property name="hibernate.statement_cache.size">20</property>

      <property name="hibernate.jdbc.batch_size">50</property>
      <property name="hibernate.cache.use_second_level_cache">false</property>



Name and version of the database you are using: SQLServer 2000 SP4

Thanks very much in advance.

J


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 09, 2006 10:21 pm 
Newbie

Joined: Wed Mar 01, 2006 3:45 pm
Posts: 9
I did another test. I have a non-PK column set to type "PKID".

the mapping is like:

Code:
    <property
        name="InstanceId"
        type="java.math.BigDecimal"
    >
        <column name="INSTANCE_ID" length="18" not-null="false" sql-type="PKID" />
   </property>



and in the trace, the bind variable is always "decimal(38,0)" (derived from BigDecimal).

It seems to me that the java type to sql type is kinda fixed, e.g. Long->bigint, BigDecimal->decimal(38,0). But I still don't believe Hibernate would do that...

Then, what can explain why the the "sql-type" in hbm is ignored?

Thanks.
J


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