在休眠中访问模式间表和关系

nit*_*esh 6 java oracle schema hibernate

存在一种典型的情况,即不同的表分散在Oracle数据库中的不同模式中,并且它们彼此相关(包含所有不同类型的关系).

它们如何使用注释在Hibernate中表示,因为当为一个模式创建sessionfactory句柄时,该模式中的表不能访问其他相关表(与其他模式中的表的外键关系)?

对于如下的查询,抛出异常 -

"from table1 as model where model.table2Name.table2column = "+foo
Run Code Online (Sandbox Code Playgroud)

例外情况如下 -

org.hibernate.QueryException: 
    could not resolve property: 
    table2column of: 
    com.test.table1 
    [from com.test.table1 as model where model.table2Name.table2column = 1]
Run Code Online (Sandbox Code Playgroud)

这里table1和table2存在于不同的模式中.

nit*_*esh 2

最后我得到了解决方案。这是使用该表的模式注释完成的,如下所示 - @Entity @Table(name = "table1", schema="schema1") 另外,table2 类的映射应包含在 table1 模式的配置文件中。