Debian Codegraph @

src/main/org/h2/command/dml/DataChangeStatement.java

raw
1 /*
2 * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (https://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6 package org.h2.command.dml;
7
8 import org.h2.command.Prepared;
9 import org.h2.engine.SessionLocal;
10 import org.h2.result.ResultInterface;
11 import org.h2.result.ResultTarget;
12 import org.h2.table.DataChangeDeltaTable.ResultOption;
13 import org.h2.table.Table;
14
15 /**
16 * Data change statement.
17 */
18 public abstract class DataChangeStatement extends Prepared {
19
20 private boolean isPrepared;
21
22 /**
23 * Creates new instance of DataChangeStatement.
24 *
25 * @param session
26 * the session
27 */
28 protected DataChangeStatement(SessionLocal session) {
29 super(session);
30 }
31
32 @Override
33 public final void prepare() {
34 if (isPrepared) {
35 return;
36 }
37 doPrepare();
38 isPrepared = true;
39 }
40
41 abstract void doPrepare();
42
43 /**
44 * Return the name of this statement.
45 *
46 * @return the short name of this statement.
47 */
48 public abstract String getStatementName();
49
50 /**
51 * Return the target table.
52 *
53 * @return the target table
54 */
55 public abstract Table getTable();
56
57 @Override
58 public final boolean isTransactional() {
59 return true;
60 }
61
62 @Override
63 public final ResultInterface queryMeta() {
64 return null;
65 }
66
67 @Override
68 public boolean isCacheable() {
69 return true;
70 }
71
72 @Override
73 public final long update() {
74 return update(null, null);
75 }
76
77 /**
78 * Execute the statement with specified delta change collector and collection mode.
79 *
80 * @param deltaChangeCollector
81 * target result
82 * @param deltaChangeCollectionMode
83 * collection mode
84 * @return the update count
85 */
86 public abstract long update(ResultTarget deltaChangeCollector, ResultOption deltaChangeCollectionMode);
87
88 }