So I've decided to give OpenJPA a go and so far I no luck. I followed this as best I could: http://struberg.wordpress.com/2012/01/08/jpa-enhancement-done-right/ org.apache.openjpa.persistence.ArgumentException: The type "class com.MyClass" has not been enhanced. is the problem.
I tried to follow this these steps to solve it since I'm pretty unfamiliar with ANT.
Add maven plugin
<plugin> <groupId>org.apache.openjpa</groupId> <artifactId>openjpa-maven-plugin</artifactId> <version>2.2.0</version> <configuration> <includes>com/myproject/core/domain/*.class</includes> <addDefaultConstructor>true</addDefaultConstructor> <enforcePropertyRestrictions>true</enforcePropertyRestrictions> <!-- Pass additional properties to the Plugin here --> <toolProperties> <property> <name>directory</name> <value>otherdirectoryvalue</value> </property> </toolProperties> </configuration> <executions> <execution> <id>enhancer</id> <phase>process-classes</phase> <goals> <goal>enhance</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>org.apache.openjpa</groupId> <artifactId>openjpa</artifactId> <version>2.2.0</version> </dependency> </dependencies> </plugin>
So now when try I clean project then server, then use maven and mvn clean process-classes It then successfully enhances the classes I have specified.
Start server and try a simple persist that worked with hibernate and it gives me:
openjpa-2.2.0-r422266:1244990 fatal user error> org.apache.openjpa.persistence.ArgumentException: The type "class com.myproject.core.domain.MyClass" has not been enhanced. FailedObject: com.myproject.core.domain.MyClass@aecda16 [java.lang.String] at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1823) at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1797) at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:822) at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:719) at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:643) at org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:411) at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:384)
<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_2_0.xsd"
version="2.0">
<persistence-unit name="myproj_pu"
transaction-type="RESOURCE_LOCAL">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<!-- MySQL -->
<properties>
<property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:3306/myproject" />
<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver" />
<property name="openjpa.ConnectionUserName" value="root" />
<property name="openjpa.ConnectionPassword" value="1111" />
<property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO" />
</properties>
</persistence-unit>
</persistence>
Frankly I don't really understand how a reasonable work flow is supposed to look like with this even if I get it to work. Maybe use another strategy or something?
Would love some pointers and tips and of course help with the problem.
Cheers
I think the only thing you missed is adding the following line inside the "persistence-unit" element of your persistence.xml:
The enhancer looks for these class definitions inside of persistence.xml so it knows which classes to enhance.