[RomaFramework-dev] [ romaframework-Feature Requests-1527489 ] Complex nested QueryByFilter usage
Brought to you by:
lvca
|
From: SourceForge.net <no...@so...> - 2006-07-23 22:23:19
|
Feature Requests item #1527489, was opened at 2006-07-24 00:23 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=824593&aid=1527489&group_id=162641 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: JDO-JPOX-PersistenceAspect Group: None Status: Open Priority: 5 Submitted By: Luca Garulli (lvca) Assigned to: Luca Garulli (lvca) Summary: Complex nested QueryByFilter usage Initial Comment: Let's consider to query for any practices with a debtor with an address in a range of ZIP codes... This is the requirements of a real world application. Avoiding the use of JDOQL directly we can use the QueryByFilter in much more advanced mode: nesting it! ;-) COOOOL In this way you can query inside relationships (1-many, many-to-many) and however inside collections. Something like: @Override public void search() { QueryByFilter dynaFilter = new QueryByFilter(Practice.class); if (getFilter().getEntity().getDebtor() != null) dynaFilter.addItem("debtor", QueryByFilter.FIELD_EQUALS, getFilter().getEntity().getDebtor()); QueryByFilter capFilter = null; if (getFilter().getCapFrom() != null && getFilter().getCapFrom().length() > 0 || getFilter().getCapTo() != null && getFilter().getCapTo().length() > 0) capFilter = new QueryByFilter(Address.class); if (getFilter().getCapFrom() != null && getFilter().getCapFrom().length() > 0) capFilter.addItem("zip", QueryByFilter.FIELD_MAJOR_EQUALS, getFilter().getCapFrom()); if (getFilter().getCapTo() != null && getFilter().getCapTo().length() > 0) capFilter.addItem("zip", QueryByFilter.FIELD_MINOR_EQUALS, getFilter().getCapTo()); if (capFilter != null) dynaFilter.addItem("debtor.addresses", QueryByFilter.FIELD_CONTAINS, capFilter); searchByFilter(dynaFilter); } ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=824593&aid=1527489&group_id=162641 |