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/AuditListTableMapping.java')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMapping.java31
1 files changed, 13 insertions, 18 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMapping.java
index 85b0e3d319..d57dae7eca 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMapping.java
@@ -14,8 +14,8 @@ package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.db.IDBStore;
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.IMappingStrategy;
@@ -23,12 +23,14 @@ import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import java.sql.PreparedStatement;
import java.sql.SQLException;
+import java.util.List;
/**
* This is a list-table mapping for audit mode. It has ID and version columns and no delta support.
@@ -38,8 +40,6 @@ import java.sql.SQLException;
*/
public class AuditListTableMapping extends AbstractListTableMapping
{
- private FieldInfo[] keyFields;
-
private String sqlClear;
public AuditListTableMapping(IMappingStrategy mappingStrategy, EClass eClass, EStructuralFeature feature)
@@ -50,37 +50,31 @@ public class AuditListTableMapping extends AbstractListTableMapping
private void initSQLStrings()
{
+ IDBTable table = getTable();
+
// ----------- clear list -------------------------
StringBuilder builder = new StringBuilder();
builder.append("DELETE FROM "); //$NON-NLS-1$
- builder.append(getTable());
+ builder.append(table);
builder.append(" WHERE "); //$NON-NLS-1$
builder.append(LIST_REVISION_ID);
builder.append("=? AND "); //$NON-NLS-1$
builder.append(LIST_REVISION_VERSION);
- builder.append("=? "); //$NON-NLS-1$
+ builder.append("=?"); //$NON-NLS-1$
sqlClear = builder.toString();
}
@Override
- protected FieldInfo[] getKeyFields()
+ protected void addKeyFields(List<FieldInfo> list)
{
- if (keyFields == null)
- {
- IDBStore store = getMappingStrategy().getStore();
-
- keyFields = new FieldInfo[] {
- new FieldInfo(LIST_REVISION_ID, store.getIDHandler().getDBType(), store.getIDColumnLength()),
- new FieldInfo(LIST_REVISION_VERSION, DBType.INTEGER) };
- }
-
- return keyFields;
+ list.add(new FieldInfo(LIST_REVISION_VERSION, DBType.INTEGER));
}
@Override
protected void setKeyFields(PreparedStatement stmt, CDORevision revision) throws SQLException
{
- getMappingStrategy().getStore().getIDHandler().setCDOID(stmt, 1, revision.getID());
+ IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
+ idHandler.setCDOID(stmt, 1, revision.getID());
stmt.setInt(2, revision.getVersion());
}
@@ -92,13 +86,14 @@ public class AuditListTableMapping extends AbstractListTableMapping
@Override
public void rawDeleted(IDBStoreAccessor accessor, CDOID id, CDOBranch branch, int version)
{
+ IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
IPreparedStatementCache statementCache = accessor.getStatementCache();
PreparedStatement stmt = null;
try
{
stmt = statementCache.getPreparedStatement(sqlClear, ReuseProbability.HIGH);
- getMappingStrategy().getStore().getIDHandler().setCDOID(stmt, 1, id);
+ idHandler.setCDOID(stmt, 1, id);
stmt.setInt(2, version);
DBUtil.update(stmt, false);
}

Back to the top