<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Does JBoss AS7 support runtime annotation processing for Metamodel using javax.persistence.metamodel.EntityType?
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/v_m">Veer Muchandi</a> in <i>JBoss AS 7 Development</i> - <a href="https://community.jboss.org/message/718919#718919">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>I am trying to use runtime annotation processing by using  javax.persistence.metamodel.EntityType as given in the <a class="jive-link-external-small" href="http://docs.oracle.com/javaee/6/tutorial/doc/gjiup.html">http://docs.oracle.com/javaee/6/tutorial/doc/gjiup.html</a></p><h3 style="font-size: 15px; color: #000000; margin-top: 3px; font-family: Arial, Helvetica, FreeSans, Luxi-sans, 'Nimbus Sans L', sans-serif; text-align: -webkit-auto;">Using Metamodel Classes</h3><p style="color: #000000; margin-top: 2px; font-family: Arial, Helvetica, FreeSans, Luxi-sans, 'Nimbus Sans L', sans-serif; font-size: 12px; text-align: -webkit-auto;">Metamodel classes that correspond to entity classes are of the following type:</p><pre style="font-family: Monaco, 'Courier New', Courier; color: #000000; font-size: 12px; text-align: -webkit-auto;"><tt style="font-family: Monaco, 'Courier New', Courier;">javax.persistence.metamodel.EntityType<T></tt></pre><p style="color: #000000; font-family: Arial, Helvetica, FreeSans, Luxi-sans, 'Nimbus Sans L', sans-serif; font-size: 12px; text-align: -webkit-auto;">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 <tt style="font-family: Monaco, 'Courier New', Courier;">getModel</tt> method on the query root object or first obtaining an instance of the <tt style="font-family: Monaco, 'Courier New', Courier;">Metamodel</tt> interface and then passing the entity type to the instance’s <tt style="font-family: Monaco, 'Courier New', Courier;">entity</tt> method.</p><p style="color: #000000; font-family: Arial, Helvetica, FreeSans, Luxi-sans, 'Nimbus Sans L', sans-serif; font-size: 12px; text-align: -webkit-auto;">The following code snippet shows how to obtain the <tt style="font-family: Monaco, 'Courier New', Courier;">Pet</tt> entity’s metamodel class by calling <tt style="font-family: Monaco, 'Courier New', Courier;">Root<T>.getModel</tt>:</p><pre style="font-family: Monaco, 'Courier New', Courier; color: #000000; font-size: 12px; text-align: -webkit-auto;">EntityManager em = ...; CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery cq = cb.createQuery(Pet.class); Root<Pet> pet = cq.from(Pet.class); EntityType<Pet> Pet_ = pet.getModel();</pre><p style="color: #000000; font-family: Arial, Helvetica, FreeSans, Luxi-sans, 'Nimbus Sans L', sans-serif; font-size: 12px; text-align: -webkit-auto;">The following code snippet shows how to obtain the <tt style="font-family: Monaco, 'Courier New', Courier;">Pet</tt> entity’s metamodel class by first obtaining a metamodel instance by using <tt style="font-family: Monaco, 'Courier New', Courier;">EntityManager.getMetamodel</tt> and then calling <tt style="font-family: Monaco, 'Courier New', Courier;">entity</tt> on the metamodel instance:</p><pre style="font-family: Monaco, 'Courier New', Courier; color: #000000; font-size: 12px; text-align: -webkit-auto;">EntityManager em = ...; Metamodel m = em.getMetamodel(); EntityType<Pet> Pet_ = m.entity(Pet.class);</pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="color: #ff0000;">org.jboss.resteasy.spi.UnhandledException: java.lang.Error: Unresolved compilation problems: </span></p><p><span style="color: #ff0000;"> name cannot be resolved or is not a field</span></p><p><span style="color: #ff0000;"> itemBrand cannot be resolved or is not a field</span></p><p><span style="color: #ff0000;"> itemCategory cannot be resolved or is not a field</span></p><p><span style="color: #ff0000;"> itemSubCategory cannot be resolved or is not a field</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="color: #ff0000;"> org.jboss.resteasy.core.SynchronousDispatcher.unwrapException(SynchronousDispatcher.java:345)</span></p><p><span style="color: #ff0000;"> org.jboss.resteasy.core.SynchronousDispatcher.unwrapException(SynchronousDispatcher.java:341)</span></p><p><span style="color: #ff0000;"> org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:321)</span></p><p><span style="color: #ff0000;"> org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:214)</span></p><p><span style="color: #ff0000;"> org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:190)</span></p><p><span style="color: #ff0000;"> org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:534)</span></p><p><span style="color: #ff0000;"> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)</span></p><p><span style="color: #ff0000;"> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)</span></p><p><span style="color: #ff0000;"> org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)</span></p><p><span style="color: #ff0000;"> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)</span></p><p><span style="color: #ff0000;"> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)</span></p><p><span style="color: #ff0000;"> javax.servlet.http.HttpServlet.service(HttpServlet.java:847)</span></p><p><span style="color: #ff0000;"> org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The jboss documentation does not talk about runtime metamodel generation. See the link here. <a class="jive-link-external-small" href="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/</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Please help</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/718919#718919">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss AS 7 Development at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>