Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 44906 invoked from network); 11 Nov 2005 16:25:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Nov 2005 16:25:40 -0000 Received: (qmail 11609 invoked by uid 500); 11 Nov 2005 16:25:33 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 11539 invoked by uid 500); 11 Nov 2005 16:25:32 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 11508 invoked by uid 500); 11 Nov 2005 16:25:32 -0000 Received: (qmail 11493 invoked by uid 99); 11 Nov 2005 16:25:32 -0000 X-ASF-Spam-Status: No, hits=-9.3 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME,SUBJECT_NOVOWEL X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 11 Nov 2005 08:25:32 -0800 Received: (qmail 44564 invoked by uid 1510); 11 Nov 2005 16:25:11 -0000 Date: 11 Nov 2005 16:25:11 -0000 Message-ID: <20051111162511.44563.qmail@minotaur.apache.org> From: arminw@apache.org To: db-ojb-cvs@apache.org Subject: cvs commit: db-ojb/src/java/org/apache/ojb/broker/platforms PlatformMsSQLServerImpl.java X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N arminw 2005/11/11 08:25:11 Modified: src/java/org/apache/ojb/broker/platforms PlatformMsSQLServerImpl.java Log: fix OJB-77 Revision Changes Path 1.11 +14 -7 db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformMsSQLServerImpl.java Index: PlatformMsSQLServerImpl.java =================================================================== RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformMsSQLServerImpl.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- PlatformMsSQLServerImpl.java 25 Nov 2004 17:31:34 -0000 1.10 +++ PlatformMsSQLServerImpl.java 11 Nov 2005 16:25:11 -0000 1.11 @@ -59,12 +59,19 @@ public String getLastInsertIdentityQuery(String tableName) { - // matthias.roth@impart.ch - // the function is used by the - // org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl - // this call must be made before commit the insert cammand, so you - // must turn off autocommit by setting the useAutoCommit="2" - return "SELECT @@IDENTITY AS id FROM " + tableName; + /* + More info about the used identity-query see JIRA OJB-77 + http://issues.apache.org/jira/browse/OJB-77 + + As suggested in OJB-77 the latest recommendation from MS was to + use function "SELECT SCOPE_IDENTITY()" to get the latest generated identity + for the current session and scope: + "SCOPE_IDENTITY and @@IDENTITY will return last identity values generated in + any table in the current session. However, SCOPE_IDENTITY returns values + inserted only within the current scope; @@IDENTITY is not limited to a + specific scope." + */ + return "SELECT SCOPE_IDENTITY()"; } /** --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org