Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 06c0e02c1036c4a207adc7acd865d8b320c8e402 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/***************************************************************************
 * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Stefan Winkler - initial API and implementation
 **************************************************************************/
package org.eclipse.emf.cdo.server.db;

import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.server.IStoreChunkReader.Chunk;
import org.eclipse.emf.cdo.server.internal.db.jdbc.AbstractJDBCDelegate;

import org.eclipse.net4j.db.IDBConnectionProvider;
import org.eclipse.net4j.util.om.monitor.OMMonitor;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.util.List;

/**
 * Interface for all JDBC related activities regarding revisions.
 * 
 * @author Stefan Winkler
 * @since 2.0
 * @noimplement This interface is not intended to be implemented by clients. Please extend the abstract class
 *              {@link AbstractJDBCDelegate} instead.
 */
public interface IJDBCDelegate
{
  /**
   * Insert a reference row.
   */
  public void insertReference(CDORevision sourceRevision, int index, CDOID targetId, IReferenceMapping referenceMapping);

  /**
   * Delete all reference rows of a cdoid.
   */
  public void deleteReferences(CDOID id, IReferenceMapping referenceMapping);

  /**
   * Insert an attribute row.
   */
  public void insertAttributes(CDORevision revision, IClassMapping classMapping);

  /**
   * Update an attribute row.
   */
  public void updateAttributes(CDORevision revision, IClassMapping classMapping);

  /**
   * Remove an attribute row.
   */
  public void deleteAttributes(CDOID id, IClassMapping classMapping);

  /**
   * Set the revised date of a specific revision's previous version.
   */
  public void updateRevisedForReplace(CDORevision revision, IClassMapping classMapping);

  /**
   * Set the revised date of all unrevised rows of cdoid
   */
  public void updateRevisedForDetach(CDOID id, long revised, IClassMapping classMapping);

  /**
   * Select a revision's attributes
   * 
   * @return <code>true</code> if the revision attributes have been successfully loaded.<br>
   *         <code>false</code> if the revision does not exist in the database.
   */
  public boolean selectRevisionAttributes(CDORevision revision, IClassMapping classMapping, String where);

  /**
   * Select a revision's references (or a part thereof)
   */
  public void selectRevisionReferences(CDORevision revision, IReferenceMapping referenceMapping, int referenceChunk);

  /**
   * Select a revision's reference's chunks
   */
  public void selectRevisionReferenceChunks(IDBStoreChunkReader chunkReader, List<Chunk> chunks,
      IReferenceMapping referenceMapping, String where);

  /**
   * Get the connection object of this JDBC delegate
   */
  public Connection getConnection();

  /**
   * Get the one omnipresent statement object of this JDBC delegate
   */
  public Statement getStatement();

  /**
   * Do any outstanding writes (e.g. execute batches). Called any number of times - but at least once immediately before
   * commit().
   * 
   * @see IStoreAccessor#write(org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext, OMMonitor)
   */
  public void flush(OMMonitor monitor);

  /**
   * Do a commit on the JDBC connection.
   */
  public void commit(OMMonitor monitor);

  /**
   * Do a rollback on the JDBC connection.
   */
  public void rollback();

  /**
   * Get a prepared statement. The caller is responsible of closing it.
   */
  public PreparedStatement getPreparedStatement(String sql);

  /**
   * Set a connection provider to provide the delegate with the DB connection. This may only be called before
   * activation.
   */
  public void setConnectionProvider(IDBConnectionProvider connectionProvider);

  /**
   * Set a flag indicating that this delegate maintains a read-only DB connection. This may only be called before
   * activation.
   */
  public void setReadOnly(boolean reader);
}

Back to the top