1 21 22 package org.opensubsystems.core.persist.db; 23 24 import java.sql.Connection ; 25 import java.sql.PreparedStatement ; 26 import java.sql.SQLException ; 27 import java.util.Collection ; 28 import java.util.Iterator ; 29 30 import org.opensubsystems.core.data.DataObject; 31 import org.opensubsystems.core.error.OSSException; 32 33 57 public class DatabaseUpdateMultipleDataObjectsOperation extends DatabaseUpdateOperation 58 { 59 61 69 public DatabaseUpdateMultipleDataObjectsOperation( 70 DatabaseFactoryImpl factory, 71 String query, 72 ModifiableDatabaseSchema schema, 73 Collection colDataObject 74 ) 75 { 76 super(factory, query, schema, DatabaseUpdateOperation.DBOP_UPDATE, colDataObject); 77 } 78 79 81 84 protected void performOperation( 85 DatabaseFactoryImpl dbfactory, 86 Connection cntConnection, 87 PreparedStatement pstmQuery 88 ) throws OSSException, 89 SQLException  90 { 91 int[] arrUpdatedReturn; 92 int iBatchedCount = 0; 93 Iterator items; 94 DataObject data = null; 95 int size; 96 int iTotalUpdatedReturn = 0; 97 98 size = ((Collection )m_data).size(); 99 for (items = ((Collection )m_data).iterator(); items.hasNext();) 100 { 101 data = (DataObject)items.next(); 102 prepareData(data); 104 setValuesForUpdate(pstmQuery, data, 1); 106 pstmQuery.addBatch(); 107 iBatchedCount++; 108 109 if (((iBatchedCount % Database.BATCH_ITERATOR) == 0) 111 || (iBatchedCount == size)) 112 { 113 arrUpdatedReturn = pstmQuery.executeBatch(); 114 iTotalUpdatedReturn += arrUpdatedReturn.length; 115 } 116 } 117 setReturnData(new Integer (iTotalUpdatedReturn)); 120 } 121 } 122
| Popular Tags
|