Index: cpa/src/main/java/org/castor/cpa/persistence/sql/keygen/SequenceBeforeKeyGenerator.java =================================================================== --- cpa/src/main/java/org/castor/cpa/persistence/sql/keygen/SequenceBeforeKeyGenerator.java (revision 8360) +++ cpa/src/main/java/org/castor/cpa/persistence/sql/keygen/SequenceBeforeKeyGenerator.java (working copy) @@ -28,6 +28,7 @@ import org.exolab.castor.jdo.PersistenceException; import org.castor.core.util.Messages; import org.castor.cpa.persistence.sql.driver.DB2Factory; +import org.castor.cpa.persistence.sql.driver.SapDbFactory; import org.castor.cpa.persistence.sql.driver.InterbaseFactory; import org.castor.cpa.persistence.sql.driver.PostgreSQLFactory; import org.castor.cpa.persistence.sql.driver.OracleFactory; @@ -248,6 +249,31 @@ } } + /** + * Implements SequenceKeyGenValueHandler that generates sql query for fetching + * identity from sap/max database. + */ + private class SapDbType extends SequenceKeyGenValueHandler { + + /** + * Generates sql select query for fetching identity and then calss the + * base class getValue method of query execution. + * + * @param conn An open JDBC connection. + * @param tableName Name of the table from which identity will be fetched. + * @param primKeyName Primary key of the table. + * @param props database engine specific properties. + * @return ResutlSet containing identity. + * @throws Exception If database error occurs. + */ + protected Object getValue(final Connection conn, final String tableName, + final String primKeyName, final Properties props) throws Exception { + return getValue("SELECT " + + _factory.quoteName(getSeqName(tableName, primKeyName) + ".nextval") + + " FROM DUAL", conn); + } + } + //----------------------------------------------------------------------------------- /** The Jakarta @@ -341,6 +367,8 @@ _type = new PostgresqlType(); } else if (OracleFactory.FACTORY_NAME.equals(factoryName)) { _type = new OracleType(); + } else if (SapDbFactory.FACTORY_NAME.equals(factoryName)) { + _type = new SapDbType(); } else { _type = new DefaultType(); } Index: cpa/src/main/java/org/castor/cpa/persistence/sql/keygen/SequenceKeyGeneratorFactory.java =================================================================== --- cpa/src/main/java/org/castor/cpa/persistence/sql/keygen/SequenceKeyGeneratorFactory.java (revision 8352) +++ cpa/src/main/java/org/castor/cpa/persistence/sql/keygen/SequenceKeyGeneratorFactory.java (working copy) @@ -19,6 +19,7 @@ import org.castor.core.util.Messages; import org.castor.cpa.persistence.sql.driver.PostgreSQLFactory; +import org.castor.cpa.persistence.sql.driver.SapDbFactory; import org.exolab.castor.mapping.MappingException; import org.exolab.castor.persist.spi.PersistenceFactory; @@ -69,8 +70,8 @@ } if (returning) { - // for PostgreSQL temporary fall back to before until during is supported - if (PostgreSQLFactory.FACTORY_NAME.equals(factoryName)) { + if (PostgreSQLFactory.FACTORY_NAME.equals(factoryName) || + SapDbFactory.FACTORY_NAME.equals(factoryName)) { return new SequenceBeforeKeyGenerator(factory, params, sqlType); } return new SequenceDuringKeyGenerator(factory, params, sqlType); Index: src/doc/release-notes.xml =================================================================== --- src/doc/release-notes.xml (revision 8361) +++ src/doc/release-notes.xml (working copy) @@ -91,6 +91,26 @@ ]]> + + + use of key generator on MaxDB generates wrong command. + + + Ahmad Hassan + ahmad.hassan@gmail.com + + + Ralf Joachim + ralf.joachim@syscon.eu + + + Ahmad Hassan + ahmad.hassan@gmail.com + + Enh. + JDO + 20090812 + Add missing javadoc to KeyGeneratorTypeHandler interface and its implementations.