openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <plins...@gmail.com>
Subject Re: Enhancing a persistent class
Date Wed, 04 Jul 2007 15:12:09 GMT
> In JEE, the application server
> will generally handle the enhancement for you.

Generally-speaking, if you are using OpenJPA from Spring beans in a
Java EE environment, you should get deploy-time auto-enhancement.

Additionally, I wrote an IntelliJ plugin a little while back that
automatically processes your classes after compilation; if you're an
IntelliJ user, this can make things easier.

-Patrick

On 7/4/07, Michael Dick <michael.d.dick@gmail.com> wrote:
> Hi Joshua,
>
> The OpenJPA manual discusses the mechanisms in depth at
> http://openjpa.apache.org/docs/latest/manual/manual.html#ref_guide_pc_enhance.
> In a nutshell :
>
> In order to track the state of an entity class OpenJPA inserts additional
> code into the entity class - which we refer to as enhancement.
>
> Inserting the additional code may be done at compile time (static
> enhancement) or during runtime (dynamic enhancement).
>
> Enhancing your entities at build time can be done by running the main method
> of org.apache.openjpa.enhance.PCEnhancer, or through the PCEnhancer ant
> task.
>
> Using dynamic enhancement in JSE can be done by specifying -javaagent:${path
> to openjpa.jar} when you run the application. In JEE, the application server
> will generally handle the enhancement for you.
>
> Hope this helps,
> -mike
>
>
> On 7/4/07, Joshua Jackson <joshua.java@gmail.com> wrote:
> >
> > Dear all,
> >
> > I received this exception when executing a entitymanager.persist.
> >
> > org.apache.openjpa.persistence.ArgumentException: Attempt to cast
> > instance "com.taxandtech.lab.faces.bean.Department@afa4b0" to
> > PersistenceCapable failed.  Ensure that it has been enhanced.
> >
> > Why does this occur? How do I solve it? This same code works with
> > other persistency provider? What makes it different in OpenJPA?
> >
> > This is my persistence.xml snippets:
> >     <persistence-unit name="openjpaPU">
> >         <provider>org.apache.openjpa.persistence.PersistenceProviderImpl
> > </provider>
> >         <class>com.taxandtech.lab.faces.bean.Department</class>
> >         <properties>
> >                 <property name="openjpa.ConnectionURL"
> > value="jdbc:mysql://localhost:3306/test"/>
> >                 <property name="openjpa.ConnectionDriverName"
> > value="com.mysql.jdbc.Driver"/>
> >                 <property name="openjpa.ConnectionUserName"
> > value="joshua"/>
> >                 <property name="openjpa.ConnectionPassword"
> > value="password"/>
> >                 <property name="openjpa.Log" value="DefaultLevel=INFO,
> > Tool=INFO"/>
> >                 <property name="openjpa.jdbc.SynchronizeMappings"
> > value="buildSchema(ForeignKeys=true)"/>
> >         </properties>
> >     </persistence-unit>
> >
> > Thanks in advance
> >
> > --
> > Let's create a highly maintainable and efficient code
> >
> > YM!: thejavafreak
> > Blog: http://www.nagasakti.or.id/roller/joshua/
> >
>


-- 
Patrick Linskey
202 669 5907

Mime
View raw message