I was able to create a working ddl for the sample helloworld-web for Apache
Derby by folowing the developers guide http://fornax-platform.org/cp/x/dAQ.
My changes are far from complete and correct - they are rather quick and
dirty - but may be a starting point to support Apache Derby.
My sculptor-generator.properties:
db.product=custom
db.custom.maxNameLength=27
db.custom.hibernate.dialect=org.hibernate.dialect.DerbyDialects
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.length.Enum=40
My helloworld\src\main\resources\templates\CustomDDL.xpt
«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)»
«REM»
«EXPAND dropSequence»
«EXPAND createSequence»
«EXPAND idPrimaryKey FOREACH
getDomainObjectsInCreateOrder(true).select(d | d.attributes.exists(a|a.name
== "id"))»
«ENDREM»
«EXPAND createTable FOREACH getDomainObjectsInCreateOrder(true)»
«EXPAND createTable FOREACH resolveManyToManyRelations(true)»
«EXPAND manyToManyPrimaryKey FOREACH resolveManyToManyRelations(true)»
«EXPAND naturalKeyConstraint FOREACH
getDomainObjectsInCreateOrder(true).select(d | d.hasNaturalKey()) »
«REM»
«EXPAND uuidConstraint FOREACH
getDomainObjectsInCreateOrder(true).select(d | d.attributes.exists(a |
a.name == "uuid")) »
«ENDREM»
«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 dropSequence FOR Application»
drop sequence hibernate_sequence;
«ENDDEFINE »
«DEFINE createSequence FOR Application»
create sequence hibernate_sequence;
«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 -»
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 extends != null-»,
«EXPAND extendsForeignKeyColumn -»
«ENDIF-»
);
«ENDLET -»
«ENDLET -»
«ENDDEFINE»
«DEFINE column(String prefix) FOR Attribute-»
«prefix»«getDatabaseName()»
«getDatabaseType()»«getDatabaseTypeNullability()-»
«IF name == "id"» PRIMARY KEY GENERATED ALWAYS AS IDENTITY «ENDIF-»
«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 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»
Kind Regards,
René
--
View this message in context:
http://www.nabble.com/Starting-Support-for-Apache-Derby-tp14804464s17564p14804464.html
Sent from the Fornax-Platform mailing list archive at Nabble.com.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Fornax-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fornax-developer