logger.debug("Column defaultValue annotation for " + name
+ " is " + columnDefaultValue);
}
storeColumn = table.getColumn(columnName);
if (storeColumn == null) {
throw new ClusterJUserException(local.message("ERR_No_Column",
name, table.getName(), columnName));
}
initializeColumnMetadata(storeColumn);
if (logger.isDebugEnabled())
logger.debug("Column type for " + name + " is "
+ storeColumnType.toString() + "; charset name is "
+ charsetName);
domainTypeHandler.registerPrimaryKeyColumn(this, columnName);
lobAnnotation = getMethod.getAnnotation(Lob.class);
}
if (primaryKey) {
if (type.equals(int.class)) {
objectOperationHandlerDelegate = objectOperationHandlerKeyInt;
} else if (type.equals(long.class)) {
objectOperationHandlerDelegate = objectOperationHandlerKeyLong;
} else if (type.equals(String.class)) {
objectOperationHandlerDelegate = objectOperationHandlerKeyString;
} else if (type.equals(byte[].class)) {
objectOperationHandlerDelegate = objectOperationHandlerKeyBytes;
} else {
objectOperationHandlerDelegate = objectOperationHandlerUnsupportedType;
error(
local.message("ERR_Primary_Field_Type", domainTypeHandler.getName(), name, printableName(type)));
}
} else if (lobAnnotation != null) {
// large object support for byte[]
if (type.equals(byte[].class)) {
objectOperationHandlerDelegate = objectOperationHandlerBytesLob;
} else if (type.equals(String.class)) {
objectOperationHandlerDelegate = objectOperationHandlerStringLob;
} else {
objectOperationHandlerDelegate = objectOperationHandlerUnsupportedType;
error(
local.message("ERR_Unsupported_Field_Type", printableName(type), name));
}
} else if (!isPersistent()) {
// NotPersistent field
if (type.equals(byte.class)) {
objectOperationHandlerDelegate = objectOperationHandlerNotPersistentByte;
} else if (type.equals(double.class)) {
objectOperationHandlerDelegate = objectOperationHandlerNotPersistentDouble;
} else if (type.equals(float.class)) {
objectOperationHandlerDelegate = objectOperationHandlerNotPersistentFloat;
} else if (type.equals(int.class)) {
objectOperationHandlerDelegate = objectOperationHandlerNotPersistentInt;
} else if (type.equals(long.class)) {
objectOperationHandlerDelegate = objectOperationHandlerNotPersistentLong;
} else if (type.equals(short.class)) {
objectOperationHandlerDelegate = objectOperationHandlerNotPersistentShort;
} else {
objectOperationHandlerDelegate = objectOperationHandlerNotPersistentObject;
}
} else {
// not a pk field; use xxxValue to set values
if (type.equals(byte[].class)) {
objectOperationHandlerDelegate = objectOperationHandlerBytes;
} else if (type.equals(java.util.Date.class)) {
objectOperationHandlerDelegate = objectOperationHandlerJavaUtilDate;
} else if (type.equals(BigDecimal.class)) {
objectOperationHandlerDelegate = objectOperationHandlerDecimal;
} else if (type.equals(BigInteger.class)) {
objectOperationHandlerDelegate = objectOperationHandlerBigInteger;
} else if (type.equals(double.class)) {
objectOperationHandlerDelegate = objectOperationHandlerDouble;
} else if (type.equals(float.class)) {
objectOperationHandlerDelegate = objectOperationHandlerFloat;
} else if (type.equals(int.class)) {
objectOperationHandlerDelegate = objectOperationHandlerInt;
} else if (type.equals(Integer.class)) {
objectOperationHandlerDelegate = objectOperationHandlerObjectInteger;
} else if (type.equals(Long.class)) {
objectOperationHandlerDelegate = objectOperationHandlerObjectLong;
} else if (type.equals(Short.class)) {
if (ColumnType.Year.equals(storeColumnType)) {
objectOperationHandlerDelegate = objectOperationHandlerObjectShortYear;
} else {
objectOperationHandlerDelegate = objectOperationHandlerObjectShort;
}
} else if (type.equals(Float.class)) {
objectOperationHandlerDelegate = objectOperationHandlerObjectFloat;
} else if (type.equals(Double.class)) {
objectOperationHandlerDelegate = objectOperationHandlerObjectDouble;
} else if (type.equals(long.class)) {
objectOperationHandlerDelegate = objectOperationHandlerLong;
} else if (type.equals(short.class)) {
if (ColumnType.Year.equals(storeColumnType)) {
objectOperationHandlerDelegate = objectOperationHandlerShortYear;
} else {
objectOperationHandlerDelegate = objectOperationHandlerShort;
}
} else if (type.equals(String.class)) {
objectOperationHandlerDelegate = objectOperationHandlerString;
} else if (type.equals(Byte.class)) {
objectOperationHandlerDelegate = objectOperationHandlerObjectByte;
} else if (type.equals(byte.class)) {
objectOperationHandlerDelegate = objectOperationHandlerByte;
} else if (type.equals(boolean.class)) {
objectOperationHandlerDelegate = objectOperationHandlerBoolean;
} else if (type.equals(Boolean.class)) {
objectOperationHandlerDelegate = objectOperationHandlerObjectBoolean;
} else if (type.equals(java.sql.Date.class)) {
objectOperationHandlerDelegate = objectOperationHandlerJavaSqlDate;
} else if (type.equals(java.sql.Time.class)) {
objectOperationHandlerDelegate = objectOperationHandlerJavaSqlTime;
} else if (type.equals(java.sql.Timestamp.class)) {
objectOperationHandlerDelegate = objectOperationHandlerJavaSqlTimestamp;
} else {
objectOperationHandlerDelegate = objectOperationHandlerUnsupportedType;
error(
local.message("ERR_Unsupported_Field_Type", type.getName()));
}
}
// Handle indexes. One index can be annotated on this field.
// Other indexes including the column mapped to this field
// are annotated on the class.
// TODO: indexes are ignored since they are handled by reading the column metadata
indexAnnotation = getMethod.getAnnotation(
com.mysql.clusterj.annotation.Index.class);
String indexName = null;
if (indexAnnotation != null) {
indexName = indexAnnotation.name();
if (indexAnnotation.columns().length != 0) {
throw new ClusterJUserException(
local.message("ERR_Index_Annotation_Columns", domainTypeHandler.getName(), name));
}
}
registerIndices(domainTypeHandler);