Get all table names set up in SessionFactory

前端 未结 4 1284
你的背包
你的背包 2020-12-16 05:52

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

4条回答
  •  一个人的身影
    2020-12-16 06:31

    You can try using native sql queries.

    session.createSQLQuery("SELECT * FROM user_tables").list();
    

    which gives list of tables owned by loggedin user or else you can use 'all_tables' or 'dba_tables' for all the tables for oracle database.If mysql db is used then replace the query with "SHOW TABLES"

提交回复
热议问题