views:

311

answers:

1

I have setup a project using both Jdo and Jpa. I used Jpa Annotation to Declare my Entity. Then I setup my testCases based on LocalTestHelper (from Google App Engine Documentation). When I run the test, a call to makePersistent of Jdo:PersistenceManager is perfectly OK; a call to persist of Jpa:EntityManager raised an error:

java.lang.IllegalArgumentException: Type ("org.seamoo.persistence.jpa.model.ExampleModel") is not that of an entity but needs to be for this operation
    at org.datanucleus.jpa.EntityManagerImpl.assertEntity(EntityManagerImpl.java:888)
    at org.datanucleus.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:385)
Caused by: org.datanucleus.exceptions.NoPersistenceInformationException: The class "org.seamoo.persistence.jpa.model.ExampleModel" is required to be persistable yet no Meta-Data/Annotations can be found for this class. Please check that the Meta-Data/annotations is defined in a valid file location.
    at org.datanucleus.ObjectManagerImpl.assertClassPersistable(ObjectManagerImpl.java:3894)
    at org.datanucleus.jpa.EntityManagerImpl.assertEntity(EntityManagerImpl.java:884)
    ... 27 more

How can it be the case? Below is the link to the compact source code of the maven projects that reproduce that problem: Updated: http://seamoo.com/jpa-bug-reproduce-compact.tar.gz

Execute the maven test goal over the parent pom you will notice that 3/4 tests from org.seamoo.persistence.jdo.JdoGenericDAOImplTest passed, while all tests from org.seamoo.persistence.jpa.JpaGenericDAOImplTest failed.

+1  A: 

So you either haven't enhanced your model classes, or haven't provided persistence metadata (XML, annotations) for them (at runtime). The log tells you ample information. And I really don't think that presenting people with some tgz with 3 separate projects and expecting them to find the particular class that you're referring to could be called "optimum usage of their time". Cut it down to the actual class, its metadata and a sample Main

DataNucleus
Hi, sorry for any inconvenience. I have updated my source code and remove all code that is out side the scope of the problem. By the way, what I was curious about is that: I used JPA annotation for my entities, but then JDO API works fine with these entities while JPA API does not. As you can see in the source code, the `ExampleModel` was enhanced by the maven datanucleus plugin. Even though, given I missed any of the required data, why JDO works?
Phương Nguyễn
JDO works (with JDO or JPA input), JPA works (with JDO or JPA input). All of those people on GAE/J forum using JPA can't be wrong:-P. The testcase is "cleaned up"? I'd expect one model class and a main, and persistence.xml. That's all it needs.No I can't see anything about what was enhanced; your log tells you that. Enhanced your classes? (for JPA?). When you run, what was in the CLASSPATH? The log (DEBUG level) tells you all of this, so it would kinda make sense to look at it.
DataNucleus