Hello Edoardo -

I got this to work with Ant and OpenJPA 1.2.1 similar to what you are doing with schemaAction=build and sqlFile=abc.sql (without "action" element).

However I gave up on the taskdef when I found that I could not specify java arguments and sysproperty values to the Ant task. I need the sysproperty value for java.util.logging config file location. I need the java argument because there is no way to specify the PersistenceUnit if there are multiple PersistentUnits in persistence.xml (at least I didn't see how to specify that).

This is what I am doing instead of the taskdef ("lg.dealers.dev" is the persistence-unit) -

<property name="persistence.unit" value="persistence.xml#lg.dealers.dev" />
   <property name="drop.tables.file" value="drop_lg_tables.sql" />
   <property name="create.tables.file" value="create_lg_tables.sql" />

   <target name="schema" depends="enhance">
<java classname="org.apache.openjpa.jdbc.meta.MappingTool" fork="yes" failonerror="yes"> <arg line="-p ${persistence.unit} -schemaAction build -sql ${create.tables.file}" /> <sysproperty key="java.util.logging.config.file" value="logging.properties"/>
           <classpath refid="class.path" />
       </java>
   </target>




On 4/6/2009 2:47 AM, Edoardo Panfili wrote:
Good morning,

I am trying to use the mapping tool to generate SQL instructions for database generation (only to check, I already have a working DB), I am using Ant to call the mapping tool.

--------------------------------------------------------------------
<taskdef name="mappingtool"
  classname="org.apache.openjpa.jdbc.ant.MappingToolTask">
  <classpath>
    <path>
      <fileset dir="/usr/local/openjpa/">
        <include name="*.jar" />
      </fileset>
    </path>
  </classpath>
</taskdef>

<target name="SQL">
  <mappingtool action="buildSchema" schemaaction="createDB"
    sqlfile="/tmp/db.sql" >
    <config propertiesFile="${progetto.src}/META-INF/persistence.xml" />
    <fileset dir="${progetto.bin}">
      <include name="**/obj/**.class" />
    </fileset>
  </mappingtool>
</target>
--------------------------------------------------------------------

I did some search on google and nabble, the propertiesFile seems to be correct (is the one used in production), the fileset is the same in the enhance task (that works). But after task execution /tmp/db.sql in empty.

In am using openJPA 1.2.1 and Eclipse 3.4.

Any suggestion (or link to documentation that I must read after openJPA manual) ?

thank you
Edoardo





Reply via email to