Out of desperation I tried to use the PCEnhanceTask via antrun in my maven
build.
<taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask">
<classpath refid="enhance_classpath" />
</taskdef>
<openjpac>
<classpath refid="enhance_classpath" />
<config propertiesFile="SOME_PATH${file.separator}persistence.xml" />
</openjpac>
As you can see I use the persistence.xml to provide the entities that need
enhancing. The PU also contains said option (<property
name="openjpa.DetachState" value="loaded(DetachedStateField=true)"/>).
Still, my entities receive transient fields:
protected transient boolean pcVersionInit;
protected transient StateManager pcStateManager;
private transient Object pcDetachedState;
I don't understand why this configuration only works for runtime enhancement,
especially if runtime enhancement is strongly discouraged to be used in
production.
:-(
With kind regards
Christian Mötzing
Consultant
NOVA TEC // Consulting GmbH
Dieselstrasse 18/1 // D-70771 Leinfelden-Echterdingen
phone: +49 711 22040-718
fax: +49 711 22040-899
mobile: +49 1608806281
e-mail: [email protected]
web: www.novatec-gmbh.de
Sitz der Gesellschaft: Waldenbuch // Handelsregister: Stuttgart – HRB 739078
Geschäftsführer: Hans-Dieter Brenner // Michael Schuchart // Albrecht Stäbler
----- Original Message -----
From: "Christian Mötzing" <[email protected]>
To: [email protected]
Sent: Tuesday, August 12, 2014 8:40:27 AM
Subject: Options for entity enhancement not working in maven build
Hello OpenJPA mailing list.
I have the following configuration in my persistence.xml:
<persistence-unit name="my.pu">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider
>
<class>com.company.project.entities.Entity</class>
<properties>
<property name="openjpa.DetachState"
value="loaded(DetachedStateField=true)"/>
</properties>
</persistence-unit>
My project can be built with Eclipse using runtime enhancement afterwards
(via OpenJPA agent) to execute some tests. In this case enhancement uses
the option above and does not insert transient fields on enhancement.
I also have a maven build utilizing openjpa-maven-plugin
(<groupId>org.apache.openjpa</groupId><artifactId>openjpa-maven-plugin</ar
tifactId>).
Plugin configuration looks like this:
<executions>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
<configuration>
<includes>**/entities
/*.class</includes>
<addDefaultConstructor>false</addDefaultConstructor>
<skip>${openjpa.enhance.skip}</skip>
<toolProperties>
<property>
<name>openjpa.DetachState</name>
<value>loaded(DetachedStateField=true)</value>
</property>
</toolProperties>
</configuration>
</execution>
</executions>
With or without toolProperties-tag entity enhancement does not use the
option (neither through persistence.xml nor through pom.xml). Can you
please point me to some documentation on how to set this option with
openjpa-maven-plugin?
I am using OpenJPA 2.2.1.
With kind regards
Christian Mötzing
Consultant
NOVATEC // Consulting GmbH
Dieselstrasse 18/1 // D-70771 Leinfelden-Echterdingen
phone:
+49 711 22040-718
fax:
+49 711 22040-899
mobile:
+49 1608806281
e-mail:
<mailto:[email protected]>
[email protected]
web:
<http://www.novatec-gmbh.de/> www.novatec-gmbh.de
Sitz der Gesellschaft: Waldenbuch // Handelsregister: Stuttgart – HRB
739078
Geschäftsführer: Hans-Dieter Brenner // Michael Schuchart // Albrecht
Stäbler