简体   繁体   English

使用注释将单个实体映射到休眠中相同模式的多个表

[英]Mapping a single entity to multiple tables of same schema in hibernate using annotations

I have a class CustomerProfile which is mapped to a table CUST_PROFILE.我有一个类 CustomerProfile,它映射到一个表 CUST_PROFILE。 We have requirement to maintain the closed profiles in a separate table which will have the same schema.我们需要在一个单独的表中维护封闭的配置文件,该表将具有相同的架构。 I have read many questions in SO especially the below (which has a answer summarizing many other similar questions )我在 SO 中阅读了许多问题,尤其是以下内容(其中有一个总结了许多其他类似问题的答案)

hibernate two tables per one entity 每个实体休眠两张表

from which I can understand that it is difficult to acheive the same using annotations other than the MappedSuperClass.从中我可以理解,使用 MappedSuperClass 以外的注释很难实现相同的目标。 but possible using the xml mapping.但可以使用 xml 映射。

The reason i am hesitant to use MappedsuperClass is because CustomerProfile has 17 other table with one to many mapping and we have the same set of tables for closed customer profiles also.我对使用 MappedsuperClass 犹豫不决的原因是因为 CustomerProfile 有 17 个其他表具有一对多映射,而且我们也有相同的一组表用于封闭的客户配置文件。 So i would end up with (17 + 1 for customer profile) 18 mapped super class, 18 active profile and 18 closed profile classes which is 54 classes.所以我最终会得到(17 + 1 用于客户配置文件)18 个映射的超类、18 个活动配置文件和 18 个封闭配置文件类,即 54 个类。

Is there any other way that this can be achieved without MappedSuperClass when using Annotations.在使用注解时,有没有其他方法可以在没有 MappedSuperClass 的情况下实现这一点。

我使用 MappedSuperClass 本身也达到了同样的效果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM