Changeset 30 for trunk/fmgVen/test
- Timestamp:
- Apr 9, 2011, 12:44:03 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/fmgVen/test/com/fmguler/ven/sample/Sample.java
r29 r30 18 18 package com.fmguler.ven.sample; 19 19 20 import com.fmguler.ven.Criteria; 20 21 import com.fmguler.ven.LiquibaseUtil; 21 22 import com.fmguler.ven.Ven; … … 43 44 //list the objects 44 45 testList(); 46 //list the objects by some criteria string 47 testListByCriteriaString(); 48 //list the objects by some typed criteria 49 testListByCriteriaObject(); 45 50 //delete an object 46 51 testDelete(); … … 112 117 joins.add("SomeDomainObject.anotherDomainObject"); 113 118 List objList = ven.list(SomeDomainObject.class, joins); 114 119 115 120 Iterator it = objList.iterator(); 116 121 while (it.hasNext()) { … … 121 126 122 127 /** 123 * Test list the collection of objects by some criteria 128 * Test list the collection of objects by some criteria (string) 124 129 */ 125 public static void testListByCriteria () {130 public static void testListByCriteriaString() { 126 131 Ven ven = getVen(); 127 //List objList = ven.list(SomeDomainObject.class/*, criteria */); 128 //System.out.println(objList); 132 133 //these objects will be included 134 Set joins = new HashSet(); 135 joins.add("SomeDomainObject.anotherDomainObjects"); 136 joins.add("SomeDomainObject.anotherDomainObject"); 137 138 //the results will be filtered according to this criteria 139 Criteria criteria = new Criteria() //criteria object 140 //.param("and SomeDomainObject.name like :p1").param("p1", "s%") 141 .add("and SomeDomainObject.anotherDomainObjects.name like :p2").param("p2", "a%"); 142 143 144 //list with includes and criteria 145 List objList = ven.list(SomeDomainObject.class, joins, criteria); 146 147 //print the results 148 Iterator it = objList.iterator(); 149 while (it.hasNext()) { 150 SomeDomainObject someDomainObject = (SomeDomainObject)it.next(); 151 System.out.println(someDomainObject); 152 } 153 } 154 155 /** 156 * Test list the collection of objects by some criteria (object) 157 */ 158 public static void testListByCriteriaObject() { 159 Ven ven = getVen(); 160 161 //these objects will be included 162 Set joins = new HashSet(); 163 joins.add("SomeDomainObject.anotherDomainObjects"); 164 joins.add("SomeDomainObject.anotherDomainObject"); 165 166 //the results will be filtered according to this criteria 167 Criteria criteria = new Criteria() //criteria object 168 .like("SomeDomainObject.anotherDomainObjects.name", "a%") //attribute like value 169 .eq("SomeDomainObject.name", "sdo1") //attribute equals value 170 .and(); //connects previous criteria with and 171 172 //list with includes and criteria 173 List objList = ven.list(SomeDomainObject.class, joins, criteria); 174 175 //print the results 176 Iterator it = objList.iterator(); 177 while (it.hasNext()) { 178 SomeDomainObject someDomainObject = (SomeDomainObject)it.next(); 179 System.out.println(someDomainObject); 180 } 129 181 } 130 182
Note: See TracChangeset
for help on using the changeset viewer.