Veer Muchandi [
https://community.jboss.org/people/v_m] created the discussion
"Does JBoss AS7 support runtime annotation processing for Metamodel using
javax.persistence.metamodel.EntityType?"
To view the discussion, visit:
https://community.jboss.org/message/718919#718919
--------------------------------------------------------------
I am trying to use runtime annotation processing by using
javax.persistence.metamodel.EntityType as given in the
http://docs.oracle.com/javaee/6/tutorial/doc/gjiup.html
http://docs.oracle.com/javaee/6/tutorial/doc/gjiup.html
h3. Using Metamodel Classes
Metamodel classes that correspond to entity classes are of the following type:
javax.persistence.metamodel.EntityType<T>
Metamodel classes are typically generated by annotation processors either at development
time or at runtime. Developers of applications that use Criteria queries may generate
static metamodel classes by using the persistence provider’s annotation processor or may
obtain the metamodel class by either calling the getModel method on the query root object
or first obtaining an instance of the Metamodel interface and then passing the entity type
to the instance’s entity method.
The following code snippet shows how to obtain the Pet entity’s metamodel class by calling
Root<T>.getModel:
EntityManager em = ...; CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery cq =
cb.createQuery(Pet.class); Root<Pet> pet = cq.from(Pet.class); EntityType<Pet>
Pet_ = pet.getModel();
The following code snippet shows how to obtain the Pet entity’s metamodel class by first
obtaining a metamodel instance by using EntityManager.getMetamodel and then calling entity
on the metamodel instance:
EntityManager em = ...; Metamodel m = em.getMetamodel(); EntityType<Pet> Pet_ =
m.entity(Pet.class);
When I try to deploy this code into JBoss, there are no errors. But at run time I get the
following errors. name, itemBrand, itemCategory and itemSubCategory below are the
attributes of my entity (like the Pet class above).
org.jboss.resteasy.spi.UnhandledException: java.lang.Error: Unresolved compilation
problems:
name cannot be resolved or is not a field
itemBrand cannot be resolved or is not a field
itemCategory cannot be resolved or is not a field
itemSubCategory cannot be resolved or is not a field
org.jboss.resteasy.core.SynchronousDispatcher.unwrapException(SynchronousDispatcher.java:345)
org.jboss.resteasy.core.SynchronousDispatcher.unwrapException(SynchronousDispatcher.java:341)
org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:321)
org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:214)
org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:190)
org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:534)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)
The jboss documentation does not talk about runtime metamodel generation. See the link
here.
http://docs.jboss.org/hibernate/jpamodelgen/1.0/reference/en-US/html_single/
http://docs.jboss.org/hibernate/jpamodelgen/1.0/reference/en-US/html_single/
Please help
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/718919#718919]
Start a new discussion in JBoss AS 7 Development at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]