ANT task WsJpaDBGenTask

The ANT task WsJpaDBGenTask provides an alternative to the wsdbgen command.

The WsJpaDBGenTask ANT task utility supports utilizing the pureQuery feature in Java™ Persistence API (JPA) 2.0 applications that use WSJPA and do not use DB2® databases. Instead of using the wsdbgen from the command line, you can use the example code in your ANT build XML file to use the WsJpaDBGenTask in your build process.

Both the PDQ runtime Java archive (JAR) files, pdq.jar and pdqmgmt.jar, must be specified using the ANT -lib option.

注意: Read more about the DB2 JAR level compliance for pureQuery at the IBM® Support website: System requirements for IBM Optim™ pureQuery Run time for Linux, UNIX, and Windows.

Example

The following example is run in the Windows environment with the ANT command:
C:\jpa\ant jar -noclasspath -lib  c:/AppServer/dev/JavaEE/j2ee.jar 
-lib ${app_server_root}/runtimes/com.ibm.ws.jpa.-2.0 thinclient_9.0.jar 
-lib c:/sqllib/java/db2jcc.jar 
-lib c:/sqllib/java/db2jcc_license_cu.jar 
-lib c:/sqllib/java/pdq.jar 
-lib c:/sqllib/java/pdqmgmt.jar 
当调用 ANT 命令时,pureQuery、JPA 和 JDBC 驱动程序的 JAR 文件必须位于库列表上。
<?xml version="1.0"?> 
<project name="sample" default="jar"> 
<taskdef name="enhancer" classname="org.apache.openjpa.ant.PCEnhancerTask" /> 
<taskdef name="wsdbgen" classname="com.ibm.websphere.persistence.pdq.ant.WsJpaDB2GenTask" /> 
<target name="clean" description="remove intermediate files"> 
<delete dir="classes"/> 
<delete dir="enhanced" /> 
<delete> 
<fileset dir="." includes="META-INF/*.pdqxml" /> 
<fileset dir="." includes="sample.jar" /> 
</delete> 
</target> 

<target name="compile" 
description="compile the Java source code to class files"> 
<mkdir dir="classes"/> 
<javac srcdir="." destdir="classes"> 
<classpath> 
<pathelement location="c:/AppServer/dev/JavaEE/j2ee.jar>" 
<pathelement location="c:/AppServer/runtimes/com.ibm.ws.jpa-2.0.thinclient_9.0.jar" /> 
</classpath> 
</javac> 
</target> 

<target name="enhance" depends="compile" > 
<mkdir dir="enhanced" /> 
<enhancer directory="./enhanced" > 
<config propertiesFile="META-INF/persistence.xml" /> 
<classpath> 
<pathelement location="." /> 
<pathelement location="classes" /> 
</classpath> 
</enhancer> 
</target> 


<target name="wsdbgen" depends="enhance" > 
<wsdb2gen pu="MyAntTest" url="jdbc:db2://localhost:50000/demodb" user="user1" pw="secret" > 
<classpath> 
<pathelement location="."/> 
<pathelement location="enhanced" /> 
</classpath> 
</wsdb2gen> 
</target> 


<target name="jar" depends="wsdbgen" 
description="create a Jar file for the application"> 
<jar destfile="sample.jar"> 
<fileset dir="classes" includes="**/*.class"/> 
<fileset dir="." includes="META-INF/*.xml" /> 
</jar> 
</target> 
</project> 

指示主题类型的图标 参考主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=rejb_wsdbJpaDBgenant
文件名:rejb_wsdbJpaDBgenant.html