Hello,
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.