You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ddlutils-user@db.apache.org by Laurent ROCHE <la...@yahoo.com> on 2007/01/09 11:04:57 UTC

Re : FK troubles Identity

Hi,

It is still not working properly i.e. not using ID from the data.
Here is the related extract of my bouild.xml file:
<target name="import-derby" description="Creates db and Loads data">
      <taskdef name="ddlToDatabase"
              classname="org.apache.ddlutils.task.DdlToDatabaseTask">
         <classpath refid="classpath"/>
      </taskdef>

      <ddlToDatabase schemaFile="schema-pg.xml" sortforeignkeys="false" verbosity="DEBUG" shutdowndatabase="true" >

         <database url="jdbc:derby:pip_dev"
                 driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
                 username=""
                 password=""/>

         <createDatabase failonerror="true"/>
         <writeSchemaToDatabase/>
        <writeDataToDatabase datafile="data.xml" failonerror="true" ensureforeignkeyorder="true" useexplicitidentityvalues ="true"/>

      </ddlToDatabase>

</target> 


What do I do wrong ?

 
Have fun,
L@u
The Computing Froggy

----- Message d'origine ----
De : Thomas Dudziak <to...@gmail.com>
À : ddlutils-user@db.apache.org
Envoyé le : Mardi, 9 Janvier 2007, 6h33mn 01s
Objet : Re: FK troubles [Was: Not much info with: "Could not parse or write data file"] aka "The Saga continues II "

On 1/8/07, Laurent ROCHE <la...@yahoo.com> wrote:


> PB2 : do not insert generated IDs for IDENTITY
> I have some tables with GENERATED BY DEFAULT AS IDENTITY for the Primary Key (most of my tables refered by FK).
> I would then expect to get the PK from the given value and not a generated value. This is not the case hence the rows from other tables referencing the PK on the first table will not insert as the values are identical.

This should work fine. It is controlled via the
useExplicitIdentityValues parameter
(http://db.apache.org/ddlutils/ant/org.apache.ddlutils.task.WriteDataToDatabaseCommand.html#parameter-useexplicitidentityvalues)
whose default value is false (i.e. use the value defined by the
database (identity column) not the one in the data xml file).



Tom




__________________________________________________
Do You Yahoo!?
En finir avec le spam? Yahoo! Mail vous offre la meilleure protection possible contre les messages non sollicités 
http://mail.yahoo.fr Yahoo! Mail 

Re: Re : FK troubles Identity

Posted by Thomas Dudziak <to...@gmail.com>.
On 1/9/07, Laurent ROCHE <la...@yahoo.com> wrote:

> It is still not working properly i.e. not using ID from the data.
> Here is the related extract of my bouild.xml file:
> <target name="import-derby" description="Creates db and Loads data">
>       <taskdef name="ddlToDatabase"
>               classname="org.apache.ddlutils.task.DdlToDatabaseTask">
>          <classpath refid="classpath"/>
>       </taskdef>
>
>       <ddlToDatabase schemaFile="schema-pg.xml" sortforeignkeys="false" verbosity="DEBUG" shutdowndatabase="true" >
>
>          <database url="jdbc:derby:pip_dev"
>                  driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
>                  username=""
>                  password=""/>
>
>          <createDatabase failonerror="true"/>
>          <writeSchemaToDatabase/>
>         <writeDataToDatabase datafile="data.xml" failonerror="true" ensureforeignkeyorder="true" useexplicitidentityvalues ="true"/>
>
>       </ddlToDatabase>
>
> </target>
>
> What do I do wrong ?

You have to set useexplicitidentityvalues to false, otherwise DdlUtils
will use the values defined in the data XML file, not the ones
generated by the database.

Tom