cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r612392 - in /cayenne/main/trunk/framework: cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/ cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne...
Date Wed, 16 Jan 2008 09:28:29 GMT
Author: aadamchik
Date: Wed Jan 16 01:28:26 2008
New Revision: 612392

URL: http://svn.apache.org/viewvc?rev=612392&view=rev
Log:
CAY-962 Update PK artifacts (AUTO_PK_SUPPORT and friends) to allow BIGINT values

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/PkGenerator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresPkGenerator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLPkGenerator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sybase/SybasePkGenerator.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/PreferenceDetail.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/PkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/PkGenerator.java?rev=612392&r1=612391&r2=612392&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/PkGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/PkGenerator.java
Wed Jan 16 01:28:26 2008
@@ -73,7 +73,7 @@
     Object generatePkForDbEntity(DataNode dataNode, DbEntity ent) throws Exception;
 
     /**
-     * Generates a unique and non-repeating primary key for specified DbEntity.
+     * Generates a unique and non-repeating primary key for specified PK attribute.
      * 
      * @since 3.0
      */

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresPkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresPkGenerator.java?rev=612392&r1=612391&r2=612392&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresPkGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresPkGenerator.java
Wed Jan 16 01:28:26 2008
@@ -41,6 +41,47 @@
  * @author Tore Halset
  */
 public class IngresPkGenerator extends OraclePkGenerator {
+    
+    @Override
+    protected long longPkFromDatabase(DataNode node, DbEntity entity) throws Exception {
+
+        DbKeyGenerator pkGenerator = entity.getPrimaryKeyGenerator();
+        String pkGeneratingSequenceName;
+        if (pkGenerator != null
+                && DbKeyGenerator.ORACLE_TYPE.equals(pkGenerator.getGeneratorType())
+                && pkGenerator.getGeneratorName() != null)
+            pkGeneratingSequenceName = pkGenerator.getGeneratorName();
+        else
+            pkGeneratingSequenceName = sequenceName(entity);
+
+        Connection con = node.getDataSource().getConnection();
+        try {
+            Statement st = con.createStatement();
+            try {
+                String sql = "SELECT " + pkGeneratingSequenceName + ".nextval";
+                QueryLogger.logQuery(sql, Collections.EMPTY_LIST);
+                ResultSet rs = st.executeQuery(sql);
+                try {
+                    // Object pk = null;
+                    if (!rs.next()) {
+                        throw new CayenneRuntimeException(
+                                "Error generating pk for DbEntity " + entity.getName());
+                    }
+                    return rs.getLong(1);
+                }
+                finally {
+                    rs.close();
+                }
+            }
+            finally {
+                st.close();
+            }
+        }
+        finally {
+            con.close();
+        }
+    }
+    
     /**
      * Generates primary key by calling Oracle sequence corresponding to the
      * <code>dbEntity</code>. Executed SQL looks like this:
@@ -48,6 +89,8 @@
      * <pre>
      *     SELECT nextval(pk_table_name)
      * </pre>
+     * 
+     * @deprecated since 3.0
      */
     @Override
     protected int pkFromDatabase(DataNode node, DbEntity ent) throws Exception {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLPkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLPkGenerator.java?rev=612392&r1=612391&r2=612392&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLPkGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLPkGenerator.java
Wed Jan 16 01:28:26 2008
@@ -227,7 +227,7 @@
         StringBuffer buf = new StringBuffer();
         buf.append("CREATE TABLE AUTO_PK_SUPPORT (").append(
                 "  TABLE_NAME CHAR(100) NOT NULL,").append(
-                "  NEXT_ID INTEGER NOT NULL, UNIQUE (TABLE_NAME)").append(")");
+                "  NEXT_ID BIGINT NOT NULL, UNIQUE (TABLE_NAME)").append(")");
 
         return buf.toString();
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sybase/SybasePkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sybase/SybasePkGenerator.java?rev=612392&r1=612391&r2=612392&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sybase/SybasePkGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sybase/SybasePkGenerator.java
Wed Jan 16 01:28:26 2008
@@ -39,6 +39,19 @@
  * @author Andrus Adamchik
  */
 public class SybasePkGenerator extends JdbcPkGenerator {
+    
+    @Override
+    protected String pkTableCreateString() {
+        StringBuffer buf = new StringBuffer();
+        buf
+                .append("CREATE TABLE AUTO_PK_SUPPORT (")
+                .append("  TABLE_NAME CHAR(100) NOT NULL,")
+                .append("  NEXT_ID DECIMAL(19,0) NOT NULL,")
+                .append("  PRIMARY KEY(TABLE_NAME)")
+                .append(")");
+
+        return buf.toString();
+    }
 
     /**
      * Generates database objects to provide automatic primary key support. Method will
@@ -50,7 +63,7 @@
      * <pre>
      *    CREATE TABLE AUTO_PK_SUPPORT (
      *       TABLE_NAME VARCHAR(32) NOT NULL,
-     *       NEXT_ID INTEGER NOT NULL
+     *       NEXT_ID DECIMAL(19,0) NOT NULL
      *    )
      * </pre>
      * 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/PreferenceDetail.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/PreferenceDetail.java?rev=612392&r1=612391&r2=612392&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/PreferenceDetail.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/pref/PreferenceDetail.java
Wed Jan 16 01:28:26 2008
@@ -198,7 +198,7 @@
                     .lookupDataNode(entity.getDataMap());
 
             try {
-                Object pk = node.getAdapter().getPkGenerator().generatePkForDbEntity(
+                Object pk = node.getAdapter().getPkGenerator().generatePk(
                         node,
                         entity.getPrimaryKeys().iterator().next());
                 otherId.getReplacementIdMap().put(DomainPreference.ID_PK_COLUMN, pk);



Mime
View raw message