openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <kwsut...@gmail.com>
Subject Re: MappingTool : Java class and Ant task
Date Tue, 22 Mar 2011 16:00:54 GMT
Hi Jean-Baptiste,
The Mapping Tool has two separate "action" parameters:  -schemaAction and
-action.

-schemaAction build should be similar to the SchemaTool usage:

   -

   build: Generate SQL to build a schema matching the one in the given XML
   file. Unlike add, this option does not take into account the fact that
   part of the schema defined in the XML file might already exist in the
   database. Therefore, this action is typically used in conjunction with the
   -file flag to write a SQL script. This script can later be used to
   recreate the schema in the XML

-action buildSchema is more commonly used and I believe is the action you
are really looking for:

   - buildSchema: This is the default action. It makes the database schema
   match your existing mappings. If your provided mappings conflict with your
   class definitions, OpenJPA will fail with an informative exception.

Since the Mapping Tool already provides the ability to drop tables:

   - -dropTables/-dt <true/t | false/f>: Corresponds to the same-named
   option on the schema tool.

Since all of the MappingTool parameters should be accessible from the ant
task, the corresponding ant task invocation should be similar to this
(although I have not personally tried it):

  <mappingtool dropTables="true" action="buildSchema">
    <fileset dir=".">
      <include name="**/*.java" />

    </fileset>
  </mappingtool>


Make sense?  I don't use Ant, so I don't know for sure that this all works,
but according to our docs, it should...  :-)

Good luck,
Kevin

On Tue, Mar 22, 2011 at 10:39 AM, Jean-Baptiste BRIAUD -- Novlog <
j-b.briaud@novlog.com> wrote:

> Hi,
>
> There is 2 ways to use the same MappingTool : as a Java class or as an Ant
> task.
>
>
> http://openjpa.apache.org/builds/2.1.0/apache-openjpa-2.1.0/docs/manual/manual.html#ref_guide_integration_mappingtool
>
> http://openjpa.apache.org/builds/2.1.0/apache-openjpa-2.1.0/docs/manual/manual.html#ref_guide_mapping_mappingtool
>
> It look like the same but it is not, at least on syntax point of view :
>
> On command line according to the doc : -schemaAction build
> On ant task : <mappingtool action="buildSchema"
> On reality from my experience for command line : ... -action buildSchema
>
> Currently, I manage to make it work but I'd like to add more parameters
> like -dropTables true.
> What would be the Ant task syntax for it ?
>
> What would be the recommended way to use it ?
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message