Mantis - Resin
Viewing Issue Advanced Details
95 minor always 04-12-05 00:00 11-30-05 14:43
sam  
 
urgent  
closed 3.0.12  
3.0.12 fixed  
none    
none 3.0.15  
0000095: EJB query with access more than two references deep
RSN-86
(rep by A Barton)

We are porting an application from Resin-ee.2.1.x to Resin-pro-3.0.12. We
have discovered a problem in 3.0.12 that had been working fine in 2.1.x. Our
problem seems to be related to the depth of reference in our queries. Our
entity definition includes the following query:

        <query>
            <query-method>
               <method-name>findAll</method-name>
               <method-params>
               </method-params>
            </query-method>
            <ejb-ql><![CDATA[SELECT o FROM Faq o order by
o.faqCategory.categoryName, o.intOrder]]></ejb-ql>
         </query>

We wrote a simple JSP to exercise the problem finder:

<%
    fooblox.faq.FaqHome home =
(fooblox.faq.FaqHome)barblox.commons.ejb.EJBUtils.getLocalHome("FaqBean");
    home.findAll();
%>

Here is the stacktrace:

java.lang.NullPointerException
    at com.caucho.amber.query.ColumnExpr.generateWhere(ColumnExpr.java:124)
    at
com.caucho.amber.query.AbstractAmberExpr.generateSelect(AbstractAmberExpr.ja
va:121)
    at
com.caucho.amber.query.SelectQuery.generateLoadSQL(SelectQuery.java:437)
    at com.caucho.amber.query.SelectQuery.init(SelectQuery.java:291)
    at com.caucho.amber.query.QueryParser.parseSelect(QueryParser.java:399)
    at com.caucho.amber.query.QueryParser.parse(QueryParser.java:238)
    at
com.caucho.amber.connection.AmberConnectionImpl.parseQuery(AmberConnectionIm
pl.java:922)
    at
com.caucho.amber.connection.AmberConnectionImpl.prepareQuery(AmberConnection
Impl.java:894)
    at
com.caucho.amber.connection.AmberConnectionImpl.prepareQuery(AmberConnection
Impl.java:861)
    at _ejb.FaqBean.FaqBean__EJB$LocalHome.findAll(FaqBean__EJB.java:354)


Here is a code snippet from the resin generated source: FaqBean__EJB.java:
...
        query = trans.getAmberConnection().prepareQuery("SELECT o FROM
Faq o ORDER BY o.faqCategory.categoryName, o.intOrder");
        com.caucho.amber.query.ResultSetImpl rs =
(com.caucho.amber.query.ResultSetImpl) query.executeQuery();
        java.util.ArrayList list = new java.util.ArrayList();
        while (rs.next()) {
          com.caucho.ejb.entity.EntityObject item =
(com.caucho.ejb.entity.EntityObject) rs.getObject(1);
          list.add(item);
        }
       rs.close();
...

If we remove the ?o.faqCategory.categoryName? reference from the order by
clause, this finder will return successfully. Our problem seems to be
related to accessing relationships in queries more than two levels deep. We
are experiencing this same problem with ejbSelect methods as well.

Resin-pro 3.0.12

Notes
(0000099)
ferg   
04-12-05 00:00   
This does not qualify as a "critical" issue.
(0000100)
ferg   
04-12-05 00:00   
ejb/0t00