19 package com.mysql.clusterj.bindings;
21 import com.mysql.cluster.ndbj.NdbApiException;
22 import com.mysql.cluster.ndbj.NdbOperation;
24 import com.mysql.clusterj.ClusterJDatastoreException;
25 import com.mysql.clusterj.core.store.Blob;
26 import com.mysql.clusterj.core.store.Column;
27 import com.mysql.clusterj.core.store.Operation;
28 import com.mysql.clusterj.core.store.ResultData;
30 import com.mysql.clusterj.core.util.I18NHelper;
31 import com.mysql.clusterj.core.util.Logger;
32 import com.mysql.clusterj.core.util.LoggerFactoryService;
34 import java.math.BigDecimal;
38 import java.sql.Timestamp;
43 class OperationImpl
implements Operation {
46 static final I18NHelper local = I18NHelper.getInstance(OperationImpl.class);
49 static final Logger logger = LoggerFactoryService.getFactory()
50 .getInstance(OperationImpl.class);
54 private ClusterTransactionImpl clusterTransaction;
56 public OperationImpl(
NdbOperation operation, ClusterTransactionImpl transaction) {
57 this.ndbOperation = operation;
58 this.clusterTransaction = transaction;
61 public void equalBoolean(Column storeColumn,
boolean booleanValue) {
62 throw new UnsupportedOperationException(local.message(
"ERR_NotImplemented"));
65 public void equalByte(Column storeColumn, byte b) {
67 ndbOperation.equalInt(storeColumn.getName(), (int)b);
68 }
catch (NdbApiException ndbApiException) {
69 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
74 public void equalBytes(Column storeColumn, byte[] value) {
76 ndbOperation.equalBytes(storeColumn.getName(), value);
77 }
catch (NdbApiException ndbApiException) {
78 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
83 public void equalDecimal(Column storeColumn, BigDecimal value) {
85 ndbOperation.equalDecimal(storeColumn.getName(), value);
86 }
catch (NdbApiException ndbApiException) {
87 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
92 public void equalInt(Column storeColumn,
int value) {
94 ndbOperation.equalInt(storeColumn.getName(), value);
95 }
catch (NdbApiException ndbApiException) {
96 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
101 public void equalLong(Column storeColumn,
long value) {
103 ndbOperation.equalLong(storeColumn.getName(), value);
104 }
catch (NdbApiException ndbApiException) {
105 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
110 public void equalString(Column storeColumn,
String value) {
112 ndbOperation.equalString(storeColumn.getName(), value);
113 }
catch (NdbApiException ndbApiException) {
114 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
119 public void equalTimestamp(Column storeColumn, Timestamp value) {
121 ndbOperation.equalTimestamp(storeColumn.getName(), value);
122 }
catch (NdbApiException ndbApiException) {
123 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
128 public void equalDatetime(Column storeColumn, Timestamp value) {
130 ndbOperation.equalDatetime(storeColumn.getName(), value);
131 }
catch (NdbApiException ndbApiException) {
132 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
137 public void equalDate(Column storeColumn, Date value) {
139 Timestamp timestamp =
new Timestamp(((Date)value).getTime());
140 ndbOperation.equalDatetime(storeColumn.getName(), timestamp);
141 }
catch (NdbApiException ndbApiException) {
142 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
147 public void equalTime(Column storeColumn, Time value) {
149 Timestamp timestamp =
new Timestamp(((Time)value).getTime());
150 ndbOperation.equalDatetime(storeColumn.getName(), timestamp);
151 }
catch (NdbApiException ndbApiException) {
152 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
157 public void getBlob(Column storeColumn) {
159 ndbOperation.getBlob(storeColumn.getName());
160 }
catch (NdbApiException ndbApiException) {
161 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
166 public Blob getBlobHandle(Column storeColumn) {
168 return new BlobImpl(ndbOperation.getBlobHandle(storeColumn.getName()));
169 }
catch (NdbApiException ndbApiException) {
170 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
175 public void getValue(Column storeColumn) {
177 ndbOperation.getValue(storeColumn.getName());
178 }
catch (NdbApiException ndbApiException) {
179 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
184 public void postExecuteCallback(Runnable callback) {
185 clusterTransaction.postExecuteCallback(callback);
188 public ResultData resultData() {
190 clusterTransaction.executeNoCommit();
191 return new ResultDataImpl(ndbOperation.resultData());
194 public void setBoolean(Column storeColumn, Boolean value) {
195 throw new UnsupportedOperationException(local.message(
"ERR_NotImplemented"));
198 public void setByte(Column storeColumn, byte value) {
200 ndbOperation.setInt(storeColumn.getName(), (int)value);
201 }
catch (NdbApiException ndbApiException) {
202 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
207 public void setBytes(Column storeColumn, byte[] value) {
209 ndbOperation.setBytes(storeColumn.getName(), value);
210 }
catch (NdbApiException ndbApiException) {
211 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
216 public void setDate(Column storeColumn, Date value) {
218 ndbOperation.setDate(storeColumn.getName(), value);
219 }
catch (NdbApiException ndbApiException) {
220 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
225 public void setDecimal(Column storeColumn, BigDecimal value) {
227 ndbOperation.setDecimal(storeColumn.getName(), value);
228 }
catch (NdbApiException ndbApiException) {
229 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
234 public void setDouble(Column storeColumn, Double value) {
236 ndbOperation.setDouble(storeColumn.getName(), value);
237 }
catch (NdbApiException ndbApiException) {
238 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
243 public void setFloat(Column storeColumn, Float value) {
245 ndbOperation.setFloat(storeColumn.getName(), value);
246 }
catch (NdbApiException ndbApiException) {
247 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
252 public void setInt(Column storeColumn, Integer value) {
254 ndbOperation.setInt(storeColumn.getName(), value);
255 }
catch (NdbApiException ndbApiException) {
256 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
261 public void setLong(Column storeColumn,
long value) {
263 ndbOperation.setLong(storeColumn.getName(), value);
264 }
catch (NdbApiException ndbApiException) {
265 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
270 public void setNull(Column storeColumn) {
272 ndbOperation.setNull(storeColumn.getName());
273 }
catch (NdbApiException ndbApiException) {
274 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
279 public void setShort(Column storeColumn, Short value) {
281 ndbOperation.setShort(storeColumn.getName(), value);
282 }
catch (NdbApiException ndbApiException) {
283 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
288 public void setString(Column storeColumn,
String value) {
290 ndbOperation.setString(storeColumn.getName(), value);
291 }
catch (NdbApiException ndbApiException) {
292 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
297 public void setTime(Column storeColumn, Time value) {
299 ndbOperation.setTime(storeColumn.getName(), value);
300 }
catch (NdbApiException ndbApiException) {
301 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
306 public void setTimestamp(Column storeColumn, Timestamp value) {
308 ndbOperation.setTimestamp(storeColumn.getName(), value);
309 }
catch (NdbApiException ndbApiException) {
310 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),
315 public void setDatetime(Column storeColumn, Timestamp value) {
317 ndbOperation.setDatetime(storeColumn.getName(), value);
318 }
catch (NdbApiException ndbApiException) {
319 throw new ClusterJDatastoreException(local.message(
"ERR_Datastore"),