1 10 11 package com.triactive.jdo.store; 12 13 import com.triactive.jdo.FieldManager; 14 import com.triactive.jdo.PersistenceManager; 15 import java.sql.ResultSet ; 16 17 18 public class PersistentIDROF implements Query.ResultObjectFactory 19 { 20 private final PersistenceManager pm; 21 private final Class candidateClass; 22 private final int[] fieldNumbers; 23 private final ColumnMapping[] fieldMappings; 24 private final int[] columnNumbersByField; 25 private final ColumnMapping idMapping; 26 27 public PersistentIDROF(PersistenceManager pm, Class candidateClass) 28 { 29 this(pm, candidateClass, null, null, null); 30 } 31 32 public PersistentIDROF(PersistenceManager pm, 33 Class candidateClass, 34 int[] fieldNumbers, 35 ColumnMapping[] fieldMappings, 36 int[] columnNumbersByField) 37 { 38 this.pm = pm; 39 this.candidateClass = candidateClass; 40 this.fieldNumbers = fieldNumbers; 41 this.fieldMappings = fieldMappings; 42 this.columnNumbersByField = columnNumbersByField; 43 44 idMapping = (ColumnMapping)pm.getStoreManager().getDatabaseAdapter().getMapping(OID.class); 45 } 46 47 public Object getObject(ResultSet rs) 48 { 49 Object id = idMapping.getObject(pm, rs, 1); 50 51 if (fieldNumbers != null) 52 { 53 FieldManager fm = new ResultSetGetter(pm, rs, fieldMappings, columnNumbersByField); 54 55 return pm.getObjectById(id, candidateClass, fieldNumbers, fm); 56 } 57 else 58 return pm.getObjectById(id, candidateClass, false); 59 } 60 } 61 | Popular Tags |