openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rolf Schumacher <mailingl...@august.de>
Subject Re: has not been enhanced
Date Wed, 25 Mar 2009 17:23:21 GMT
Thank you, Kevin

took only a quarter to understand (if I did). I like short explanations.

Let me repeat:

- enhanced classes provide services to openjpa classes at runtime
- therefore enhancement is needed for an openjpa project to run
  (it's recommended to avoid "sub-classing" (what's that??))
- it's recommended to use -javaagent:....PCEnhancerTask
  (that is executed in the same context and prior to the main class)
  with the executing jvm, in order to enhance the classes at load-time

I experimented a bit with Ricks explanation and found my error. Thank you.

Obviously (I'm far from sure about it) the openjpa maven plugin or the
openjpa environment takes care about enhancement or sub-classing. My
error was caused different:

In my data model I have two multi-key tables.
They need an extra class in order to represent the primary key.
The openjpa maven plugin or netbeans (I don't know either) automatically
extends the persistence.xml with the class name, but not with the
classname of the primary keys.
I use the details of the key of only one of them.
Therefore I had to manually extend the persistence.xml by the class name
of that primary key (TimesheetCommentPK in my case).

I can omit the other primary key class name from persistence.xml as long
as I do not need details of that multi-field key.

Now my tests are running as expected. Maybe with sub-classing - how to
check? Or does the maven plug-in take care of enhancements?

==================

What do you think about this solution to testing with enhancement
omitting sub-classing?:

Put "new PCEnhancerTask();" as the first statement in setUpClass of
Junit test?

And for running an application:

Put "new PCEnhancerTask();" as the first statement in main(String[] args)?

Rolf

Kevin Sutter wrote:
> Rolf,
> Your "build" is also executing a main called App, which calls Bill.  So, the
> enhancement processing that is being requested is due to the OpenJPA
> runtime, not the normal compile, build, and packaging phase.
>
> For optimum performance, OpenJPA uses byte-code weaving, or enhancement, on
> the Entity classes.  This process inserts some specific byte-codes into the
> Entity classes which help OpenJPA with processing of the Persistence
> Contexts and the associated Entities.
>
> The first message in your log indicates that you are not performing the
> enhancement process.  Without this enhancement process, we fall back to an
> Entity sub-classing approach.  Not only does this approach not perform very
> well, there are several known issues with this sub-classing.  The main idea
> of sub-classing was to provide an initial, easy out-of-box experience for
> OpenJPA users.  Unfortunately, due to some of the limitations of this
> approach, our users almost immediately hit a roadblock.
>
> Rick has provided a good write-up on Enhancement on our Persistence blog:
> http://webspherepersistence.blogspot.com/2009/02/openjpa-enhancement.html
>
> Hopefully this will give a bit more background.  Take a read through this
> and then post back when you have more questions.  Thanks for your interest
> in OpenJPA!
>
> Kevin
>
> On Wed, Mar 25, 2009 at 3:41 AM, Rolf Schumacher <mailinglist@august.de>wrote:
>
>   
>> thank you for your answer, Rick
>>
>> you'll find the persistence.xml here: http://apache.pastebin.com/m4a91654f
>> the highlighted class is that one that netbeans has introduced when it
>> generated it from the table TIMESHEET_COMMENT in the database eHour.
>>
>> you'll find the Java stack dump here: http://apache.pastebin.com/m7641c82f
>> it happens when I try to build the maven project with netbeans build
>>
>> you'll find the pom.xml here: http://apache.pastebin.com/m6f437735
>>
>> I mentioned running openjpa:enhance
>> the Java stackdump you can find here: http://apache.pastebin.com/m2da3ff7d
>>
>>
>>
>> Rick Curtis wrote:
>>     
>>> Can we get some more info? Your persistence.xml file along with the
>>>       
>> actual error message would be a good start.
>>     
>>> -Rick
>>>
>>>
>>> I'm working successfully on my first jpa project,
>>> using netbeans, maven and openjpa.
>>>
>>> Now I added another entity class by applying the generator from the pull
>>> down menu of a package "New/Entity Classes from Database ..."
>>>
>>> It generated two entity classes because the key has multiple colums:
>>> Entity and EntityPK.
>>>
>>> When I built the project again I get the error:
>>>
>>> "The type "class EntityPK" has not been enhanced."
>>>
>>> And the build stops.
>>>
>>> I looked in the documentation for "enhancement" and found it to be an
>>> important subject but was not able to understand why a class shall be
>>> enhanced in order for the project to get built.
>>>
>>> Before I added this entity to the other 5 - one with a primary key class
>>> as well - I didn't had this problem and everything worked smooth. Now I
>>> got stuck.
>>>
>>> What shall I look into to overcome this problem?
>>>
>>> Rolf
>>>
>>> p.s. When I ran the maven goal openjpa:enhance an exception occurs while
>>> parsing a non-entity class, telling me that a class can not be found
>>> that I provide at runtime. Honestly, I do not know what I was doing here.
>>>
>>>
>>>
>>>
>>>
>>>       
>
>   

Mime
View raw message