Changeset 28 for trunk/fmgVen/src/com/fmguler/ven/Ven.java
- Timestamp:
- Feb 9, 2011, 10:53:45 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/fmgVen/src/com/fmguler/ven/Ven.java
r27 r28 18 18 package com.fmguler.ven; 19 19 20 import com.fmguler.ven.util.Convert; 20 21 import java.util.HashMap; 21 22 import java.util.List; 22 23 import java.util.Map; 24 import java.util.Set; 23 25 import javax.sql.DataSource; 24 26 import org.springframework.beans.BeanWrapper; … … 36 38 private QueryGenerator generator; 37 39 private QueryMapper mapper; 40 private boolean debug = true; 38 41 39 42 public Ven() { … … 50 53 } 51 54 52 public Object get(int id, Class objectClass) { 53 return null; 55 public Object get(int id, Class objectClass, Set joins) { 56 String query = generator.generateSelectQuery(objectClass, joins); 57 query += " where 1=1 and " + Convert.toDB(Convert.toSimpleName(objectClass.getName())) + ".id = :___id "; 58 59 Map paramMap = new HashMap(); 60 paramMap.put("___id", new Integer(id)); 61 if (debug) System.out.println("Ven - SQL: " + query); 62 63 List result = mapper.list(query, paramMap, objectClass); 64 if (result.isEmpty()) return null; 65 if (result.size() > 1) System.out.println("Ven - WARNING >> get(id) returns more than one row"); 66 return result.get(0); 54 67 } 55 68 … … 114 127 if (dataSource == null) throw new RuntimeException("fmgVen - DataSource cannot be null"); 115 128 this.template = new NamedParameterJdbcTemplate(dataSource); 129 mapper.setDataSource(dataSource); 116 130 } 117 131
Note: See TracChangeset
for help on using the changeset viewer.