getting hibernate default schema name programmatically from session factory?

后端 未结 4 947
无人及你
无人及你 2021-02-07 15:24

I was wondering if there is a way to get the default schema name from session factory, somehow? The reason I need to get it is because I have to use a one native SQL and I have

4条回答
  •  执笔经年
    2021-02-07 15:58

    I had problems with John's solution to use {h-schema} when using the Criteria api's Restrictions.sqlRestriction(...) (probably because this substitution happens within the separate HQL api). Similar to Michael's solution, I used:

    SessionFactoryImplementor sfi = (SessionFactoryImplementor)sessionFactory;
    String name = sfi.getSettings().getDefaultSchemaName();
    

提交回复
热议问题