Hi Folks,
I’m trying out JPAContainer for the first time and can’t get past this seemingly easy and basic problem:
Caused by: java.lang.IllegalArgumentException: The class is not an entity
at com.vaadin.addon.jpacontainer.metadata.MetadataFactory.getEntityClassMetadata(MetadataFactory.java:84)
at com.vaadin.addon.jpacontainer.provider.LocalEntityProvider.<init>(LocalEntityProvider.java:100)
at com.vaadin.addon.jpacontainer.provider.LocalEntityProvider.<init>(LocalEntityProvider.java:86)
at com.vaadin.addon.jpacontainer.provider.MutableLocalEntityProvider.<init>(MutableLocalEntityProvider.java:68)
at vortex.console.ui.PeopleTable.load(PeopleTable.java:159)
....truncated...
Here is the code triggering the problem:
EntityManager em = RequestHandler.getEntityManager();
MutableLocalEntityProvider<Person> entityProvider =
new MutableLocalEntityProvider<Person>(Person.class, em);
The “new MutableLocalEntityProvider(Person.class, em)” is the matching line for
at vortex.console.ui.PeopleTable.load(PeopleTable.java:159)
The EntityManager (em) is a Hibernate EM.
The Person class is auto-generated by Texo (http://wiki.eclipse.org/Texo) from an ECore model file. Texo takes care of generating JPA Annotations.
Here is the JPAContainer method were the exception occurs:
public <T> EntityClassMetadata<T> getEntityClassMetadata(
Class<T> mappedClass) throws IllegalArgumentException {
assert mappedClass != null : "mappedClass must not be null";
if (mappedClass.getAnnotation(Entity.class) == null) {
throw new IllegalArgumentException("The class is not an entity");
}
PersistentPropertyMetadata.AccessType accessType = determineAccessType(mappedClass);
if (accessType == null) {
throw new IllegalArgumentException(
"The access type could not be determined");
} else {
return (EntityClassMetadata<T>) getClassMetadata(mappedClass,
accessType);
}
}
The mappedClass.getAnnotation(Entity.class) appears to be java.lang.class.getAnnotation(). My guess is that perhaps the Texo generated annotations aren’t recognized by getAnnotation(). Texo generates annotations in an orm.xml (part of the JPA standard) file and does not put the annotations directly into the generated Java code like the Person.java class (attached). Is this a known issue? Is there a way to get the annotations in orm.xml to work with JPAContainer and the getAnnotation() method?
Any suggestions on this exception?
11945.java (10.6 KB)