We need to use following query in CMP entity bean:

SELECT OBJECT(o) FROM CPRecoverLog o WHERE o.status = ?1 AND o.CPTransactionId 
= ( SELECT MIN(o1.CPTransactionId) FROM CPRecoverLog o1 WHERE o1.status = ?1)

The bean tags are as follows:

 * @ejb.bean description = "CPRecoverLog"
 *                      name = "CPRecoverLog"
 *                      local-jndi-name = "abs.CPRecoverLog"
 *                      type = "CMP"
 *                      view-type = "local"
 *                      primkey-field = "id"
 *                      cmp-version = "2.x" 
 *                                             schema = "CPRecoverLog"
 * 
 * @jboss.persistence table-name = "CPRecoverLog"
 * 
 * @ejb.pk class = "java.lang.Integer"
 * 
 * @jboss.unknown-pk 
 *          column-name = "id"
 *          jdbc-type = "INTEGER"
 *          sql-type = "INTEGER" 
 *          class = "java.lang.Integer" 
 *
 * @jboss.entity-command name = "sybase-fetch-key" 
 *          class = 
"org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCSybaseCreateCommand"
 * @jboss.entity-command-attribute name = "pk-sql"
 *          value = "SELECT @@IDENTITY"
 *
 * @ejb.finder
 *   signature = "Collection findAll()"
 *   query = "SELECT OBJECT(o) FROM CPRecoverLog o WHERE o.id IS NOT NULL"
 *
 * @ejb.finder
 *   signature = "Collection findByStatus(java.lang.String status)"
 *   query = "SELECT OBJECT(o) FROM CPRecoverLog o WHERE o.status = ?1"
 *
 * @ejb.finder
 *       signature = "Collection findByStatusUnique(java.lang.String status)"
 *   query = "SELECT OBJECT(o) FROM CPRecoverLog o WHERE o.status = ?1 AND 
o.CPTransactionId = (SELECT MIN(o1.CPTransactionId) FROM CPRecoverLog o1 WHERE 
o1.status = ?1)"
 *   

When I try to deploy this bean I get a parse exception for the finder - 
findByStatusUnique. 
Is it because EJB-QL does not support nested queries?
I also tried the JBoss-QL. But even after that the problem persisted.
Am I doing something wrong or am I missing something ?
I know there are other ways to do this using ejbFinder methods, but I want to 
use the finders without having to code any JDBC.

Does anybody know how to work with such nested queries in finders/

Regards,
Amit

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

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


-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id=105hix
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to