getting hibernate default schema name programmatically from session factory?

后端 未结 4 950
无人及你
无人及你 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:47

    I just found out that hibernate has {h-schema} replacement that can be used in native sql queries. So this does the job cleanly when you are connected to a one schema in oracle database and want to execute queries against different schemas. Example would be:

    select * from {h-schema}table_name
    

    This ways instead of doing a manual replaceAll in a query, hibernate will take care of everything given that each session factory is configured with "hibernate.default_schema" property.

提交回复
热议问题