You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Daryl Stultz <da...@6degrees.com> on 2009/05/21 17:42:34 UTC

Mapping Ant Task - configure datasource

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.

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com

Re: Mapping Ant Task - configure datasource

Posted by Daryl Stultz <da...@6degrees.com>.
On Thu, May 21, 2009 at 12:02 PM, Gene Shaw <gs...@ogresystems.com> wrote:

> This is how I have been handling passing of properties of to our ant
> mapping task.


Sweet, that does it. Turns out it works for the enhancer task as well...
Thanks.

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com

Re: Mapping Ant Task - configure datasource

Posted by Michael Dick <mi...@gmail.com>.
Gene, you're doing it right :-)

-mike

On Thu, May 21, 2009 at 11:02 AM, Gene Shaw <gs...@ogresystems.com> wrote:

> 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.
>>
>>
>>
>
>

Re: Mapping Ant Task - configure datasource

Posted by Gene Shaw <gs...@ogresystems.com>.
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.
>
>