通过反射,金蝶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);

 


版权声明:本文为guosyu原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。