-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Named Query Lookups fail
PostPosted: Mon Nov 08, 2004 4:18 pm 
Beginner
Beginner

Joined: Mon Sep 08, 2003 10:56 am
Posts: 35
I'm deploying my hibernate beans using the JBoss-hibernate integration code, and so far I have not been able to get named queries to work. These quires worked fine outside of JBoss, but since I migrated to stateless session beans they broke. Everything seems to work fine if I pull the named query into the actuall code that looks it up and use it as a regular query.

Hibernate version: 2.1.5

Mapping documents:

Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class
        name="com.piratefever.hibernate.dbo.Order"
        table="orders"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="orderId"
            column="id"
            type="java.lang.Integer"
            unsaved-value="null"
        >
            <generator class="native">
            </generator>
        </id>

        <timestamp
            name="orderDate"
            column="order_date"
        />

        <property
            name="processed"
            type="java.lang.Boolean"
            update="true"
            insert="true"
            access="property"
            column="processed"
        />

        <property
            name="customerId"
            type="java.lang.Integer"
            update="true"
            insert="true"
            access="property"
            column="customer_id "
        />

        <set
            name="orderItems"
            table="ordered_items"
            lazy="false"
            inverse="false"
            cascade="save-update"
            sort="unsorted"
        >

              <key
                  column="id"
              >
              </key>

              <many-to-many
                  class="com.piratefever.hibernate.dbo.OrderItem"
                  column="ordrid"
                  outer-join="auto"
               />

        </set>

        <property
            name="paymentMethod"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="pmt_method"
        />

        <property
            name="responseMessage"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="response_msg"
        />

        <property
            name="resultCode"
            type="java.lang.Integer"
            update="true"
            insert="true"
            access="property"
            column="result_code"
        />

        <property
            name="vsignReference"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="reference_id"
        />

        <property
            name="hostCode"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="host_code"
        />

        <property
            name="type"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="type"
        />

        <property
            name="tax"
            type="double"
            update="true"
            insert="true"
            access="property"
            column="tax"
        />

        <property
            name="orderIp"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="orderIp"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-Order.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

        <query name="com.piratefever.hibernate.dbo.order.findByDateRange"><![CDATA[
            from com.piratefever.hibernate.dbo.Order as ordr where ordr.processed = :showprocessed and ordr.orderDate > :from and ordr.orderDate < :to
        ]]></query>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Code:
/** @ejb.interface-method
     * @see com.piratefever.core.client.InventoryService#getOrdersInDateRange(java.util.Date, java.util.Date, java.lang.String)
     */
    public Collection getOrdersInDateRange(Date from, Date to, String status)
        throws DataStoreException {
        try {
         Session sess = HibernateContext.getSession(DBO_SESSION);
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         
         Query finder = sess.getNamedQuery("com.piratefever.hibernate.dbo.order.findByDateRange");
         finder.setString("from", sdf.format(from, new StringBuffer(), new FieldPosition(0)).toString());
         finder.setString("to", sdf.format(to, new StringBuffer(), new FieldPosition(0)).toString());
         //REFACTOR (joel) refactor status to a hibernate dependent value object enum thingy.
         finder.setString("showprocessed", status.equals("processed")?"1":"0");
         
         return finder.list();
           
        } catch (HibernateException e) {
            throw new DataStoreException(e.getMessage());
      }
    }


Full stack trace of any exception that occurs:

Code:
14:08:39,500 ERROR [Engine] StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
com.piratefever.core.exceptions.ApplicationFailureException: Named query not known: com.piratefever.hibernate.dbo.order.findByDateRange
   at com.piratefever.core.client.delegate.InventoryDelegate.getOrdersInDateRange(InventoryDelegate.java:63)
   at com.piratefever.crm.accounting.struts.LoadOrderListAction.execute(LoadOrderListAction.java:103)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
   at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:44)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:169)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
   at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
   at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
   at java.lang.Thread.run(Thread.java:595)



Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 7:53 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There is no Hibernate class in your stack trace

_________________
Emmanuel


Top
 Profile  
 
 Post subject: no class
PostPosted: Tue Nov 09, 2004 11:54 am 
Beginner
Beginner

Joined: Mon Sep 08, 2003 10:56 am
Posts: 35
I'm a little confused by your response. Does there need to be a hibernate class in my stack trace? The point of failure here is when the hibernate session tries to lookup the named query that is specified in the hbm.xml file I posted. Were you trying to tell me to post the contents of a specific hibernate class?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 3:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
No. What he is saying is that we need to see the stack trace of the HibernateException, not *your* com.piratefever.core.exceptions.ApplicationFailureException


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.