Le 15/04/2010 08:51, Anurag Walia a écrit :
>
> Hi
>
> i have an entity like
> <entity entity-name="EmplLeave"
> package-name="org.ofbiz.humanres.employment" title="Employee Leave
> Entity">
> <field name="partyId" type="id-ne"/>
> <field name="fromDate" type="date-time"/>
> <field name="thruDate" type="date-time"/>
> <prim-key field="partyId"/>
> <prim-key field="fromDate"/>
> </entity>
>
> i want a sql query like this by delegator
> SELECT * from empl_leave where party_Id=10411 and month(from_date)='4' and
> year(from_date)='2010' ;(this is runnig on console)
> but when i am trying this in java service
> GenericValue emplLeave=(GenericValue)delegator.findByAndCache("EmplLeave",
> UtilMisc.toMap("month(fromDate)", submitmonth,"year(fromDate)",submityear),
> null);
> (then exception is coming on server java.lang.ClassCastException:
> javolution.util.FastList)
> so please help me how to use sql methods in delegator.
>
> Thanks in advance
>
> Regards
> Anurag Walia
>
findByAndCache will send you a list, and not a GV. So you may use a
list, and then use getFirst to have the first element of your list.
HTH,
--
Erwan de FERRIERES
www.nereide.biz