-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem with @@identity with MS SQL Server 2000
PostPosted: Thu Oct 07, 2004 7:52 pm 
Newbie

Joined: Wed Oct 06, 2004 2:28 pm
Posts: 5
Inspite of using
<property name="dialect">net.sf.hibernate.dialect.SQLServerDialect</property>
I still see that @@identity in being generated in the SQL insteead of scope_identity()

exec sp_prepexec @P1 output, N'@P1 nvarchar(4000),@P2 varchar(8000),@P3 varchar(8000),@P4 int,@P5 varchar(8000),@P6 int,@P7 datetime,@P8 int,@P9 int,@P10 nvarchar(4000),@P11 int,@P12 datetime,@P13 int,@P14 int,@P15 nvarchar(4000),@P16 nvarchar(4000),@P17 nvarchar(4000),@P18 int', N'insert into Entity (EntityLastName, EntityMiddleInitial, EntityTIN, Gender, EntityFullName, Age, EntityDOB, AddressID, FaxNumber, Email, FaxAreaCode, UpdateDate, AdjusterEntityID, PhoneNumber, EntityFirstName, Occupation, ExternalID, PhoneAreaCode) values (@P1 , @P2 , @P3 , @P4 , @P5 , @P6 , @P7 , @P8 , @P9 , @P10 , @P11 , @P12 , @P13 , @P14 , @P15 , @P16 , @P17 , @P18 ) select @@identity', N'Roy', NULL, NULL, NULL, NULL, NULL, NULL, 2102364, NULL, N'sroy@claimiq.com', NULL, NULL, NULL, NULL, N'Shankar', N'Surgeon', N'9999', NULL

So what am I missing ?
Any help will be great.
Thanks.



<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory>
<!-- local connection properties -->
<property name="hibernate.connection.url">jdbc:bea:sqlserver://dev-db;DatabaseName=DEV</property>
<property name="hibernate.connection.driver_class">weblogic.jdbc.sqlserver.SQLServerDriver</property>
<property name="hibernate.connection.username">claimiq</property>
<property name="hibernate.connection.password">claimiq</property>
<!-- property name="hibernate.connection.pool_size"></property -->
<!-- dialect for Microsoft SQL Server -->
<property name="dialect">net.sf.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.use_outer_join">true</property>
<mapping resource="ciq/Loss.hbm" />
</session-factory>
</hibernate-configuration>



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

<hibernate-mapping package="com.claimiq.hibernate" auto-import="true">
<class name="Entity" table="Entity" lazy="true">
<id
column="EntityID"
name="EntityID"
type="integer"
>
<generator class="net.sf.hibernate.id.IdentityGenerator" />
</id>
<property
column="EntityLastName"
length="255"
name="EntityLastName"
not-null="false"
type="string"
/>
<property
column="EntityMiddleInitial"
length="40"
name="EntityMiddleInitial"
not-null="false"
type="string"
/>
<property
column="EntityTIN"
length="10"
name="EntityTIN"
not-null="false"
type="string"
/>
<property
column="Gender"
length="10"
name="Gender"
not-null="false"
type="integer"
/>
<property
column="EntityFullName"
length="125"
name="EntityFullName"
not-null="false"
type="string"
/>
<property
column="Age"
length="10"
name="Age"
not-null="false"
type="integer"
/>
<property
column="EntityDOB"
length="23"
name="EntityDOB"
not-null="false"
type="timestamp"
/>
<property
column="AddressID"
length="10"
name="AddressID"
not-null="false"
type="integer"
/>
<property
column="FaxNumber"
length="10"
name="FaxNumber"
not-null="false"
type="integer"
/>
<property
column="Email"
length="50"
name="Email"
not-null="false"
type="string"
/>
<property
column="FaxAreaCode"
length="10"
name="FaxAreaCode"
not-null="false"
type="integer"
/>
<property
column="UpdateDate"
length="23"
name="UpdateDate"
not-null="false"
type="timestamp"
/>
<property
column="AdjusterEntityID"
length="10"
name="AdjusterEntityID"
not-null="false"
type="integer"
/>
<property
column="PhoneNumber"
length="10"
name="PhoneNumber"
not-null="false"
type="integer"
/>
<property
column="EntityFirstName"
length="40"
name="EntityFirstName"
not-null="false"
type="string"
/>
<property
column="Occupation"
length="255"
name="Occupation"
not-null="false"
type="string"
/>
<property
column="ExternalID"
length="255"
name="ExternalID"
not-null="false"
type="string"
/>
<property
column="PhoneAreaCode"
length="10"
name="PhoneAreaCode"
not-null="false"
type="integer"
/>

<one-to-one
name="Address"
class="Address"
/>

</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
MS SQL Server 2000
The generated SQL (show_sql=true):
Hibernate: insert into Entity (EntityLastName, EntityMiddleInitial, EntityTIN, Gender, EntityFullName, Age, EntityDOB, AddressID, FaxNumber, Email, FaxAreaCode, UpdateDate, AdjusterEntityID, PhoneNumber, EntityFirstName, Occupation, ExternalID, PhoneAreaCode) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Debug level Hibernate log excerpt:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.