for test classes there is an own test-enhance goal LieGrue, strub
----- Original Message ----- > From: Chris Joysn <joys...@gmail.com> > To: users@openjpa.apache.org; Mark Struberg <strub...@yahoo.de> > Cc: > Sent: Wednesday, August 8, 2012 9:57 PM > Subject: Re: Annotations removed when enhancing? > > nice :) > > thanks for your hints. But i seem unable to apply the plugin cfg to my > setup successfully: > > i added the following cfg, changing the execution phase to > process-test-classes, as the > enhencement is only needed for entities needed in unit tests: > > <plugin> > <groupId>org.codehaus.mojo</groupId> > <artifactId>openjpa-maven-plugin</artifactId> > <version>1.2</version> > <configuration> > <includes>org/activiti/standalone/jpa/*.class</includes> > <addDefaultConstructor>true</addDefaultConstructor> > > <enforcePropertyRestrictions>true</enforcePropertyRestrictions> > > <persistenceXmlFile>src/test/resources/META-INF/persistence.xml</persistenceXmlFile> > </configuration> > <executions> > <execution> > <id>enhancer</id> > <phase>process-test-classes</phase> > <goals> > <goal>enhance</goal> > </goals> > </execution> > </executions> > <dependencies> > <dependency> > <groupId>org.apache.openjpa</groupId> > <artifactId>openjpa</artifactId> > <version>2.0.1</version> > </dependency> > </dependencies> > </plugin> > > the plugin is unable to find the entities listed in the persistence.xml: > > [INFO] --- openjpa-maven-plugin:1.2:enhance (enhancer) @ activiti-engine --- > 38 activiti-jpa-pu INFO [main] openjpa.Tool - No targets were given. > Running on all classes in your persistent classes list, or all metadata > files in classpath directories if you have not listed your persistent > classes. Use -help to display tool usage information. > [INFO] > ------------------------------------------------------------------------ > [INFO] BUILD FAILURE > [INFO] > ------------------------------------------------------------------------ > [INFO] Total time: 3.623s > [INFO] Finished at: Wed Aug 08 21:52:30 CEST 2012 > [INFO] Final Memory: 15M/250M > [INFO] > ------------------------------------------------------------------------ > [ERROR] Failed to execute goal > org.codehaus.mojo:openjpa-maven-plugin:1.2:enhance (enhancer) on project > activiti-engine: Execution enhancer of goal > org.codehaus.mojo:openjpa-maven-plugin:1.2:enhance failed: > java.lang.ClassNotFoundException: > org.activiti.standalone.jpa.IntegerIdJPAEntity -> [Help 1] > > what i am missing for that plugin? > > Thanks > Chris > > On 8 August 2012 20:22, Mark Struberg <strub...@yahoo.de> wrote: > >> yikes, that means you use subclassing. >> >> >> I recommend to use the openjpa-maven-plugin to enhance the classes at >> build time already. >> >> Here is a sample which you can look at >> >> https://github.com/struberg/lightweightEE/blob/master/backend-api/pom.xml >> >> We still need to polish our own documentation, but the parameters are >> almost the same as in the old version which you can find at [1]. >> The openjpa-maven-plugin is not part of OpenJPA itself since 2.2.0. >> >> >> LieGrue, >> strub >> >> [1] http://mojo.codehaus.org/openjpa-maven-plugin/usage.html >> >> >> >> ----- Original Message ----- >> > From: Chris Joysn <joys...@gmail.com> >> > To: users@openjpa.apache.org >> > Cc: >> > Sent: Wednesday, August 8, 2012 7:04 PM >> > Subject: Re: Annotations removed when enhancing? >> > >> > well... i am not so an experienced OpenJPA user but i can provide the >> > following information: >> > >> > before merging the entity to an persistence context the class of the >> entity >> > looks like: >> > >> > org.activiti.standalone.jpa.FieldAccessJPAEntity@4260ab >> > >> > after the merge it looks like: >> > >> > org.apache.openjpa.enhance.org >> > $activiti$standalone$jpa$FieldAccessJPAEntity$pcsubclass@df88d2 >> > >> > when performing an >> > >> > private boolean isEntityAnnotationPresent(Class<?> clazz) { >> > return (clazz.getAnnotation(Entity.class) != null); >> > } >> > >> > the Entity.class annotation is found before the merge, not not after > the >> > merge. >> > >> > And when subclassing is bad, how can i get rid of it? >> > >> > Chris >> > >> > On 8 August 2012 15:55, Kevin Sutter <kwsut...@gmail.com> wrote: >> > >> >> > What way of enhancement do you use in your project? >> >> > If you use subclassing, then the generated subclass is > probably >> > without >> >> annotations. >> >> >> >> And, if you are using subclassing, then quit using subclassing! > :-) >> >> Nobody that is serious about their application should be using >> subclassing >> >> support. I've even been throwing around the idea of removing > the >> >> subclassing support altogether since it can cause more issues > than it >> >> resolves... But, that's a whole separate discussion... >> >> >> >> Kevin >> >> >> >> On Wed, Aug 8, 2012 at 1:13 AM, Mark Struberg > <strub...@yahoo.de> >> > wrote: >> >> >> >> > >> >> > >> >> > Kevin is right. I re-checked it now as well. At least for > build-time >> >> > enhanced entities the annotations remain on the class and > fields. We >> > do >> >> not >> >> > use method annotations, so I cannot check this quickly. >> >> > >> >> > What confused me earlier is that jad (java decompiler) > doesn't >> > seem to >> >> > show annotations in general. But looking at the hex dump of > the class >> >> file >> >> > itself clearly shows that they are there. >> >> > >> >> > What way of enhancement do you use in your project? >> >> > If you use subclassing, then the generated subclass is > probably >> > without >> >> > annotations. >> >> > >> >> > >> >> > LieGrue, >> >> > strub >> >> > >> >> > >> >> > >> >> > ----- Original Message ----- >> >> > > From: Kevin Sutter <kwsut...@gmail.com> >> >> > > To: users@openjpa.apache.org >> >> > > Cc: >> >> > > Sent: Tuesday, August 7, 2012 5:21 PM >> >> > > Subject: Re: Annotations removed when enhancing? >> >> > > >> >> > > I'm curious why you think that the annotations are >> > removed... Even >> >> after >> >> > > enhancement is performed, OpenJPA parses the entity > classes to >> > get the >> >> > ORM >> >> > > data, which is normally specified via annotations. Do > you have >> > an >> >> > example? >> >> > > >> >> > > Kevin >> >> > > >> >> > > On Sun, Aug 5, 2012 at 1:09 PM, Chris Joysn >> > <joys...@gmail.com> wrote: >> >> > > >> >> > >> well.. unfortunately a framework relies on it to > detect JPA >> >> > entities... i >> >> > >> think there is no other way to detect in a > reliable way JPA >> > entities? >> >> > >> >> >> > >> LieGrueZuRue >> >> > >> >> >> > >> >> >> > >> On 5 August 2012 19:52, Mark Struberg >> > <strub...@yahoo.de> wrote: >> >> > >> >> >> > >> > Having code relying on @Entity is bitter so > to say ;) >> >> > >> > >> >> > >> > All JPA functions could also be added via > XML, without >> > having any >> >> > >> > annotation on your entities... >> >> > >> > >> >> > >> > Such code would btw also not work in > Hibernate if you >> > use proxies. >> >> > >> Becasue >> >> > >> > the generated proxies don't have > annotations >> > neither. >> >> > >> > >> >> > >> > LieGrue, >> >> > >> > strub >> >> > >> > >> >> > >> > >> >> > >> > >> >> > >> > ----- Original Message ----- >> >> > >> > > From: Chris Joysn > <joys...@gmail.com> >> >> > >> > > To: users@openjpa.apache.org >> >> > >> > > Cc: >> >> > >> > > Sent: Sunday, August 5, 2012 7:19 PM >> >> > >> > > Subject: Annotations removed when > enhancing? >> >> > >> > > >> >> > >> > > Hello, >> >> > >> > > >> >> > >> > > is it possible that entities do not get > their >> > annotations removed >> >> > > when >> >> > >> > > OpenJPA is performing its enhancements? >> >> > >> > > >> >> > >> > > unfortunately some code relies on the > fact that >> > eg. @Entity is >> >> > > present >> >> > >> on >> >> > >> > > classes, but this annotation gets > removed by >> > OpenJPA. >> >> > >> > > >> >> > >> > > thanks >> >> > >> > > >> >> > >> > >> >> > >> >> >> > > >> >> > >> >> >> > >> >