|
|
|
[
Permlink
| « Hide
]
Stephan Kleine - 05/Nov/09 03:09 PM
Small test case showing the problem
The property dbMaintainer.disableConstraints.enabled=true only works when you use unitils to update your database, using the dbmaintainer. It appears that your schema is generated using hibernate. Simply call DatabaseUnitils.disableConstraints() instead.
The reason that we don't perform disabling if the dbmaintainer is not used, is that in that case we don't know whether the database schema was updated. For most projects running the disable constraints operation is costly, even when there's nothing to disable anymore. You don't want to wait for this operation to complete before each test run. Therefore we let the user decide when it's needed to run this operation again. > The property dbMaintainer.disableConstraints.enabled=true only works when you use unitils to update your database, using the dbmaintainer.
You are right, I currently use jpa to maintain my database and it works when I switch to dbmaintainer (explicitly stating that in the docs would be great to avoid confusion ;)) However, calling "DatabaseUnitils.disableConstraints()" either in the test method or in some other one annotated with @BeforeSuite / BeforeWhatever doesn't help. I get "INFO: Disabling constraints in database schema PUBLIC" shown in the log but inserting my test data still fails because of the constraints not being disabled. How to reproduce with the above test case: Insert the following method into the BookDAOLocalBeanTest class: @BeforeSuite public void disableConstraints() { logger.info("Disabling constraints"); DatabaseUnitils.disableConstraints(); logger.info("Contraints disabled"); } Therefore please reopen this bug because the issue still exists and the suggested workaround doesn't work. |
||||||||||||||||||||||||||||||||||||||||||||||