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 <[EMAIL PROTECTED]> wrote:

Dear all,

I received this exception when executing a entitymanager.persist.

org.apache.openjpa.persistence.ArgumentException: Attempt to cast
instance "[EMAIL PROTECTED]" 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/

Reply via email to