Re: Easily Import/Export tables

From: open.pumpkin (open.pumpki..mail.com)
Date: Tue Sep 08 2009 - 03:24:04 EDT

  • Next message: Arnaud Garcia: "Re: DataContext cache WICKET"

    Thanks for reply.

    I'm considering the ant method but I have a problem and some questions.

    Here the error I receive during execution of my ant script :
    Buildfile: build.xml

    exportTask:
    [cdataport] log4j:WARN No appenders could be found for logger
    (org.apache.cayenne.conf.DefaultConfiguration).
    [cdataport] log4j:WARN Please initialize the log4j system properly.
    [cdataport] Porting from 'Dev_WKN_Node' to 'Local_WKN_Node'.

    BUILD FAILED
    /path/toMy/build.xml:20: Error porting data: null

    Here my build.xml :
    <project name="name of project" default="exportTask" basedir=".">

        <path id="classpath">
            <fileset dir="/home/myUser">
                <include name="cayenne-tools-3.0.jar" />
                <include name="cayenne-server-3.0.jar" />
                <include name="vpp-2.2.1.jar" />
            </fileset>
            <fileset
    dir="/home/myUser/servers/jboss-portal-2.7.2/server/default/lib">
                <include name="**/*.jar" />
            </fileset>
        </path>

        <taskdef name="cdataport"
    classname="org.apache.cayenne.tools.DataPortTask">
            <classpath refid="classpath" />
        </taskdef>

        <target name="exportTask">
            <cdataport
    projectFile="/home/myUser/workspace/gestion-portlet/src/main/webapp/WEB-INF/cayenne/cayenne.xml"
                srcNode="Dev_WKN_Node" destNode="Local_WKN_Node" />
        </target>

    </project>

    Line #20 is : srcNode="Dev_WKN_Node" destNode="Local_WKN_Node" />
    Connections to databases are correct (if I stop one DB, I receive a
    Connection refused exception). Node names are correct. But I'm not familiar
    with ant.
    Can you enlighten me?

    Now some general questions :
    When using the ant method to export DB data, ID's are kept identical in
    different DB's ? Or, if they change, the foreign keys are automatically
    mapped with new ID's ? If not, then this method does not interest me.

    Thanks.
    O.P.

    2009/9/7 Andrus Adamchik <andru..bjectstyle.org>

    > Hi there,
    >
    > Cayenne may not have built in data migration tools that would fit every
    > scenario, although there's been some attempts to write them [1]. At the same
    > time Cayenne is a good *platform* for writing such tools based on either
    > objects (de)serialization, or direct migration [1], and less so for
    > SQL-based migrations (although that's also possible).
    >
    > Note on the XML approach... Current XML (de)serialization API [2] is too
    > raw for my liking, but coincidentally last week I started writing a tool
    > based on XStream [3] to serialize designated object subgraphs (subsets of a
    > large DB defined based on some rules), with the goal of loading that data to
    > another DB or back to the same DB (i.e. cloning). The code turned out to be
    > pretty simple and powerful. It can handle databases of practically any size,
    > and define subgraph scope in terms of mapped relationships. Not yet sure if
    > that becomes open source though.
    >
    > Finally if your export/import rules are something simple (e.g. "transfer
    > the entire DB"), I'd strongly suggest to investigate dump/load tools
    > provided by your database. All of the major DB's have them. This may save
    > you from reinventing the wheel.
    >
    > Cheers,
    > Andrus
    >
    > [1] http://cayenne.apache.org/doc/cdataport.html
    > [2]
    > http://cayenne.apache.org/doc/api/org/apache/cayenne/xml/package-summary.html
    > [3] http://xstream.codehaus.org/
    >
    >
    > On Sep 7, 2009, at 5:07 AM, open.pumpkin wrote:
    >
    > Hello,
    >>
    >> Is it possible to export tables using a dedicated cayenne function ?
    >>
    >> I would like to export one or more tables (and data), specified by the
    >> user
    >> of my application, to import them in another environment (for example from
    >> development to production).
    >>
    >> The ideal thing would be a SQL script generated by cayenne, independant of
    >> databases and cayenne (I could use it with Mysql query browser, for
    >> example).
    >>
    >> Else, using serialization of cayenne objects ?
    >> Or another possibility ?
    >>
    >> The interest is to not manually write SELECT and UPDATE statements.
    >>
    >> Thanx.
    >> O.P.
    >>
    >
    >



    This archive was generated by hypermail 2.0.0 : Tue Sep 08 2009 - 03:24:40 EDT