Filtering
Put two instances and apply view criteria for one of them by pressing edit, we see that:
When multiple instances of entity-based view objects in an application module are based on the same underlying entity object, a new row created in one of them can be automatically added (without having to re-query) to the row sets of the others to keep your user interface consistent or simply to consistently reflect new rows in different application pages for a pending transaction.
In-memory filtering with RowMatch
Don't use RowMatch if you have the option to filter the values at database level.
In-memory filtering is much slower than filtering done at the database layer.
Sorting
- setQuery
public void filter(){ setQuery(getQuery()+ " where department_id=1"); executeQuery();System.out.println(getQuery());
} - setWhereClause
- If the view object (VO) has where clause then set where clause will be joined ( anded ) with the actual vo where clause.
- setWhereClause(null) doesn't effect the actual where clause written inside VO xml but affect only the written in VO implementation class.
public void filter(){ System.out.println(getQuery()); setWhereClause("department_id=1"); System.out.println(getQuery()); executeQuery(); System.out.println(getQuery()); }
If actual view object contains where clause department_id= 1,then output after set where clause programmatically is:
select ....... where ( department_Name='Administration' ) and ((( department_id= 1 )))
- View Criteria
- Once we have the view object with the rows populated from the database,we can sort, filter, search with the existing rows in memory without re-querying the database.This will greatly help us to minimize the database round-trip.
ViewCriteria.CRITERIA_MODE_QUERY // Uses database.
ViewCriteria.CRITERIA_MODE_CACHE // Uses rows in memory without querying the database.
- After we change the SQL mode, new setting will take effect the next time we call the executeQuery() method.
public void applyViewCriteriaAtRunTime(){ ViewCriteria vc = createViewCriteria(); //Try this line when commented and then remove commented to see the diffident output //vc.setCriteriaMode(ViewCriteria.CRITERIA_MODE_CACHE); ViewCriteriaRow vcr = vc.createViewCriteriaRow(); vcr.setAttribute("ManagerId", "200"); //ViewCriteriaItem jobItem = vcr ensureCriteriaItem("ChannelId"); //vci.setOperator(JboCompOper.OPER_ON_OR_AFTER); //jobItem.setOperator("="); //jobItem.getValues().get(0).setValue(channelId); vcr.setAttribute("FirstName","LIKE 'R%'"); vc.addRow(vcr);// same as vc.add(vcr); System.out.println(getQuery()); applyViewCriteria(vc); System.out.println(getQuery()); executeQuery(); System.out.println(getQuery()); }
Put two instances and apply view criteria for one of them by pressing edit, we see that:
The applied view criteria effects only the view that we applied the view criteria on it.
- When you choose Database:
New row created in first instance will be added also to second rowset due to the "association consistency".
New row created in 2nd instance will Not be added also to second rowset.
- When you choose In Memory:
New row created in first instance will be added also to second rowset due to the "association consistency"( better naming for this "new row consistency" )Maintaining New Row Consistency in View Objects Based on the Same Entity
New row created in 2nd instance will be added to the 1st if it matches the criteria.
When multiple instances of entity-based view objects in an application module are based on the same underlying entity object, a new row created in one of them can be automatically added (without having to re-query) to the row sets of the others to keep your user interface consistent or simply to consistently reflect new rows in different application pages for a pending transaction.
In-memory filtering with RowMatch
Don't use RowMatch if you have the option to filter the values at database level.
In-memory filtering is much slower than filtering done at the database layer.
Sorting
- setSortBy
http://bpetlur.blogspot.com/2013/11/adf-view-criteria-execution-modes.htmlUsed when you want to sort transient attributes because it is done in memory, If you have table built using a transient ViewObject , a click on the sort icon for a column would call ViewObjectImpl::setSortBy(String sortBy) to perform in memory sorting.public void sortInMemory(){ setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS); setSortBy("ViewObjectAttributeName"); // setOrderByClause("Table_Column_Name") executeQuery(); System.out.println(getQuery()); System.out.println(getWhereClause()); }
No comments:
Post a Comment