如何在构建会话工厂期间获取元数据

时间:2019-02-08 04:45:52

标签: spring hibernate spring-annotations spring-orm

使用Spring 4.3.4和Hibernate 5.1.17

我想知道如何在运行时修改元数据或获取实体映射元数据。 我可以扩展LocalSessionFactoryBean,getMetadata并将其修改为使用其他架构吗? 我想做的就是,我需要将表名从schema2替换为mock_schema2。

作为dbtest的一部分,我需要使用其他模式而不是实体定义中使用的普通模式。 当我使用以下实体定义

select
        this_.objid as objid1_0_0_,
        this_.name as name2_0_0_,
        this_.resourceKey as resource3_0_0_,
        this_.uuid as uuid4_0_0_,
        this_1_.healthStatus as healthSt1_2_0_,
        this_1_.lastSync as lastSync2_2_0_
    from
        schema1.cluster this_
    inner join
        schema2.Cluster this_1_
            on this_.objid=this_1_.clusterId;

Hibernate内部生成如下查询

FirstName LastName; Country; Restofaddress

在Dbtest的情况下,我希望查询使用模拟_schema2.Cluster而不是schema2.Cluster 。 我想知道如何在不修改实体定义的情况下做到这一点

https://vladmihalcea.com/how-to-get-access-to-database-table-metadata-with-hibernate-5/ 基本上,我正在尝试遵循上述博客中提到的方法。

0 个答案:

没有答案
相关问题