Hi again Edoardo -
This seems wrong in your task - <config
propertiesFile="${progetto.src}/META-INF/persistence.xml" />
I don't think the persistence.xml file is the right kind of config file
for these Ant tasks. Maybe someone on the list can clarify this???
"-action buildSchema" is the default so it probably does not matter if
it is included or not.
"-schemaAction build -sql myfile.sql" are what you need to create the
sql script.
This should also work with the taskdef (it did for me but I needed
arguments that could not be specified with the taskdef)
You are using the fileset to define the classes you want to map. I am
using the classes listed in persistence.xml which is why I need to
specify a persistence-unit on the command line.
- Pau|l|
On 4/7/2009 7:16 AM, Edoardo Panfili wrote:
Il 6-04-2009 18:14, Paul Copeland ha scritto:
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).
without "action" element -> zero length file.
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).
For this project I use only one persistence unit. And I am not
specifing it in the <mappingtool> tag. I try with your approach.
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>
It seems that I must use fork="no" in the other way I have problems
with classpath (this is not a problem).
<property name="persistence.unit"
value="${progetto.src}/META-INF/persistence.xml#my_persistence_unit_name"/>
is the line taht I use, it seems work but I must disable poolable
connections (or Ant sends back
"org.apache.openjpa.util.StoreException: Cannot create
PoolableConnectionFactory ...") another easy to solve problem, I use
direct connection (without a pool) but anyway a zero length file.
regards
Edoardo
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