18 package com.mysql.clusterj.core.metadata;
20 import com.mysql.clusterj.core.spi.ValueHandler;
21 import com.mysql.clusterj.ClusterJDatastoreException;
22 import com.mysql.clusterj.ClusterJUserException;
23 import com.mysql.clusterj.ColumnType;
25 import com.mysql.clusterj.annotation.Column;
26 import com.mysql.clusterj.annotation.Lob;
27 import com.mysql.clusterj.annotation.NotPersistent;
28 import com.mysql.clusterj.annotation.NullValue;
29 import com.mysql.clusterj.annotation.Persistent;
31 import com.mysql.clusterj.core.store.Operation;
32 import com.mysql.clusterj.core.store.Table;
34 import java.lang.annotation.Annotation;
36 import java.lang.reflect.Method;
38 import java.math.BigDecimal;
39 import java.math.BigInteger;
84 public int compareTo(Object other) {
101 if (logger.isDebugEnabled()) logger.debug(
"new DomainFieldHandlerImpl: fieldNumber: " + fieldNumber +
"; name:" + name +
"; getMethod: " + getMethod +
"; setMethod: " + setMethod);
107 this.getMethod = getMethod;
109 Annotation[] annotations = setMethod.getAnnotations();
110 if (annotations != null && annotations.length != 0) {
111 for (Annotation a: annotations) {
113 name, a.annotationType().getName()));
117 if (isPersistent()) {
129 if (logger.isDebugEnabled())
130 logger.debug(
"Column name annotation for " + name +
" is "
133 if (logger.isDebugEnabled())
134 logger.debug(
"Column allowsNull annotation for " + name
142 if (logger.isDebugEnabled())
143 logger.debug(
"Column defaultValue annotation for " + name
152 if (logger.isDebugEnabled())
153 logger.debug(
"Column type for " + name +
" is "
156 domainTypeHandler.registerPrimaryKeyColumn(
this,
columnName);
160 if (type.equals(
int.class)) {
162 }
else if (type.equals(
long.class)) {
164 }
else if (type.equals(
String.class)) {
166 }
else if (type.equals(byte[].class)) {
171 local.
message(
"ERR_Primary_Field_Type", domainTypeHandler.getName(),
name, printableName(type)));
175 if (type.equals(byte[].class)) {
177 }
else if (type.equals(
String.class)) {
182 local.
message(
"ERR_Unsupported_Field_Type", printableName(type), name));
184 }
else if (!isPersistent()) {
186 if (type.equals(byte.class)) {
188 }
else if (type.equals(
double.class)) {
190 }
else if (type.equals(
float.class)) {
192 }
else if (type.equals(
int.class)) {
194 }
else if (type.equals(
long.class)) {
196 }
else if (type.equals(
short.class)) {
203 if (type.equals(byte[].class)) {
205 }
else if (type.equals(java.util.Date.class)) {
207 }
else if (type.equals(BigDecimal.class)) {
209 }
else if (type.equals(BigInteger.class)) {
211 }
else if (type.equals(
double.class)) {
213 }
else if (type.equals(
float.class)) {
215 }
else if (type.equals(
int.class)) {
217 }
else if (type.equals(Integer.class)) {
219 }
else if (type.equals(Long.class)) {
221 }
else if (type.equals(Short.class)) {
227 }
else if (type.equals(Float.class)) {
229 }
else if (type.equals(Double.class)) {
231 }
else if (type.equals(
long.class)) {
233 }
else if (type.equals(
short.class)) {
239 }
else if (type.equals(
String.class)) {
241 }
else if (type.equals(Byte.class)) {
243 }
else if (type.equals(byte.class)) {
245 }
else if (type.equals(
boolean.class)) {
247 }
else if (type.equals(Boolean.class)) {
249 }
else if (type.equals(java.sql.Date.class)) {
251 }
else if (type.equals(java.sql.Time.class)) {
253 }
else if (type.equals(java.sql.Timestamp.class)) {
258 local.
message(
"ERR_Unsupported_Field_Type", type.getName()));
266 com.mysql.clusterj.annotation.Index.class);
272 local.
message(
"ERR_Index_Annotation_Columns", domainTypeHandler.getName(),
name));
275 registerIndices(domainTypeHandler);
280 logger.debug(
"Persistent nullValue annotation for " + name +
" is " + nullValue);
284 logger.debug(
"Default null value for " + name +
" is " +
defaultValue);
313 com.mysql.clusterj.core.store.Column
storeColumn) {
314 if (logger.isDebugEnabled()) logger.debug(
"new dynamic DomainFieldHandlerImpl: " +
323 domainTypeHandler.registerPrimaryKeyColumn(
this,
columnName);
328 this.
type = Integer.class;
338 this.
type = Long.class;
344 this.
type = byte[].class;
354 this.
type = Long.class;
358 this.
type = byte[].class;
362 this.
type = Long.class;
366 this.
type = byte[].class;
374 this.
type = java.sql.Date.class;
378 this.
type = java.sql.Timestamp.class;
381 case Decimalunsigned:
383 this.
type = BigDecimal.class;
387 this.
type = Double.class;
391 this.
type = Float.class;
395 this.
type = Integer.class;
399 this.
type = byte[].class;
408 this.
type = Integer.class;
414 case Olddecimalunsigned:
415 error(local.
message(
"ERR_Unsupported_Field_Type",
"Olddecimalunsigned",
name));
416 objectOperationHandlerDelegate = objectOperationHandlerUnsupportedType;
420 this.objectOperationHandlerDelegate = objectOperationHandlerObjectShort;
421 this.
type = Short.class;
424 this.objectOperationHandlerDelegate = objectOperationHandlerStringLob;
428 this.objectOperationHandlerDelegate = objectOperationHandlerJavaSqlTime;
429 this.
type = java.sql.Time.class;
432 this.objectOperationHandlerDelegate = objectOperationHandlerJavaSqlTimestamp;
433 this.
type = java.sql.Timestamp.class;
437 this.objectOperationHandlerDelegate = objectOperationHandlerObjectByte;
438 this.
type = Byte.class;
441 error(local.
message(
"ERR_Unsupported_Field_Type",
"Undefined"));
442 objectOperationHandlerDelegate = objectOperationHandlerUnsupportedType;
445 this.objectOperationHandlerDelegate = objectOperationHandlerObjectInteger;
446 this.
type = Integer.class;
449 this.objectOperationHandlerDelegate = objectOperationHandlerBytes;
450 this.
type = byte[].class;
453 this.objectOperationHandlerDelegate = objectOperationHandlerString;
457 this.objectOperationHandlerDelegate = objectOperationHandlerObjectShortYear;
458 this.
type = Short.class;
461 error(local.
message(
"ERR_Unsupported_Field_Type",
this.storeColumnType));
462 objectOperationHandlerDelegate = objectOperationHandlerUnsupportedType;
466 registerIndices(domainTypeHandler);
470 public boolean isPersistent() {
477 if (logger.isDebugEnabled()) logger.debug(
"Index names for " +
name +
" are " +
indexNames);
478 if (logger.isDebugEnabled()) logger.debug(
"Indices for " +
name +
" are " + printIndices());
482 public void operationSetValue(ValueHandler
handler, Operation op) {
494 }
catch (ClusterJDatastoreException ex) {
520 static NullObjectOperationHandler nullValueEXCEPTION =
new NullObjectOperationHandler() {
524 local.
message(
"ERR_Null_Value_Exception",
525 fmd.domainTypeHandler.getName(), fmd.name));
529 static NullObjectOperationHandler nullValueNONE =
new NullObjectOperationHandler() {