Dale,
I did like you and captured the create-table.sql in two files:
db-rmConstraints.sql and db-addConstrains and included the following
task in my db-load before/after bd-unit invocation. Its not 100%
automated but almost there ;-)
#before
<sql
driver="${database.driver_class}"
url="${database.url}"
userid="${database.admin.username}"
password="${database.admin.password}">
<classpath>
<pathelement location="${database.jar}"/>
</classpath>
<fileset dir="${basedir}">
<include name="db-rmConstraints.sql"/>
</fileset>
</sql>
#after
<sql
driver="${database.driver_class}"
url="${database.url}"
userid="${database.admin.username}"
password="${database.admin.password}">
<classpath>
<pathelement location="${database.jar}"/>
</classpath>
<fileset dir="${basedir}">
<include name="db-addConstraints.sql"/>
</fileset>
</sql>
Luiz
On 12/19/06, Luiz Fernando Rodrigues <[EMAIL PROTECTED]> wrote:
I have searched in some postgres forums and it seems that postgres
don't have any feature to turn off constraints (but mysql does). A
(messy) workaround is to setup pg_catalog.pg_class relchecks to 0 and
the setup it back to 1 when you finish .
http://archives.postgresql.org/pgsql-general/2006-08/msg00279.php
Luiz
On 12/18/06, Dale Newfield <[EMAIL PROTECTED]> wrote:
> Luiz Fernando Rodrigues wrote:
> > I have a bidirectional (User-Address) association in my model. When I
> > run db-unit it fails because it tries to insert user rows with
> > association to address, but there is no address created, so I receive
> > a FK violation.
>
> Single bi-directional associations are rarely recorded as columns on
> both tables. In that case, you just need to make sure that the tables
> are listed in a good order in your sample-data.xml file.
>
> > Can I turn off FK constrains before inserting the rows and the turn
> > then on again? (I'm using postgres, but it should not matter, should
> > it?)
>
> If you have multiple associations, you may end up with circular
> dependencies, and it can get trickier. You may need to drop those
> constraints and recreate. I don't have a good solution for this, but I
> wrote up what I do a week ago:
>
>
http://www.nabble.com/about-circular-dependency-in-models-tf2779209s2369.html#a7775198
>
> If you find a non-manual way to do this, please let me know.
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]