JP, I am using EJB 2.0 in WLS 8.1. Does this apply to the 2.0 spec as well ?
thank u, Flavio. >Hi all, > >I am facing another issue. I have a table mapped to a CMP that has 3 cols as >PK: > >PK = (DATE, UID, IID) > >My final goal is to return all different dates from the table. I tried: > >SELECT DISTINCT o.date FROM MyBean AS o > >The problem is that I can't return a Date from a ejb-ql. i can only return a >bean. So is there a way to return beans with distinct o.date cmp field ? > > I assume you're using an EJB 2.1 container. For you to avail of the objects as Dates (or Strings or Longs, depending on the mapping you've defined for the date field) you must use this query in an ejbSelect<NAME> method (refer to the spec, section 10.6.7). It should look like this: public abstract class MyBean implements EntityBean { .... public abstract java.util.Set ejbSelectFindAllDistinctDates() throws FinderException; .... } If the ejbSelect method returns a java.util.Set, then DISTINCT is assumed to be in the query. If you return a java.util.Collection, then you must include the DISTINCT keyword to obtain the desired results. You may only call the method from within another method of your ejb. You can pair this method with an ejbHome method to expose it to the outside world directly from the Home interface (I assume a LocalHome here): public class LocalHomeMyBean extends EJBLocalHome { public Set getAllDistinctDates() throws GetterException; //Getter encapsulates the FinderException so that there's no confusion } public abstract class MyBean implements EntityBean { .... public abstract java.util.Set ejbSelectFindAllDistinctDates() throws FinderException; .... public Set ejbHomeGetAllDistinctDates() throws GetterException { try { return ejbSelectFindAllDistinctDates(); } catch (FinderException fe) { throw new GetterException(fe); } } HTH, JP =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".