[RomaFramework-dev] [ romaframework-Feature Requests-1527489 ] Complex nested QueryByFilter usage
Brought to you by:
lvca
|
From: SourceForge.net <no...@so...> - 2006-07-23 22:25:08
|
Feature Requests item #1527489, was opened at 2006-07-24 00:23 Message generated for change (Comment added) made by lvca 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: Closed 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); } ---------------------------------------------------------------------- >Comment By: Luca Garulli (lvca) Date: 2006-07-24 00:25 Message: Logged In: YES user_id=75115 Implemented using CONTAINS JDOQL operator. Works very well with arbitrary complex clauses SVN revision: 375 ---------------------------------------------------------------------- Comment By: Luca Garulli (lvca) Date: 2006-07-24 00:25 Message: Logged In: YES user_id=75115 Resolved. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=824593&aid=1527489&group_id=162641 |