01: package com.xoetrope.service.replication.derby;
02:
03: import net.xoetrope.optional.data.sql.DataConnection;
04: import net.xoetrope.xui.XProject;
05:
06: public class XDerbyReplicationEngine extends
07: com.xoetrope.service.XReplicationEngine {
08:
09: /**
10: * Creates a new instance of XDerbyReplicationEngine
11: */
12: public XDerbyReplicationEngine(XProject project,
13: DataConnection dataConn) {
14: super (project, dataConn);
15: }
16:
17: protected void tagLocalTable(String tableName) {
18: if (!tableName.startsWith("XSYS"))
19: dataConnection
20: .doUpdate("CREATE TRIGGER "
21: + tableName
22: + "_DeleteTrigger AFTER DELETE ON "
23: + tableName
24: + " REFERENCING OLD AS DELETEDROW FOR EACH ROW MODE DB2SQL "
25: + "INSERT INTO xSysLocalDeletions (tableName,pseudoId,deleteDate) VALUES('"
26: + tableName
27: + "', DELETEDROW.pseudoID,CURRENT_TIMESTAMP)");
28: }
29:
30: protected void createTimestampTables() {
31: if (dataConnection
32: .doUpdate("CREATE TABLE XSYSLOCALTIMESTAMPS (tableName VARCHAR(64), lastUpdate TIMESTAMP, maxPseudoID INT)") != Integer.MIN_VALUE) {
33: dataConnection
34: .doUpdate("CREATE TABLE XSYSSERVERTIMESTAMPS (tableName VARCHAR(64), lastUpdate TIMESTAMP, lastDelete TIMESTAMP)");
35: dataConnection
36: .doUpdate("CREATE TABLE XSYSLOCALDELETIONS (tableName VARCHAR(64), pseudoId INT, deleteDate TIMESTAMP)");
37: hasTimeStamps = true;
38: }
39: }
40:
41: }
|