db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/platforms PlatformMsSQLServerImpl.java
Date Fri, 11 Nov 2005 16:25:11 GMT
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


Mime
View raw message