arminw 2005/11/11 08:21:39
Modified: src/java/org/apache/ojb/broker/platforms Tag:
OJB_1_0_RELEASE PlatformMsSQLServerImpl.java
Log:
fix OJB-77
Revision Changes Path
No revision
No revision
1.8.2.1 +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.8
retrieving revision 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- PlatformMsSQLServerImpl.java 4 Apr 2004 23:53:35 -0000 1.8
+++ PlatformMsSQLServerImpl.java 11 Nov 2005 16:21:39 -0000 1.8.2.1
@@ -59,12 +59,19 @@
public String getLastInsertIdentityQuery(String tableName)
{
- // [EMAIL PROTECTED]
- // 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]