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)
{
- // [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]