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