private String makeSQL(T t, String... fields) throws SqlCreateException {
Class<?> clazz = t.getClass();
String table = ORMConfigBeanUtil.getTable(clazz);
StringBuilder condition = new StringBuilder();
ReflectUtil ru = new ReflectUtil(t);
for (int i = 0; i < fields.length; i++) {
if (condition.length() > 0)
condition.append(" AND ");
Method getter = ru.getGetter(fields[i]);
if (getter == null)
continue;
String column = ORMConfigBeanUtil.getColumn(clazz, fields[i]);
condition.append(column + " = ");
Object _value = null;
Object value = null;
try {
_value = getter.invoke(t);
if (_value == null)
continue;
if (ClassUtil.isPojo(_value.getClass())) {
Field f = ru.getField(fields[i]);
OneToOne oneAnn = getter.getAnnotation(OneToOne.class);
if (oneAnn == null)
oneAnn = f.getAnnotation(OneToOne.class);
ManyToOne manyToOneAnn = null;
if (oneAnn == null){
manyToOneAnn = getter.getAnnotation(ManyToOne.class);
if (manyToOneAnn == null)
manyToOneAnn = f.getAnnotation(ManyToOne.class);
}
if (oneAnn != null || manyToOneAnn != null) {
ReflectUtil tarRu = new ReflectUtil(_value);
String tarFKField = ORMConfigBeanUtil.getIdField(_value.getClass());
Method tarFKGetter = tarRu.getGetter(tarFKField);
value = tarFKGetter.invoke(_value);
}
}
if (value == null)