-->
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: problem with 'select SCOPE_IDENTITY()' on distributed tables
PostPosted: Wed Jun 25, 2008 12:22 pm 
Newbie

Joined: Sat Dec 08, 2007 9:22 am
Posts: 10
Hi All,

Heres the problem, we have two SQL servers with "Linked Server" references between them. We have NHibernate able to pull data from these tables and even build the mapped bags, lists, sets by joining between the tables.

We achieved this by adding a fully qualified name to our table name i.e

Table "Categories" on server 1 has an hbm mapping:

Code:
<class name="Category" table="DBSVR1.Jeanie_Master.dbo.Category" select-before-update="false" optimistic-lock="none">

<!-- etc -->

</class>


All is going well, untill we have to persist an object. At the point NHibernate persists an object to SQL using auto increment of the identity field is calls ''select SCOPE_IDENTITY()' to get the last identity value provided by sql e.g.

Code:
INSERT INTO [DBSVR2].[Jeanie_Import].[dbo].ContentProviderImportLog (ContentProviderId, DateImported, IsSucessful) VALUES (1, GETDATE(), 1); select SCOPE_IDENTITY();


Thus we do not get the identity result back and NHibernate throws an exception. What can I do?

Cheers, Chris.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 1:54 pm 
Newbie

Joined: Thu Oct 18, 2007 1:10 pm
Posts: 9
You can auto increment the ID column in the database itself and mark the id tag with the following element.

<generator class="native"/>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 4:51 am 
Newbie

Joined: Sat Dec 08, 2007 9:22 am
Posts: 10
Hi lvelayutham,


Tried that with no joy.

Chris.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 5:29 am 
Newbie

Joined: Sat Dec 08, 2007 9:22 am
Posts: 10
From what I read 'native' chooses the best algorithm based upon the underlying DB. Which in this case seems to be working the same was as 'identity'. The sql output is identical in any case.


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.