OneToOne oneAnn = getter.getAnnotation(OneToOne.class);
if (oneAnn == null)
oneAnn = f.getAnnotation(OneToOne.class);
if (oneAnn != null) {
JoinColumn joinColumn = getter
.getAnnotation(JoinColumn.class);
if (joinColumn == null)
joinColumn = f.getAnnotation(JoinColumn.class);
if (joinColumn == null) {
p.setColumn(f.getName() + "_id");
} else {
if (joinColumn.name().trim().length() == 0) {
String refCol = joinColumn.referencedColumnName();
if (refCol == null || refCol.trim().length() == 0)
p.setColumn(f.getName() + "_id");
else
p.setColumn(f.getName() + "_" + refCol);
} else
p.setColumn(joinColumn.name());
}
String relProperty = oneAnn.mappedBy();
if (relProperty == null || relProperty.trim().length() == 0)
relProperty = ORMConfigBeanUtil.getIdField(f.getType());
p.setRelProperty(relProperty);
p.setRelClass(f.getType());
p.setType(PropType.ONE_ONE);
p.setSize("20");
}
ManyToOne manyOneAnn = getter.getAnnotation(ManyToOne.class);
if (manyOneAnn == null)
manyOneAnn = f.getAnnotation(ManyToOne.class);
if (manyOneAnn != null) {
ReflectUtil _ru;
try {
_ru = new ReflectUtil(f.getType());
for (Field _f : _ru.getFields()) {
if (!ClassUtil.isListClass(_f))
continue;
String _name = _f.getName();
Method _getter = ru.getGetter(_name);
if (getter == null)
continue;
OneToMany oneManyAnn = _getter
.getAnnotation(OneToMany.class);
if (oneManyAnn == null)
oneManyAnn = f.getAnnotation(OneToMany.class);
if (oneManyAnn == null)
continue;
Class<?> _targetClass = ClassUtil
.getGenericType(_f);
if (!clazz.getName().equals(_targetClass.getName()))
continue;
String relProperty = oneManyAnn.mappedBy();
if (relProperty == null
|| relProperty.trim().length() == 0)
relProperty = ORMConfigBeanUtil.getIdField(_f
.getType());
p.setRelProperty(relProperty);
break;
}
} catch (Exception e) {
}
p.setRelClass(f.getType());
p.setType(PropType.MANY_ONE);
p.setSize("20");
JoinColumn col = getter.getAnnotation(JoinColumn.class);
if (col == null)
col = f.getAnnotation(JoinColumn.class);
if (col == null) {
p.setColumn(f.getName() + "_id");
} else {
if (col.name().trim().length() == 0) {
String refCol = col.referencedColumnName();
if (refCol == null || refCol.trim().length() == 0)
p.setColumn(f.getName() + "_id");
else
p.setColumn(f.getName() + "_" + refCol);
} else
p.setColumn(col.name());
}
}
}
result.add(p);