获取在SessionFactory中设置的所有表名 [英] Get all table names set up in SessionFactory
本文介绍了获取在SessionFactory中设置的所有表名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有办法检索由 SessionFactory
管理的所有表的名称?例如,所有通过 AnnotationConfiguration.addAnnotatedClass(...))添加的表
?
Is there a way to retrieve the name of all tables that are managed by the SessionFactory
? For instance, all the tables that were added via AnnotationConfiguration.addAnnotatedClass(...))
?
推荐答案
下面是如何获取一个tableName与 getClassMetadata
Here is howto getting one tableName with getClassMetadata
ClassMetadata cm = sessionFactory.GetClassMetadata(className);
AbstractEntityPersister aep = (AbstractEntityPersister) cm;
String tableName = aep.getTableName();
:您可以通过调用 getAllClassMetadata()
并查找所有表名称
: you can find all by calling getAllClassMetadata()
and find all table names like that
Map m = sessionFactory.GetAllClassMetadata();
/* iterate map*/
AbstractEntityPersister aep = m.get(/*key (className)*/)
String tableName = aep.getTableName();
这篇关于获取在SessionFactory中设置的所有表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文