1.
环境
jdk version: 1.5
ant version: 1.6.5
database version: Oracle 9.2
tomcat version: 5.0.28
2.
download:
Example Source Code TopLink JPA jar3.
gen warunzip order-jsf-jpa-example.zip to <EXAMPLE_HOME>
java -jar glassfish-persistence-installer-9.0-b48.jar
Add toplink-essentials.jar and toplink-essentials-agent.jar to: <EXAMPLE_HOME>
modify <EXAMPLE_HOME>\persistence-unit\src\META-INF\persistence.xml
<properties>
<property name="toplink.ddl-generation" value="create-tables"/> <!-- 下载包没有的 -->
<property name="toplink.logging.level" value="FINE"/>
<property name="toplink.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/> <!-- update to match database-->
<property name="toplink.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:ora92"/> <!-- update to match database-->
<property name="toplink.jdbc.password" value="tiger"/> <!-- update to match database-->
<property name="toplink.jdbc.user" value="scott"/> <!-- update to match database-->
</properties>
modify <EXAMPLE_HOME>\extras\src\oracle\toplink\jpa\example\inventory\tools\DDLGenerator.java
public static void main(String args[]){
Map properties = new HashMap();
// properties.put("toplink.ddl-generation", "drop-and-create-tables");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("default", properties);
emf.createEntityManager().close();
emf.close();
}
ant generate-tables
ant populate-data
ant package.webapp
4.
deployDeploy the <EXAMPLE_HOME>\web-application\deploy\jpa-example.war file to Tomcat
参考:
1.
http://www.oracle.com/technology/products/ias/toplink/jpa/tutorials/jsf-jpa-tutorial.html2.
http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-extensions.html#Java2DBSchemaGenP.S.:使用annotation代替xml, 且object默认同名映射table,爽啊,可惜的是项目暂时不可能用到,websphere 5.x和weblogic 8.x都不支持jdk 1.5