1 19 20 package org.apache.cayenne.query; 21 22 import java.util.ArrayList ; 23 import java.util.List ; 24 import java.util.Map ; 25 26 import org.apache.cayenne.ObjectId; 27 import org.apache.cayenne.map.DbAttribute; 28 import org.apache.cayenne.map.DbEntity; 29 30 37 public class InsertBatchQuery extends BatchQuery { 38 39 42 protected List objectIds; 43 44 protected List objectSnapshots; 45 protected List dbAttributes; 46 47 50 public InsertBatchQuery(DbEntity entity, int batchCapacity) { 51 super(entity); 52 53 this.objectSnapshots = new ArrayList (batchCapacity); 54 this.objectIds = new ArrayList (batchCapacity); 55 this.dbAttributes = new ArrayList (getDbEntity().getAttributes()); 56 } 57 58 public Object getValue(int dbAttributeIndex) { 59 DbAttribute attribute = (DbAttribute) dbAttributes.get(dbAttributeIndex); 60 Map currentSnapshot = (Map ) objectSnapshots.get(batchIndex); 61 return getValue(currentSnapshot, attribute); 62 } 63 64 67 public void add(Map snapshot) { 68 add(snapshot, null); 69 } 70 71 79 public void add(Map snapshot, ObjectId id) { 80 objectSnapshots.add(snapshot); 81 objectIds.add(id); 82 } 83 84 public int size() { 85 return objectSnapshots.size(); 86 } 87 88 public List getDbAttributes() { 89 return dbAttributes; 90 } 91 92 99 public ObjectId getObjectId() { 100 return (ObjectId) objectIds.get(batchIndex); 101 } 102 } 103 | Popular Tags |