通过反射,金蝶EAS·BOS中根据实体全路径获取实体对象及数据库表名

/*
 * 已知实体路径,如何获取该实体对应的数据库表名?
 * 以下尝试通过反射获取
 */
String entityPath = "com.kingdee.eas.custom.test.app.Test"; //实体路径
//对象路径:com.kingdee.eas.custom.test.TestInfo
String infoPath = entityPath.replace(".app.", ".") + "Info"; //对象路径

//通过反射获取类以及实例:clazz.newInstance()
Class clazz = Class.forName(infoPath);
DataTableInfo table = EntityUtility.getBOSEntity(null, (IObjectValue) clazz.newInstance()).getTable();
String name = table.getName();

//客户端界面弹出消息提示,表名:CT_TST_TEST
MsgBox.showInfo(name);

 

你可能感兴趣的:(通用Java,金蝶BOS,金蝶EAS·BOS,金蝶EAS)