I created sample JBOSS Seam project in Eclipse and decided to generate entity code from  existing database. It worked fine, but when I try to run it, it shows me that Hibernade is not able to map entity beans to the corresponding tables. The error message is like this:

org.hibernate.hql.ast.QuerySyntaxException: <your table> is not mapped

I spent around three hours trying to read all available information on it, but most of it just useless – it looks like people don’t know whats happening, so they recommend bizarre tricks. Like, for example, having empry seam.settings file in each folder, meh.

Finally, I found the solution in Seam Jira: https://jira.jboss.org/jira/browse/JBSEAM-3821

They rocemmend to to force Hibernate to use Seam’s EntityManager by changing two files:

1. components.xml


    <persistence:entity-manager-factory name="bookingDatabase" installed="false"/>
    <!-- If Seam loads the persistence unit (JBoss 4.x), the EntityManagerFactory will be resolved from #{bookingDatabase}.
         On JBoss AS 5, the EntityManagerFactory is retrieved from JNDI (the binding occurs during application deployment). -->
    <persistence:managed-persistence-context name="em" auto-create="true"
       entity-manager-factory="#{bookingDatabase}" persistence-unit-jndi-name="java:/bookingEntityManagerFactory"/>

2. persistence.xml


<!-- Binds the EntityManagerFactory to JNDI where Seam can look it up.
              This is only relevant when the container automatically loads the persistence unit, as is the case in JBoss AS 5. -->
         <property name="jboss.entity.manager.factory.jndi.name" value="java:/bookingEntityManagerFactory"/>

Hope that Google will find that page and the proper solution would be much more easily found!