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: Identity field in database return wrong value
PostPosted: Thu Aug 17, 2006 8:19 am 
Newbie

Joined: Thu Aug 17, 2006 8:10 am
Posts: 3
Hi

I have a class called Case. The case has to have a unique Case number for reference, but this is not a primary key. I have an int identity field in my SqlServer 2005 db table. In my mapping file for the class I have disabled the insert and update for the class so the database kan control the value:

Code:
<class name="xxx.Case, xxx" table="Cases">
   <id name="Id" type="Guid">
      <column name="Id" sql-type="uniqueidentifier" not-null="true" unique="true" index="PK_Cases"/>
      <generator class="assigned" />
   </id>
   <property name="CaseNumber" type="Int32" update="false" insert="false">
      <column name="CaseNumber" sql-type="int" not-null="false"/>
   </property>


My problem is that I can see through the profiler that the correct sql is returned (fx CaseNumber 32), but when it gets through the session, it is always 1.

Has anyone seen this behavior before, or is there another way to have the database issue the value?

Thanx
Code:


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.