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 AnnotationConfi
If you are using JPA instead of direct dependency on hibernate., following code should help in getting all table names
private List getAllTables() {
List tableNames = new ArrayList<>();
Session session = entityManager.unwrap(Session.class);
SessionFactory sessionFactory = session.getSessionFactory();
Map map = (Map) sessionFactory.getAllClassMetadata();
for(String entityName : map.keySet()){
SessionFactoryImpl sfImpl = (SessionFactoryImpl) sessionFactory;
String tableName = ((AbstractEntityPersister)sfImpl.getEntityPersister(entityName)).getTableName();
tableNames.add(tableName);
}
return tableNames;
}