Table tableAnn = clazz.getAnnotation(Table.class);
String table = tableAnn == null ? "" : tableAnn.name();
table = "".equals(table.trim()) ? clazz.getSimpleName()
.replace("PO", "").replace("POJO", "").replace("Entity", "")
.replace("Model", "") : table;
ORMConfigBean ormBean = new ORMConfigBean();
ormBean.setClazz(clazz.getName());
ormBean.setId(clazz.getSimpleName());
ormBean.setTable(table);
try {
ru = new ReflectUtil(clazz);
} catch (Error e) {
return;
} catch (Exception e) {
return;
}
List<Property> pList = new ArrayList<Property>();
for (Field f : ru.getFields()) {
String name = f.getName();
Method getter = ru.getGetter(name);
if (getter == null)
continue;
Ignore igAnn = f.getAnnotation(Ignore.class);
if (igAnn != null)
continue;
OneToMany manyAnn = getter.getAnnotation(OneToMany.class);
if (manyAnn != null)
continue;
else {
manyAnn = f.getAnnotation(OneToMany.class);
if (manyAnn != null)
continue;
}
ManyToMany mmAnn = getter.getAnnotation(ManyToMany.class);
if (mmAnn != null)
continue;
else {
mmAnn = f.getAnnotation(ManyToMany.class);
if (mmAnn != null)
continue;
}
Property p = new Property();
Id idAnn = getter.getAnnotation(Id.class);
if (idAnn == null)
idAnn = f.getAnnotation(Id.class);
if (idAnn != null) {
p.setAutoIncrement("1");
p.setPk("1");
}
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());
if (ClassUtil.isPojo(f.getType())) {
OneToOne oneAnn = getter.getAnnotation(OneToOne.class);
if (oneAnn == null) {
oneAnn = f.getAnnotation(OneToOne.class);
}
if (oneAnn != null) {
p.setType(PropType.ONE);
p.setColumn(oneAnn.mappedBy());
}
}
pList.add(p);
}
ormBean.setProperty(pList);
ORMConfigBeanCache.add(clazz, ormBean);
}