Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java76
1 files changed, 29 insertions, 47 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java
index d64c2cc547..3c8d537503 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java
@@ -28,14 +28,13 @@ import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.IIDHandler;
-import org.eclipse.emf.cdo.server.db.IPreparedStatementCache;
-import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
import org.eclipse.emf.cdo.server.db.mapping.IListMappingDeltaSupport;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.emf.ecore.EClass;
@@ -215,13 +214,12 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
*/
public void clearList(IDBStoreAccessor accessor, CDOID id)
{
- IPreparedStatementCache statementCache = accessor.getStatementCache();
- PreparedStatement stmt = null;
+ IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
+ PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlClear, ReuseProbability.HIGH);
try
{
- stmt = statementCache.getPreparedStatement(sqlClear, ReuseProbability.HIGH);
- getMappingStrategy().getStore().getIDHandler().setCDOID(stmt, 1, id);
+ idHandler.setCDOID(stmt, 1, id);
DBUtil.update(stmt, false);
}
catch (SQLException e)
@@ -230,7 +228,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
}
finally
{
- statementCache.releasePreparedStatement(stmt);
+ DBUtil.close(stmt);
}
}
@@ -260,21 +258,17 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
private void insertValue(IDBStoreAccessor accessor, CDOID id, int index, Object value, long timestamp)
{
+ FeatureMap.Entry entry = (FeatureMap.Entry)value;
+ EStructuralFeature entryFeature = entry.getEStructuralFeature();
+ CDOID tag = getTagByFeature(entryFeature, timestamp);
+ ITypeMapping typeMapping = getTypeMapping(tag);
+ String columnName = getColumnName(tag);
+
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- IPreparedStatementCache statementCache = accessor.getStatementCache();
- PreparedStatement stmt = null;
+ PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsert, ReuseProbability.HIGH);
try
{
- FeatureMap.Entry entry = (FeatureMap.Entry)value;
- EStructuralFeature entryFeature = entry.getEStructuralFeature();
- CDOID tag = getTagByFeature(entryFeature, timestamp);
- String columnName = getColumnName(tag);
-
- String sql = sqlInsert;
-
- stmt = statementCache.getPreparedStatement(sql, ReuseProbability.HIGH);
-
idHandler.setCDOID(stmt, 1, id);
int column = getKeyFields().length + 1;
@@ -282,7 +276,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
{
if (getColumnNames().get(i).equals(columnName))
{
- getTypeMapping(tag).setValue(stmt, column++, entry.getValue());
+ typeMapping.setValue(stmt, column++, entry.getValue());
}
else
{
@@ -292,7 +286,6 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
stmt.setInt(column++, index);
idHandler.setCDOID(stmt, column++, tag);
-
DBUtil.update(stmt, true);
}
catch (SQLException e)
@@ -301,7 +294,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
}
finally
{
- statementCache.releasePreparedStatement(stmt);
+ DBUtil.close(stmt);
}
}
@@ -346,12 +339,10 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
private void updateOneIndex(IDBStoreAccessor accessor, CDOID id, int oldIndex, int newIndex)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- IPreparedStatementCache statementCache = accessor.getStatementCache();
- PreparedStatement stmt = null;
+ PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
try
{
- stmt = statementCache.getPreparedStatement(sqlUpdateIndex, ReuseProbability.HIGH);
stmt.setInt(1, newIndex);
idHandler.setCDOID(stmt, 2, id);
stmt.setInt(3, oldIndex);
@@ -363,7 +354,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
}
finally
{
- statementCache.releasePreparedStatement(stmt);
+ DBUtil.close(stmt);
}
}
@@ -390,14 +381,11 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
private void move1down(IDBStoreAccessor accessor, CDOID id, int index, int upperIndex)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- IPreparedStatementCache statementCache = accessor.getStatementCache();
- PreparedStatement stmt = null;
+ PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(
+ upperIndex == UNBOUNDED_MOVE ? sqlMoveDown : sqlMoveDownWithLimit, ReuseProbability.HIGH);
try
{
- stmt = statementCache.getPreparedStatement(upperIndex == UNBOUNDED_MOVE ? sqlMoveDown : sqlMoveDownWithLimit,
- ReuseProbability.HIGH);
-
idHandler.setCDOID(stmt, 1, id);
stmt.setInt(2, index);
if (upperIndex != UNBOUNDED_MOVE)
@@ -413,7 +401,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
}
finally
{
- statementCache.releasePreparedStatement(stmt);
+ DBUtil.close(stmt);
}
}
@@ -424,13 +412,11 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
private void move1up(IDBStoreAccessor accessor, CDOID id, int index, int upperIndex)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- IPreparedStatementCache statementCache = accessor.getStatementCache();
- PreparedStatement stmt = null;
+ PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(
+ upperIndex == UNBOUNDED_MOVE ? sqlMoveUp : sqlMoveUpWithLimit, ReuseProbability.HIGH);
try
{
- stmt = statementCache.getPreparedStatement(upperIndex == UNBOUNDED_MOVE ? sqlMoveUp : sqlMoveUpWithLimit,
- ReuseProbability.HIGH);
idHandler.setCDOID(stmt, 1, id);
stmt.setInt(2, index);
if (upperIndex != UNBOUNDED_MOVE)
@@ -446,19 +432,17 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
}
finally
{
- statementCache.releasePreparedStatement(stmt);
+ DBUtil.close(stmt);
}
}
private void deleteItem(IDBStoreAccessor accessor, CDOID id, int index)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- IPreparedStatementCache statementCache = accessor.getStatementCache();
- PreparedStatement stmt = null;
+ PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlDeleteItem, ReuseProbability.HIGH);
try
{
- stmt = statementCache.getPreparedStatement(sqlDeleteItem, ReuseProbability.HIGH);
idHandler.setCDOID(stmt, 1, id);
stmt.setInt(2, index);
DBUtil.update(stmt, true);
@@ -469,7 +453,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
}
finally
{
- statementCache.releasePreparedStatement(stmt);
+ DBUtil.close(stmt);
}
}
@@ -487,19 +471,17 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
*/
public void setListItem(IDBStoreAccessor accessor, CDOID id, int index, Object value, long timestamp)
{
- IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- IPreparedStatementCache statementCache = accessor.getStatementCache();
- PreparedStatement stmt = null;
-
FeatureMap.Entry entry = (FeatureMap.Entry)value;
EStructuralFeature entryFeature = entry.getEStructuralFeature();
CDOID tag = getTagByFeature(entryFeature, timestamp);
- String columnName = getColumnName(tag);
ITypeMapping mapping = getTypeMapping(tag);
+ String columnName = getColumnName(tag);
+
+ IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
+ PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlUpdateValue, ReuseProbability.HIGH);
try
{
- stmt = statementCache.getPreparedStatement(sqlUpdateValue, ReuseProbability.HIGH);
idHandler.setCDOID(stmt, 1, tag);
int column = 2;
@@ -525,7 +507,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
}
finally
{
- statementCache.releasePreparedStatement(stmt);
+ DBUtil.close(stmt);
}
}

Back to the top