- This topic has 2 replies, 3 voices, and was last updated 20 years, 8 months ago by
Greg.
-
AuthorPosts
-
Sjoerd A. SchreuderMemberHello,
I would like to count something in the database, but I can’t figure out how to write a correct ejbSelect or ejbFind method for the query.
The query I want to execute is: “select count(d) from Devices d”
(Well, I want to run a more complex query, but I can’t get this simple query to work either)@ejb.finder doesn’t allow the return type of the method to be an int or an Integer. Thus I can’t use a finder.
When I use @ejb.select, everything compiles and looks ok to me (but I’m a newbie to entity beans). When I try to deploy to JBoss, I get:
—
2004-09-21 17:39:21,550 WARN [org.jboss.ejb.EJBDeployer.verifier] EJB spec violation:
Bean : Devices
Method : public abstract Integer ejbSelectCountAll() throws FinderException, RemoteException
Section: 12.2.9
Warning: Each home method must match a method defined in the entity bean class.
—The code in the main bean:
/**
* @ejb.interface-method view-type = “remote”
* @ejb.select query = “select COUNT(d) from Devices d”
*/
public abstract Integer ejbSelectCountAll() throws FinderException;What am I doing wrong?
Versions used: Eclipse 2.1.3, MyEclipse 2.7.101, and jboss 3.2.3.
Thanks in advance!
Sjoerd Schreuder
PS: I could write a finder returning a Collection and ask for its size(), but that’s only a work-around. Besides, I might want to use AVG() or MAX() in the future.
Riyad KallaMemberI think you might be barking up the wrong tree, from your error:
2004-09-21 17:39:21,550 WARN [org.jboss.ejb.EJBDeployer.verifier] EJB spec violation:
Bean : Devices
Method : public abstract Integer ejbSelectCountAll() throws FinderException, RemoteException
Section: 12.2.9
Warning: Each home method must match a method defined in the entity bean class.It looks like your method doesn’t match the correct signature that the EJB spec defines… try adding the “RemoteException” method to your throws method defintion (I see you only have FinderException now) and see what happens. Once you get your method matching the spec I imagine all will be right with the world again.
GregMemberAlso, EJB QL for CMP2.0/J2EE1.3 is very limited when using functional expressions. The functions COUNT(),MAX(),MIN(),SUM(), and UPPER() aren’t implemented in EJB QL for CMP2.0 beans in J2EE 1.3. I haven’t looked at the J2EE 1.4 spec to see if they have implemented that but if you are using J2EE1.3, it sounds like your workaround will be the best idea.
-
AuthorPosts