This is how I have been handling passing of properties of to our ant mapping task. All of the persistence classes are still listed in our persistence.xml file. I am still pretty new too this stuff so I could be doing it wrong but this seems to work for me.

<target name="map_build" description="This builds the schema fails if schema present"> <taskdef name="mappingtool" classname="org.apache.openjpa.jdbc.ant.MappingToolTask">
           <classpath refid="project.class.path" />
       </taskdef>
       <mappingtool action="buildSchema">
<config propertiesFile="${basedir}\source\META-INF\persistence.xml"
             connectionUserName="sa"
             connectionPassword=""
             connectionURL="jdbc:h2:${basedir}/db/h2-database/h2-database"
             connectionDriverName="org.h2.Driver" />
           <classpath refid="project.class.path" />
       </mappingtool>
   </target>

Daryl Stultz wrote:
Hello, my persistence.xml includes properties like so:

<property name="openjpa.ConnectionDriverName" value="MyDataSource" />
<property name="openjpa.ConnectionProperties" value="Thing=one"/>

This doesn't work for the ant mapping task (maybe it CAN, but I haven't
written it to do so). So I need this in my persistence.xml file:

<property name="openjpa.ConnectionURL"
value="jdbc:postgresql://localhost/mydb" />
<property name="openjpa.ConnectionDriverName" value="org.postgresql.Driver"
/>
<property name="openjpa.ConnectionUserName" value="name" />
<property name="openjpa.ConnectionPassword" value="pass" />

Is there a way I can specify these properties for the mapping task? I could
use a copy of persistence.xml, but then I have to maintain the two.

Thanks.


Reply via email to