How to write a find or select method in Home interface

I should write a ejbfinder(or select) method which just returns a persistence field in my entity bean ,

I should use EJB QL like

SELECT a.userid FROM AddressEJB AS a WHERE a.city=?1

not ( SELECT OBJECT(a)......)

right?

But How would my ejbfind method look like?

public String findUserIDByCity(String cityname) throws FinderException;

or public LocalAddress findU......?

I am confusing

[439 byte] By [xutoaa] at [2007-10-2 10:43:15]
# 1

According to the spec, the return type of a finder method is either the local (or remote) component interface of the entity bean or a Collection of it. So I think you should use a select method if you want just to return a persistence field. Something like :

public abstract String ejbSelectUserIDByCity(String cityname) throws FinderException;

You can then access this method inside a home business method :

public String ejbHomeUserIDByCity(String city) throws FinderException {

return ejbSelectUserIDByCity(city);

}

> I should use EJB QL like

> SELECT a.userid FROM AddressEJB AS a WHERE a.city=?1

> not ( SELECT OBJECT(a)......)

> right?

I my opinion, you should make litle attention when you write "a.userid", because "userid" shouldn't be a CMP field for the AdressEJB bean but for the UserEJB, instead. Use the container-managed relationship between the AdressEJB and UserEJB entity beans.

manblaizoa at 2007-7-13 2:52:51 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...