Browse Source

hibernate batch

10.0
daniel 6 years ago
parent
commit
99c5ad25e0
  1. 63
      fine-hibernate/src/com/fr/third/org/hibernate/engine/jdbc/internal/JdbcCoordinatorImpl.java
  2. 2
      fine-hibernate/src/com/fr/third/org/hibernate/engine/jdbc/internal/StatementPreparerImpl.java
  3. 3
      fine-hibernate/src/com/fr/third/org/hibernate/property/access/internal/PropertyAccessFieldImpl.java

63
fine-hibernate/src/com/fr/third/org/hibernate/engine/jdbc/internal/JdbcCoordinatorImpl.java

@ -18,6 +18,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import com.fr.third.org.jboss.logging.Logger; import com.fr.third.org.jboss.logging.Logger;
@ -187,10 +188,14 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
LOG.tracev( "Closing JDBC container [{0}]", this ); LOG.tracev( "Closing JDBC container [{0}]", this );
Connection connection; Connection connection;
try { try {
if ( currentBatch != null ) {
LOG.closingUnreleasedBatch(); LOG.closingUnreleasedBatch();
currentBatch.release(); for(Map.Entry<BatchKey, Batch> e : batchMap.entrySet()){
e.getValue().release();
} }
// if ( currentBatch != null ) {
// LOG.closingUnreleasedBatch();
// currentBatch.release();
// }
cleanup(); cleanup();
} }
finally { finally {
@ -199,35 +204,55 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
return connection; return connection;
} }
private Map<BatchKey, Batch> batchMap = new ConcurrentHashMap<BatchKey, Batch>();
@Override @Override
public Batch getBatch(BatchKey key) { public Batch getBatch(BatchKey key) {
if ( currentBatch != null ) { Batch batch = batchMap.get(key);
if ( currentBatch.getKey().equals( key ) ) { if(batch == null) {
return currentBatch; batch = batchBuilder().buildBatch( key, this );
} batchMap.put(key, batch);
else { }
currentBatch.execute(); return batch;
currentBatch.release();
} //
} // if ( currentBatch != null ) {
currentBatch = batchBuilder().buildBatch( key, this ); // if ( currentBatch.getKey().equals( key ) ) {
return currentBatch; // return currentBatch;
// }
// else {
// currentBatch.execute();
// currentBatch.release();
// }
// }
// currentBatch = batchBuilder().buildBatch( key, this );
// return currentBatch;
} }
@Override @Override
public void executeBatch() { public void executeBatch() {
if ( currentBatch != null ) { for(Map.Entry<BatchKey, Batch> e : batchMap.entrySet()){
currentBatch.execute(); e.getValue().execute();
// needed? e.getValue().release();
currentBatch.release();
} }
// if ( currentBatch != null ) {
// currentBatch.execute();
// // needed?
// currentBatch.release();
// }
} }
@Override @Override
public void abortBatch() { public void abortBatch() {
if ( currentBatch != null ) {
currentBatch.release(); for(Map.Entry<BatchKey, Batch> e : batchMap.entrySet()){
e.getValue().release();
} }
// if ( currentBatch != null ) {
// currentBatch.release();
// }
} }
private transient StatementPreparer statementPreparer; private transient StatementPreparer statementPreparer;

2
fine-hibernate/src/com/fr/third/org/hibernate/engine/jdbc/internal/StatementPreparerImpl.java

@ -74,7 +74,7 @@ class StatementPreparerImpl implements StatementPreparer {
@Override @Override
public PreparedStatement prepareStatement(String sql, final boolean isCallable) { public PreparedStatement prepareStatement(String sql, final boolean isCallable) {
jdbcCoordinator.executeBatch(); //jdbcCoordinator.executeBatch();
return buildPreparedStatementPreparationTemplate( sql, isCallable ).prepareStatement(); return buildPreparedStatementPreparationTemplate( sql, isCallable ).prepareStatement();
} }

3
fine-hibernate/src/com/fr/third/org/hibernate/property/access/internal/PropertyAccessFieldImpl.java

@ -15,6 +15,7 @@ import com.fr.third.org.hibernate.property.access.spi.PropertyAccess;
import com.fr.third.org.hibernate.property.access.spi.PropertyAccessStrategy; import com.fr.third.org.hibernate.property.access.spi.PropertyAccessStrategy;
import com.fr.third.org.hibernate.property.access.spi.Setter; import com.fr.third.org.hibernate.property.access.spi.Setter;
import com.fr.third.org.hibernate.property.access.spi.SetterFieldImpl; import com.fr.third.org.hibernate.property.access.spi.SetterFieldImpl;
import com.fr.third.org.hibernate.property.access.spi.UnsafeGetterFieldImpl;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
@ -32,7 +33,7 @@ public class PropertyAccessFieldImpl implements PropertyAccess {
this.strategy = strategy; this.strategy = strategy;
final Field field = ReflectHelper.findField( containerJavaType, propertyName ); final Field field = ReflectHelper.findField( containerJavaType, propertyName );
this.getter = new GetterFieldImpl( containerJavaType, propertyName, field ); this.getter = new UnsafeGetterFieldImpl( containerJavaType, propertyName, field );
this.setter = new SetterFieldImpl( containerJavaType, propertyName, field ); this.setter = new SetterFieldImpl( containerJavaType, propertyName, field );
} }

Loading…
Cancel
Save