hi all,
I found a problem when I using findListIteratorByCondition in OFbiz 9.04. got this exception: Service dispatcher threw an exceptionService [serviceTest] target threw an unexpected exception (FieldName orderDate not found for entity: DynamicViewEntity) The field name "orderDate" is defined in entitydef file and these codes work fine in OFbiz 4.0 here is the sample code and entity definition //=============================MoffittOrder=========================== DynamicViewEntity dve = new DynamicViewEntity(); dve.addMemberEntity("MO", "MoffittOrder"); dve.addAlias("MO", "statusId", null, null, null,true, null); dve.addAlias("MO", "orderCount","orderCount", null, null,null,"sum"); dve.addAlias("MO", "gs","gs", null, null,null,"sum"); EntityCondition whereEntityCondition = EntityCondition.makeCondition(UtilMisc.toList( EntityCondition.makeCondition("orderDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate) , EntityCondition.makeCondition("orderDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate) ), EntityOperator.AND); List l = FastList.newInstance(); l.add("statusId"); l.add("orderCount"); l.add("gs"); EntityListIterator eli =delegator.findListIteratorByCondition(dve, whereEntityCondition, null,l,UtilMisc.toList("statusId"), null); List MoffittOrder = FastList.newInstance(); try{ GenericValue one = null; while( (one = eli.next())!=null){ MoffittOrder.add(one); } }finally{ eli.close(); } //====entity def==================== <entity package-name="com.virtualvillage.import.orders" entity-name="MoffittOrder" no-auto-stamp="true"> <field name="orderDate" type="date" col-name="order_date"/> <field name="statusId" type="short-varchar" col-name="status_id"></field> <field name="orderCount" type="numeric" col-name="order_count"></field> <field name="gs" type="floating-point" col-name="gs"/> </entity> Many thanks for any reply~ |
I think you need to add this alias also into dynamicviewEntity.
dve.addAlias("MO", "orderDate", null, null, null,true, null); It is just like a mysql view definition. If you want a field in the view, you will include that field into select variable right. Here also like that only. On Mon, Jul 13, 2009 at 12:40 PM, wudongqing <[hidden email] > wrote: > > hi all, > > I found a problem when I using findListIteratorByCondition in OFbiz 9.04. > > got this exception: > Service dispatcher threw an exceptionService [serviceTest] target threw an > unexpected exception (FieldName orderDate not found for entity: > DynamicViewEntity) > > The field name "orderDate" is defined in entitydef file > and these codes work fine in OFbiz 4.0 > here is the sample code and entity definition > > //=============================MoffittOrder=========================== > DynamicViewEntity dve = new DynamicViewEntity(); > dve.addMemberEntity("MO", "MoffittOrder"); > dve.addAlias("MO", "statusId", null, null, null,true, null); > dve.addAlias("MO", "orderCount","orderCount", null, null,null,"sum"); > dve.addAlias("MO", "gs","gs", null, null,null,"sum"); > > EntityCondition whereEntityCondition = > EntityCondition.makeCondition(UtilMisc.toList( > EntityCondition.makeCondition("orderDate", > EntityOperator.GREATER_THAN_EQUAL_TO, fromDate) > , EntityCondition.makeCondition("orderDate", > EntityOperator.LESS_THAN_EQUAL_TO, thruDate) > ), EntityOperator.AND); > > List l = FastList.newInstance(); > l.add("statusId"); > l.add("orderCount"); > l.add("gs"); > > EntityListIterator eli =delegator.findListIteratorByCondition(dve, > whereEntityCondition, null,l,UtilMisc.toList("statusId"), null); > > List MoffittOrder = FastList.newInstance(); > > try{ > GenericValue one = null; > > while( (one = eli.next())!=null){ > MoffittOrder.add(one); > } > }finally{ > eli.close(); > } > > > //====entity def==================== > > <entity package-name="com.virtualvillage.import.orders" > entity-name="MoffittOrder" no-auto-stamp="true"> > <field name="orderDate" type="date" col-name="order_date"/> > <field name="statusId" type="short-varchar" > col-name="status_id"></field> > <field name="orderCount" type="numeric" > col-name="order_count"></field> > <field name="gs" type="floating-point" col-name="gs"/> > </entity> > > Many thanks for any reply~ > -- > View this message in context: > http://www.nabble.com/problem-with-findListIteratorByCondition-tp24457105p24457105.html > Sent from the OFBiz - User mailing list archive at Nabble.com. > > -- Thanks, Kumaraswamy.N 91-9866805250. |
thanks for your reply, my problem was solved.
|
Free forum by Nabble | Edit this page |