fix[orm]: The primary key must be named as id, otherwise an error will occur. #issue(108)

This commit is contained in:
godotg
2024-06-05 14:03:25 +08:00
parent 985fa61b2d
commit 5320802bf1
@@ -418,6 +418,10 @@ public class OrmManager implements IOrmManager {
throw new RunException("orm only supports int long float double String");
}
if (!idField.getName().equals("id")) {
throw new RunException("@Id filed must name with id");
}
ReflectionUtils.makeAccessible(idField);
ReflectionUtils.setField(idField, entityInstance, idFiledValue);
var idMethodOptional = Arrays.stream(ReflectionUtils.getAllMethods(clazz)).filter(it -> it.getName().equalsIgnoreCase("id"))