I tried to execute the following query using JBoss declared-sql:
SELECT c.Status, Month(c.firstUsed), COUNT(c.serialNumber) FROM Card c WHERE 
c.status = 4 GROUP BY Month(c.firstUsed)

I have the following in the jbosscmp-jdbc.xml:

           
            <query-method>
               <method-name>ejbSelectCountCardsUsed</method-name>
               <method-params>
               </method-params>
            </query-method>

            <declared-sql>
                < select >
                   <ejb-name><![CDATA[Card]]></ejb-name>
                   <field-name><![CDATA[status]]></field-name>
                   < alias ><![CDATA[c]]>< /alias >
                   <additional-columns><![CDATA[, Month(c.firstUsed), 
COUNT(c.serialNumber)]]></additional-columns>
                < /select >
                < where ><![CDATA[ c.status = 4 GROUP BY Month(c.firstUsed)]]>< 
/where >
            </declared-sql>
         

And I have the following method in the Card Entity Bean:

/**
* @ejb.home-method view-type="local"
*/
public Collection ejbHomeCountCardsUsed() throws FinderException {
      return ejbSelectCountCardsUsed();
}
        
/**
 * @ejb.select query=""
 */
public abstract Collection ejbSelectCountCardsUsed() throws FinderException;

When I read from the Collection returned by ejbHomeCountCardsUsed(), I was only 
be able to get the c.Status value. How can I get the Month(c.firstUsed), 
COUNT(c.serialNumber)?

Or is there any better way to implement this SELECT COUNT...GROUP BY query?

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

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


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to