Re: Using JPA orm.xml with Cayenne3M3

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Mar 14 2008 - 11:09:30 EDT

  • Next message: Frank Schwarz: "Re: Using JPA orm.xml with Cayenne3M3"

    To ensure that the agent discovers all classes on startup, pass 'jpa-
    eager-load' parameter to the agent:

        -javaagent:/path/cayenne-agent-3.0M3.jar=jpa-eager-load

    This makes startup slower, but all the entity classes will be
    guaranteed enhanced. This is missing from the docs, let me add it now.

    Andrus

    On Mar 14, 2008, at 4:45 PM, Frank Schwarz wrote:

    > Hi Andrus,
    >
    > the complete trace looks like this:
    >
    > *** CayenneAgent starting...
    > 14.03.2008 10:04:41 org.apache.cayenne.jpa.Provider
    > createEntityManagerFactory
    > INFO: Extra PersistenceUnitInfo properties: {}
    > 14.03.2008 10:04:42
    > org.apache.cayenne.jpa.instrument.InstrumentingUnit addTransformer
    > INFO: *** Adding transformer:
    > org.apache.cayenne.jpa.instrument.UnitClassTransforme..b95e6
    > 14.03.2008 10:04:42 org.apache.cayenne.access.QueryLogger
    > logPoolCreated
    > INFO: Created connection pool: jdbc:h2:tcp://localhost:9092/sample
    > Driver class: org.h2.Driver
    > Min. connections in the pool: 1
    > Max. connections in the pool: 5
    > *** insert ***
    > 14.03.2008 10:04:42 org.apache.cayenne.access.QueryLogger
    > logBeginTransaction
    > INFO: --- transaction started.
    > *** finished ***
    > Exception in thread "main" java.lang.IllegalArgumentException:
    > entity must be Persistent: oopex.cayenne3.jpax.usecases.model.Person
    > at
    > org
    > .apache
    > .cayenne
    > .jpa
    > .TypeCheckingEntityManager
    > .checkEntityType(TypeCheckingEntityManager.java:64)
    > at
    > org
    > .apache
    > .cayenne
    > .jpa
    > .TypeCheckingEntityManager.persist(TypeCheckingEntityManager.java:150)
    > at oopex.cayenne3.jpax.usecases.HalloWorldMain.insert(Unknown
    > Source)
    > at oopex.cayenne3.jpax.usecases.HalloWorldMain.main(Unknown
    > Source)
    > Java Result: 1
    >
    > If you like, I can provide you the sample.
    >
    > Regards,
    > Frank
    >
    > Andrus Adamchik schrieb:
    >> Hi Frank,
    >>
    >> is the application started with cayenne-agent?
    >>
    >> Andrus
    >>
    >> On Mar 14, 2008, at 11:12 AM, Frank Schwarz wrote:
    >>
    >>> Hi,
    >>>
    >>> is it possible to declare mappings in a JPA conform orm.xml file
    >>> with Cayenne3M3. Unfortunately, I have not been successful so far.
    >>>
    >>> ---%<--- META-INF/persistence.xml ----
    >>> <?xml version="1.0" encoding="UTF-8"?>
    >>> <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    >>> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
    >>> " version="1.0">
    >>> <persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
    >>> <provider>org.apache.cayenne.jpa.Provider</provider>
    >>> <mapping-file>META-INF/orm.xml</mapping-file>
    >>> <properties>
    >>> ...
    >>> </properties>
    >>> </persistence-unit>
    >>> </persistence>
    >>>
    >>> ---%<--- META-INF/orm.xml ----
    >>> <?xml version="1.0"?>
    >>> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/
    >>> orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    >>> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd
    >>> " version="1.0">
    >>> <entity class="oopex.cayenne3.jpax.usecases.model.Person"
    >>> name="Person" access="FIELD">
    >>> <table name="PERSON" />
    >>> <attributes>
    >>> <id name="id">
    >>> <generated-value strategy="SEQUENCE" />
    >>> </id>
    >>> </attributes>
    >>> </entity>
    >>> </entity-mappings>
    >>>
    >>> The error message is:
    >>> Exception in thread "main" java.lang.IllegalArgumentException:
    >>> entity must be Persistent: oopex.cayenne3.jpax.usecases.model.Person
    >>> at
    >>> org
    >>> .apache
    >>> .cayenne
    >>> .jpa
    >>> .TypeCheckingEntityManager
    >>> .checkEntityType(TypeCheckingEntityManager.java:64)
    >>> at
    >>> org
    >>> .apache
    >>> .cayenne
    >>> .jpa
    >>> .TypeCheckingEntityManager.persist(TypeCheckingEntityManager.java:
    >>> 150)
    >>> at oopex.cayenne3.jpax.usecases.HalloWorldMain.insert(Unknown
    >>> Source)
    >>> at oopex.cayenne3.jpax.usecases.HalloWorldMain.main(Unknown
    >>> Source)
    >>>
    >>> Kind regards,
    >>> Frank
    >>>
    >>
    >>
    >>
    >
    >



    This archive was generated by hypermail 2.0.0 : Fri Mar 14 2008 - 11:10:04 EDT