Hi there,
Does anyone know if @NamedQuery is supported in JBoss 4.0.4 RC1?

I defined one as:

@Entity(name="Customer")
@Table(name="CUSTOMERS")
@NamedQuery(name="findAllCustomers", query="SELECT c FROM Customers c")
public class Customer implements Serializable {
    private Long addressId;
    private Long customerId;
    private String firstName;

In stateless session bean I called it like this:

@PersistenceContext(unitName="my-persistence")
protected EntityManager em;

public List findAllCustomers() {
    return em.createNamedQuery("findAllCustomers").getResultList();
}

and at the end when tried to deployed I received this:

2006-02-23 15:47:51,637 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl] 
parse() - HQL: SELECT c FROM Customers c

2006-02-23 15:47:51,637 DEBUG [org.hibernate.hql.ast.AST] --- HQL AST ---

 \-[QUERY] 'query'

    \-[SELECT_FROM] 'SELECT_FROM'

       +-[FROM] 'FROM'

       |  \-[RANGE] 'RANGE'

       |     +-[IDENT] 'Customers'

       |     \-[ALIAS] 'c'

       \-[SELECT] 'SELECT'

          \-[IDENT] 'c'



2006-02-23 15:47:51,637 DEBUG [org.hibernate.hql.ast.ErrorCounter] 
throwQueryException() : no errors

2006-02-23 15:47:51,637 DEBUG [org.hibernate.hql.antlr.HqlSqlBaseWalker] select 
<< begin [level=1, statement=select]

2006-02-23 15:47:51,637 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx 
UCL with url null

2006-02-23 15:47:51,637 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] 
setRepository, [EMAIL PROTECTED], [EMAIL PROTECTED] url=null ,addedOrder=0}

2006-02-23 15:47:51,637 DEBUG [org.hibernate.impl.SessionFactoryImpl] Checking 
0 named SQL queries

2006-02-23 15:47:51,637 ERROR [org.hibernate.impl.SessionFactoryImpl] Error in 
named query: findAllCustomers

org.hibernate.hql.ast.QuerySyntaxException: Customers is not mapped. [SELECT c 
FROM Customers c]

        at 
org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:157)

        at 
org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:86)

        at 
org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)

        at 
org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:263)

        at 
org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3049)

        at 
org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2938)

        at 
org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)

        at 
org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)

        at 
org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)



and in ear file I had persistence.xml with:



   <persistence-unit name="my-persistence">
      <jta-data-source>java:/MyDS</jta-data-source>

      <!-- additional properties - can include hibernate properties here -->

   </persistence-unit>



Can anyone see where the problem is and if @NamedQuery is supported?

Thx!

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3925825#3925825

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3925825


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to