Changeset 29
- Timestamp:
- Feb 10, 2011, 10:06:10 PM (14 years ago)
- Location:
- trunk/fmgVen
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/fmgVen/src/com/fmguler/ven/Ven.java
r28 r29 45 45 } 46 46 47 public List list(Class objectClass) {48 return null;49 }50 51 47 public int count() { 52 48 return 0; 53 49 } 54 50 51 /** 52 * Get the object with the specified id, of the specified objectClass type. 53 * <p> 54 * By default none of the associations will be retrieved. 55 * To include the object associations (retrieve the object graph) joins should be specified, e.g. 56 * <code>SomeObject.anotherObject</code> 57 * 58 * @param id the id of the object to be retrieved 59 * @param objectClass the class of the object to be retrieved 60 * @param joins the set of object graphs to be included with the object 61 * @return the retrieved object including specified associations 62 */ 55 63 public Object get(int id, Class objectClass, Set joins) { 56 64 String query = generator.generateSelectQuery(objectClass, joins); … … 65 73 if (result.size() > 1) System.out.println("Ven - WARNING >> get(id) returns more than one row"); 66 74 return result.get(0); 75 } 76 77 /** 78 * List the objects of the specified objectClass type. 79 * <p> 80 * By default none of the associations will be retrieved. 81 * To include the object associations (retrieve the object graph) joins should be specified, e.g. 82 * <code>SomeObject.anotherObject</code> 83 * 84 * @param objectClass the class of the objects to be retrieved 85 * @param joins the set of object graphs to be included with objects 86 * @return the list of objects including specified associations 87 */ 88 public List list(Class objectClass, Set joins) { 89 String query = generator.generateSelectQuery(objectClass, joins); 90 91 Map paramMap = new HashMap(); 92 if (debug) System.out.println("Ven - SQL: " + query); 93 94 List result = mapper.list(query, paramMap, objectClass); 95 return result; 67 96 } 68 97 … … 124 153 //-------------------------------------------------------------------------- 125 154 //SETTERS 155 /** 156 * Set the DataSource to be used to access to the database 157 */ 126 158 public void setDataSource(DataSource dataSource) { 127 159 if (dataSource == null) throw new RuntimeException("fmgVen - DataSource cannot be null"); … … 130 162 } 131 163 164 /** 165 * Add the domain packages that have corresponding database tables. 166 * <p> 167 * The objects in these packages are considered persistable. 168 * @param domainPackage the package of the entity classes. 169 * @return this instance to allow chaining. 170 */ 132 171 public Ven addDomainPackage(String domainPackage) { 133 172 generator.addDomainPackage(domainPackage); -
trunk/fmgVen/test/com/fmguler/ven/sample/Sample.java
r28 r29 24 24 import java.util.Date; 25 25 import java.util.HashSet; 26 import java.util.Iterator; 26 27 import java.util.List; 27 28 import java.util.Set; … … 40 41 //get an object 41 42 testGet(); 43 //list the objects 44 testList(); 42 45 //delete an object 43 46 testDelete(); … … 51 54 */ 52 55 public static void testSave() { 56 System.out.println("******SAVE******"); 53 57 Ven ven = getVen(); 54 58 … … 71 75 */ 72 76 public static void testDelete() { 77 System.out.println("******DELETE******"); 73 78 Ven ven = getVen(); 74 79 ven.delete(2, SomeDomainObject.class); … … 79 84 */ 80 85 public static void testGet() { 86 System.out.println("******GET******"); 81 87 Ven ven = getVen(); 82 88 … … 98 104 */ 99 105 public static void testList() { 106 System.out.println("******LIST******"); 100 107 Ven ven = getVen(); 101 List objList = ven.list(SomeDomainObject.class); 102 System.out.println(objList); 108 109 //list with includes 110 Set joins = new HashSet(); 111 joins.add("SomeDomainObject.anotherDomainObjects"); 112 joins.add("SomeDomainObject.anotherDomainObject"); 113 List objList = ven.list(SomeDomainObject.class, joins); 114 115 Iterator it = objList.iterator(); 116 while (it.hasNext()) { 117 SomeDomainObject someDomainObject = (SomeDomainObject)it.next(); 118 System.out.println(someDomainObject); 119 } 103 120 } 104 121 … … 108 125 public static void testListByCriteria() { 109 126 Ven ven = getVen(); 110 List objList = ven.list(SomeDomainObject.class/*, criteria */);111 System.out.println(objList);127 //List objList = ven.list(SomeDomainObject.class/*, criteria */); 128 //System.out.println(objList); 112 129 } 113 130 -
trunk/fmgVen/test/com/fmguler/ven/sample/domain/AnotherDomainObject.java
r28 r29 102 102 103 103 public String toString() { 104 return id + " " + name + " " + description + " some domain object: {" + someDomainObject + "}";104 return "{" + id + ", " + name + ", " + description + ", some domain object: " + someDomainObject + "}"; 105 105 } 106 106 } -
trunk/fmgVen/test/com/fmguler/ven/sample/domain/SomeDomainObject.java
r28 r29 112 112 113 113 public String toString() { 114 return id + " " + name + " " + description + " another domain object: {" + anotherDomainObject + "} another domain objects:\n" + anotherDomainObjects;114 return "{" + id + ", " + name + ", " + description + ", another domain object: " + anotherDomainObject + ", another domain objects: " + anotherDomainObjects + "} "; 115 115 } 116 116 }
Note: See TracChangeset
for help on using the changeset viewer.