|
Fornax-Platform
Forum |
|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
[Sculptor] DbUnit file and join tablesHi,
The code that generates the DBUnit XML file is really robust and is a great time-saver! Thank you so much for writing it. However, we noticed that the generated file is missing the many-to-many join tables. This was pretty simple to fix though. In dbhelper.ext: // get unique list of join tables Set[String] getJoinTableNames(Collection[DomainObject] domainObjects) : domainObjects.collect( d | d.getJoinTableNames()).flatten().toSet(); // get join tables for this domain object Set[String] getJoinTableNames(DomainObject domainObject) : domainObject.references.select(r | isManyToMany(r) && r.to.hasOwnDatabaseRepresentation()) .getManyToManyJoinTableName(); In the template: «DEFINE dbunitTestData FOR Service» «FILE "dbunit/" + name + "Test.xml" TO_RESOURCES_TEST» <?xml version='1.0' encoding='UTF-8'?> <dataset> «LET module.application.getDomainObjectsInCreateOrder(true) AS domainObjects -» «FOREACH domainObjects AS domainObject » <«domainObject.getDatabaseName()» /> «ENDFOREACH » «FOREACH domainObjects.getJoinTableNames() AS joinTableName » <«joinTableName» /> «ENDFOREACH » «ENDLET» </dataset> «ENDFILE » «ENDDEFINE » The code that I tested with is slightly different due to my customizations, but that should be what is needed for Sculptor trunk code. Hope that helps. Thanks, Polly |
|
|
Re: [Sculptor] DbUnit file and join tablesThanks a lot for your contribution Polly. I will include it in trunk.
/Patrik PS. Have you also noticed: http://fornax.itemis.de/jira/browse/CSC-382
|
|
|
Re: [Sculptor] DbUnit file and join tablesHi Patrick,
Sure! Thanks for pointing out CSC-382. I did not see that. We already have code that drops all constraints, runs the delete-all, and then reapplies the constraints, but your solution looks more database agnostic. We may need to switch to using your solution. Thanks! --Polly
|
| Free embeddable forum powered by Nabble | Forum Help |