if (extendsClassMapping != null) {
ds.pairExtends(this, extendsClassMapping.getName());
}
if (clsDesc.hasNature(ClassDescriptorJDONature.class.getName())) {
ClassDescriptorJDONature nature;
nature = new ClassDescriptorJDONature(clsDesc);
_cacheParams = nature.getCacheParams();
_isKeyGenUsed = nature.getKeyGeneratorDescriptor() != null;
}
// construct <tt>FieldMolder</tt>s for each of the identity fields of
// the base class.
FieldMapping[] fmId = ClassMolderHelper.getIdFields(clsMap);
_ids = new FieldMolder[fmId.length];
for (int i = 0; i < _ids.length; i++) {
_ids[i] = new FieldMolder(ds, this, fmId[i]);
}
// construct <tt>FieldModlers</tt>s for each of the non-transient fields
// of the base class
FieldMapping[] fmFields = ClassMolderHelper.getFullFields(clsMap);
int numberOfNonTransientFieldMolders = 0;
for (int i = 0; i < fmFields.length; i++) {
if (!isFieldTransient(fmFields[i])) {
numberOfNonTransientFieldMolders += 1;
}
}
_fhs = new FieldMolder[numberOfNonTransientFieldMolders];
_resolvers = new ResolverStrategy[numberOfNonTransientFieldMolders];
int fieldMolderNumber = 0;
for (int i = 0; i < fmFields.length; i++) {
// don't create field molder for transient fields
if (isFieldTransient(fmFields[i])) {
continue;
}
if ((fmFields[i].getSql() != null) && (fmFields[i].getSql().getManyTable() != null)) {
// the fields is not primitive
String[] relatedIdSQL = null;
int[] relatedIdType = null;
TypeConvertor[] relatedIdConvertTo = null;
TypeConvertor[] relatedIdConvertFrom = null;
String manyTable = fmFields[i].getSql().getManyTable();
String[] idSQL = new String[fmId.length];
int[] idType = new int[fmId.length];
TypeConvertor[] idConvertFrom = new TypeConvertor[fmId.length];
TypeConvertor[] idConvertTo = new TypeConvertor[fmId.length];
FieldDescriptor[] fd = ((ClassDescriptorImpl) clsDesc).getIdentities();
for (int j = 0; j < fmId.length; j++) {
idSQL[j] = fmId[j].getSql().getName()[0];
if (fd[j].hasNature(FieldDescriptorJDONature.class.getName())) {
int[] type = new FieldDescriptorJDONature(fd[j]).getSQLType();
idType[j] = (type == null) ? 0 : type[0];
FieldHandlerImpl fh = (FieldHandlerImpl) fd[j].getHandler();
idConvertTo[j] = fh.getConvertTo();
idConvertFrom[j] = fh.getConvertFrom();
} else {
throw new MappingException(
"Identity type must contains sql information: " + _name);
}
}
ClassDescriptor relDesc = null;
try {
JDOClassDescriptorResolver jdoCDR;
jdoCDR = (JDOClassDescriptorResolver) classDescrResolver;
relDesc = jdoCDR.resolve(fmFields[i].getType());
} catch (ResolverException e) {
throw new MappingException("Problem resolving class descriptor for class "
+ fmFields.getClass(), e);
}
if (relDesc.hasNature(ClassDescriptorJDONature.class.getName())) {
FieldDescriptor[] relatedIds = ((ClassDescriptorImpl) relDesc).getIdentities();
relatedIdSQL = new String[relatedIds.length];
relatedIdType = new int[relatedIds.length];
relatedIdConvertTo = new TypeConvertor[relatedIds.length];
relatedIdConvertFrom = new TypeConvertor[relatedIds.length];
for (int j = 0; j < relatedIdSQL.length; j++) {
if (relatedIds[j].hasNature(FieldDescriptorJDONature.class.getName())) {
FieldDescriptorJDONature nature;
nature = new FieldDescriptorJDONature(relatedIds[j]);
String[] tempId = nature.getSQLName();
relatedIdSQL[j] = (tempId == null) ? null : tempId[0];
int[] tempType = nature.getSQLType();
relatedIdType[j] = (tempType == null) ? 0 : tempType[0];
FieldHandlerImpl fh = (FieldHandlerImpl) relatedIds[j].getHandler();
relatedIdConvertTo[j] = fh.getConvertTo();
relatedIdConvertFrom[j] = fh.getConvertFrom();
} else {