Hello. Thank you very much for fixing the bug! The ddl is now generated correctly.
One last issue remains. The Hibernate mapping files are generated containing this: <id name="id"> <generator class="native"/> </id> This does not work out of the box with derby. Also see http://opensource.atlassian.com/projects/hibernate/browse/HHH-1918. One would be required to create a HiloTable or wait until Hibernate fixes the bug. Instead, I prefer to generate the hibernate mapping automatically like this: <id name="id"> <generator class="identity"/> </id> I solved the issue by changing the SpecialCases.xpt to: «IMPORT sculptormetamodel» «EXTENSION extensions::helper» «EXTENSION extensions::properties» «EXTENSION extensions::dbhelper» «AROUND *::dummyPlaceholder FOR Object» «targetDef.proceed()» «ENDAROUND» «AROUND *::id FOR DomainObject» <id name="«getIdAttribute().name»" «IF getIdAttribute().getHibernateType() != null»type="«getIdAttribute().getHibernateType()»"«ENDIF»> <generator class="identity" /> </id> «ENDAROUND» So far, I have a working derby support. including enums. Status: Works for me in a small example, but does certainly not support all projects/features. I will not have the time to continue my work, but others may continue to work on my 'legacy' ;-) CustomDDL.xpt «REM» * Copyright 2007 The Fornax Project Team, including the original * author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. «ENDREM» «IMPORT sculptormetamodel» «EXTENSION extensions::helper» «EXTENSION extensions::dbhelper» «EXTENSION extensions::properties» «DEFINE ddl FOR Application» «FILE "dbschema/" + name + "_derby_ddl.sql" TO_GEN_RESOURCES» «REM»Drop in reverse order«ENDREM» «EXPAND dropIndex FOREACH getDomainObjectsInCreateOrder(false)» «EXPAND dropTable FOREACH resolveManyToManyRelations(false)» «EXPAND dropTable FOREACH getDomainObjectsInCreateOrder(false)» «EXPAND createTable FOREACH getDomainObjectsInCreateOrder(true)» «EXPAND createTable FOREACH resolveManyToManyRelations(true)» «EXPAND idPrimaryKey FOREACH getDomainObjectsInCreateOrder(true).select(d | d.attributes.exists(a|a.name == "id"))» «EXPAND manyToManyPrimaryKey FOREACH resolveManyToManyRelations(true)» «EXPAND naturalKeyConstraint FOREACH getDomainObjectsInCreateOrder(true).select(d | d.hasNaturalKey()) » «EXPAND uuidConstraint FOREACH getDomainObjectsInCreateOrder(true).select(d | d.attributes.exists(a | a.name == "uuid")) » «EXPAND extendsForeignKeyConstraint FOREACH getDomainObjectsInCreateOrder(true).select(d | d.extends != null)» «EXPAND foreignKeyConstraint FOREACH getDomainObjectsInCreateOrder(true)» «EXPAND foreignKeyConstraint FOREACH resolveManyToManyRelations(true)» «EXPAND index FOREACH getDomainObjectsInCreateOrder(true)» «ENDFILE » «ENDDEFINE » «DEFINE dropTable FOR DomainObject» DROP TABLE «getDatabaseName()»; «ENDDEFINE » «DEFINE createTable FOR DomainObject» «LET references.select(r | !r.many && (r.to.hasOwnDatabaseRepresentation())).size != 0 AS hasOneReferences -» «LET getBasicTypeReferences().size != 0 AS hasContainedColumns -» «LET references.select(r | r.to.metaType == Enum).size != 0 AS hasEnumColumns -» CREATE TABLE «getDatabaseName()» ( «EXPAND column("") FOREACH attributes SEPARATOR ", "-» «IF (attributes.size > 0) && (hasOneReferences) -», «ENDIF-» «EXPAND foreignKeyColumn FOREACH references.select(r | !r.many && (r.to.hasOwnDatabaseRepresentation())) SEPARATOR ", "-» «IF ((attributes.size > 0) || hasOneReferences) && (hasContainedColumns) -», «ENDIF-» «EXPAND containedColumns FOREACH getBasicTypeReferences()-» «IF ((attributes.size > 0) || hasOneReferences || hasContainedColumns) && (hasEnumColumns) -», «ENDIF-» «EXPAND enumColumn FOREACH references.select(r | r.to.metaType == Enum) SEPARATOR ", "-» «IF extends != null-», «EXPAND extendsForeignKeyColumn -» «ENDIF-» ); «ENDLET -» «ENDLET -» «ENDLET -» «ENDDEFINE» «DEFINE column(String prefix) FOR Attribute-» «prefix»«getDatabaseName()» «getDatabaseType()»«getDatabaseTypeNullability()-» «ENDDEFINE» «DEFINE enumColumn FOR Reference-» «getDatabaseName()» «getEnumDatabaseType()»«getDatabaseTypeNullability()-» «ENDDEFINE» «DEFINE containedColumns FOR Reference-» «EXPAND column(getDatabaseName() + "_") FOREACH to.attributes SEPARATOR ", "-» «ENDDEFINE» «DEFINE idPrimaryKey FOR DomainObject» ALTER TABLE «getDatabaseName()» ADD CONSTRAINT PK_«getDatabaseName()» PRIMARY KEY («attributes.select(a | a.name == "id").first().getDatabaseName()») ; «ENDDEFINE» «DEFINE manyToManyPrimaryKey FOR DomainObject» ALTER TABLE «getDatabaseName()» ADD CONSTRAINT PK_«getDatabaseName()» PRIMARY KEY («FOREACH references AS r SEPARATOR ", "»«r.getForeignKeyName()»«ENDFOREACH») ; «ENDDEFINE» «DEFINE foreignKeyColumn FOR Reference-» «IF "list" == collectionType-» «getDatabaseName()»_INDEX INTEGER(10), «ENDIF-» «getForeignKeyName()» «getForeignKeyType() -» «ENDDEFINE» «DEFINE extendsForeignKeyColumn FOR DomainObject-» «extends.getForeignKeyName()» «extends.getForeignKeyType()», «ENDDEFINE» «DEFINE foreignKeyConstraint FOR DomainObject-» «EXPAND foreignKeyConstraint FOREACH references.select(r | !r.many && (r.to.hasOwnDatabaseRepresentation()))» «ENDDEFINE» «DEFINE foreignKeyConstraint FOR Reference-» ALTER TABLE «from.getDatabaseName()» ADD CONSTRAINT FK_«truncateLongDatabaseName(from.getDatabaseName() + "_" + getDatabaseName())» FOREIGN KEY («getForeignKeyName()») REFERENCES «to.getRootExtends().getDatabaseName()» (ID)« IF (opposite != null) && opposite.isDbOnDeleteCascade()» ON DELETE CASCADE«ENDIF» ; «ENDDEFINE» «DEFINE extendsForeignKeyConstraint FOR DomainObject-» ALTER TABLE «getDatabaseName()» ADD CONSTRAINT FK_«truncateLongDatabaseName(getDatabaseName() + "_" + extends.getDatabaseName())» FOREIGN KEY («extends.getForeignKeyName()») REFERENCES «extends.getRootExtends().getDatabaseName()» (ID) ; «ENDDEFINE» «DEFINE naturalKeyConstraint FOR DomainObject-» ALTER TABLE «getDatabaseName()» «IF getNaturalKeyReference() != null -» ADD CONSTRAINT UQ_«getDatabaseName()»_KEY UNIQUE («FOREACH getNaturalKeyReference().to.attributes.select(a | a.naturalKey) AS a SEPARATOR ", "»«getNaturalKeyReference().getDatabaseName()»_«a.getDatabaseName()»«ENDFOREACH») «ELSE -» ADD CONSTRAINT UQ_«getDatabaseName()»_KEY UNIQUE («FOREACH attributes.select(a | a.naturalKey) AS a SEPARATOR ", "»«a.getDatabaseName()»«ENDFOREACH») «ENDIF» ; «ENDDEFINE» «DEFINE uuidConstraint FOR DomainObject-» ALTER TABLE «getDatabaseName()» ADD CONSTRAINT UQ_«getDatabaseName()»_UUID UNIQUE (UUID) ; «ENDDEFINE» «DEFINE index FOR DomainObject-» «EXPAND index("", this) FOREACH attributes.select(a | a.index == true)-» «EXPAND containedColumnIndex FOREACH getBasicTypeReferences()-» «ENDDEFINE» «DEFINE containedColumnIndex FOR Reference-» «EXPAND index(getDatabaseName() + "_", from) FOREACH to.attributes.select(a | a.index == true)» «ENDDEFINE» «DEFINE index(String prefix, DomainObject domainObject) FOR Attribute-» CREATE INDEX IDX_«truncateLongDatabaseName(domainObject.getDatabaseName() + "_" + prefix + getDatabaseName())» ON «domainObject.getDatabaseName()» («prefix»«getDatabaseName()» ASC) ; «ENDDEFINE» «DEFINE dropIndex FOR DomainObject-» «EXPAND dropIndex("", this) FOREACH attributes.select(a | a.index == true)-» «EXPAND dropContainedColumnIndex FOREACH getBasicTypeReferences()-» «ENDDEFINE» «DEFINE dropContainedColumnIndex FOR Reference-» «EXPAND dropIndex(getDatabaseName() + "_", from) FOREACH to.attributes.select(a | a.index == true)» «ENDDEFINE» «DEFINE dropIndex(String prefix, DomainObject domainObject) FOR Attribute-» DROP INDEX IDX_«truncateLongDatabaseName(domainObject.getDatabaseName() + "_" + prefix + getDatabaseName())»; «ENDDEFINE» sculptor-generator.properties # Derby specific settings db.product=custom db.custom.maxNameLength=27 db.custom.hibernate.dialect=org.hibernate.dialect.DerbyDialect db.custom.onDeleteCascade=true db.custom.type.Boolean=CHAR(1) db.custom.type.byte=CHAR db.custom.type.Byte=CHAR db.custom.type.short=SMALLINT db.custom.type.Short=SMALLINT db.custom.type.Integer=INTEGER db.custom.type.int=INTEGER db.custom.type.Long=BIGINT db.custom.type.long=BIGINT db.custom.type.Date=DATE db.custom.type.java.util.Date=DATE db.custom.type.DateTime=DATE db.custom.type.Timestamp=DATE db.custom.type.BigDecimal=DECIMAL db.custom.type.Double=DOUBLE db.custom.type.double=DOUBLE db.custom.type.String=VARCHAR db.custom.length.String=100 db.custom.type.Enum=VARCHAR db.custom.length.Enum=40 db.custom.type.ShortString=VARCHAR db.custom.length.ShortString=40 javaType.ShortString=String Kind Regards, René -- View this message in context: http://www.nabble.com/Starting-Support-for-Apache-Derby-tp14804464s17564p14917895.html Sent from the Fornax-Platform mailing list archive at Nabble.com. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Fornax-developer mailing list Fornax-developer@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fornax-developer