manyManyAnn = f.getAnnotation(ManyToMany.class);
if (manyManyAnn != null)
continue;
}
Property p = new Property();
if (Long.class.isAssignableFrom(f.getType())
|| long.class.isAssignableFrom(f.getType()))
p.setSize("20");
else if (Integer.class.isAssignableFrom(f.getType())
|| int.class.isAssignableFrom(f.getType()))
p.setSize("4");
else if (String.class.isAssignableFrom(f.getType()))
p.setSize("255");
else if (Boolean.class.isAssignableFrom(f.getType())
|| boolean.class.isAssignableFrom(f.getType()))
p.setSize("");
else if (Float.class.isAssignableFrom(f.getType())
|| float.class.isAssignableFrom(f.getType()))
p.setSize("8");
Id idAnn = getter.getAnnotation(Id.class);
if (idAnn == null)
idAnn = f.getAnnotation(Id.class);
if (idAnn != null) {
if (pList != null && hasIdProperty(pList))
continue;
p.setAutoIncrement("1");
p.setPk("1");
p.setSize("20");
}
Column colAnn = getter.getAnnotation(Column.class);
if (colAnn == null) {
colAnn = f.getAnnotation(Column.class);
}
String column = colAnn == null ? "" : colAnn.name();
column = "".equals(column.trim()) ? name : column;
p.setName(name);
p.setColumn(column);
p.setType(f.getType().getName());
p.setNotNull("true");
if (colAnn != null) {
// int size = colAnn.length();
p.setNotNull(String.valueOf(colAnn.nullable()));
p.setUnique(String.valueOf(colAnn.unique()));
}
if (ClassUtil.isPojo(f.getType())) {
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);