Browse Source

Merge pull request #70 in CORE/base-third from ~DANIEL/base-third:release/10.0 to release/10.0

* commit '99c5ad25e03bf14e877c17b157dfe52d78a32628':
  hibernate batch
10.0
daniel 6 years ago
parent
commit
ce0c353180
  1. 65
      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

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

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

@ -74,7 +74,7 @@ class StatementPreparerImpl implements StatementPreparer {
@Override
public PreparedStatement prepareStatement(String sql, final boolean isCallable) {
jdbcCoordinator.executeBatch();
//jdbcCoordinator.executeBatch();
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.Setter;
import com.fr.third.org.hibernate.property.access.spi.SetterFieldImpl;
import com.fr.third.org.hibernate.property.access.spi.UnsafeGetterFieldImpl;
/**
* @author Steve Ebersole
@ -32,7 +33,7 @@ public class PropertyAccessFieldImpl implements PropertyAccess {
this.strategy = strategy;
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 );
}

Loading…
Cancel
Save