Hi,
Can someone provide an example of how to declare a datasource and use
JPA in a web project like siwpas-sample-collapse?
Using a presistence.xml like this:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="
http://java.sun.com/xml/ns/persistence"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</
provider>
<class>siwpas.sample.par.Person</class>
<properties>
<property name="openjpa.jdbc.DBDictionary"
value="mysql(SupportsSubselect=true)" />
<property name="openjpa.ConnectionDriverName"
value="com.mysql.jdbc.Driver" />
<property name="openjpa.ConnectionURL" value="jdbc:mysql://
localhost/openjpa" />
<property name="openjpa.ConnectionUserName" value="openjpa" />
<property name="openjpa.ConnectionPassword" value="openjpa" />
<property name="openjpa.Log" value="DefaultLevel=TRACE" />
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)" />
</properties>
</persistence-unit>
</persistence>
the open-jpa plugin start in siwpas, but the entitiy manager give an
error like this:
http://mail-archives.apache.org/mod_mbox/openjpa-users/200907.mbox/%3C124648310551...@n2.nabble.com%3E
I also tried to use a datasource declaration in persistence.xml
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="
http://java.sun.com/xml/ns/persistence"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="default" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</
provider>
<jta-data-source>default</jta-data-source>
<properties>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)" />
</properties>
</persistence-unit>
</persistence>
and using openejb.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Resource id="default" type="DataSource">
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql://localhost/openjpa
UserName openjpa
Password openjpa
</Resource>
but it don't works!!
Soma ideas?
thanks in advance
fiorenzo