_fieldDescriptor = fieldDesc;
ClassDescriptor related = fieldDesc.getClassDescriptor();
if (related != null) {
if (!(related.hasNature(ClassDescriptorJDONature.class.getName()))) {
throw new MappingException("Related class is not JDOClassDescriptor");
}
FieldDescriptor[] relids = ((ClassDescriptorImpl) related).getIdentities();
String[] relnames = new String[relids.length];
for (int i = 0; i < relids.length; i++) {
relnames[i] = new FieldDescriptorJDONature(relids[i]).getSQLName()[0];
if (relnames[i] == null) {
throw new MappingException("Related class identities field does "
+ "not contains sql information!");
}
}
FieldDescriptor[] classids = ((ClassDescriptorImpl) clsDesc).getIdentities();
String[] classnames = new String[classids.length];
for (int i = 0; i < classids.length; i++) {
classnames[i] = new FieldDescriptorJDONature(classids[i]).getSQLName()[0];
if (classnames[i] == null) {
throw new MappingException("Related class identities field does "
+ "not contains sql information!");
}
}
String[] names = relnames;
if (!(fieldDesc.hasNature(FieldDescriptorJDONature.class.getName()))) {
_tableName = new ClassDescriptorJDONature(related).getTableName();
_store = false;
_multi = fieldDesc.isMultivalued();
_joined = true;
_joinFields = classnames;
_dirtyCheck = true;
} else {
final FieldDescriptorJDONature jdoFieldNature =
new FieldDescriptorJDONature(fieldDesc);
names = jdoFieldNature.getSQLName();
if ((names != null) && (names.length != relids.length)) {
throw new MappingException("The number of column of foreign keys "
+ "doesn't not match with what specified in manyKey");
}
names = (names != null) ? names : relnames;
String[] joins = jdoFieldNature.getManyKey();
if ((joins != null) && (joins.length != classids.length)) {
throw new MappingException("The number of column of foreign keys "
+ "doesn't not match with what specified in manyKey");
}
if (jdoFieldNature.getManyTable() != null) {
_tableName = jdoFieldNature.getManyTable();
_store = false;
_multi = fieldDesc.isMultivalued();
_joined = true;
_joinFields = (joins != null) ? joins : classnames;
} else if (jdoFieldNature.getSQLName() != null) {
_tableName = classTable;
_store = !ext && !jdoFieldNature.isReadonly();
_multi = false;
_joined = false;
_joinFields = classnames;
} else {
_tableName = new ClassDescriptorJDONature(related).getTableName();
_store = false;
_multi = fieldDesc.isMultivalued();
_joined = true;
_joinFields = (joins != null) ? joins : classnames;
}
_dirtyCheck = jdoFieldNature.isDirtyCheck();
}
_columns = new SQLColumnInfo[relids.length];
for (int i = 0; i < relids.length; i++) {
if (!(relids[i].hasNature(FieldDescriptorJDONature.class.getName()))) {
throw new MappingException("Related class identities field does "
+ "not contains sql information!");
}
FieldDescriptor relId = relids[i];
FieldHandlerImpl fh = (FieldHandlerImpl) relId.getHandler();