简体   繁体   English

Hibernate中的弱实体映射

[英]Weak Entity Mapping in Hibernate

I have 2 classes: 我有2个班:

@Entity
class A{
    @Id
    long id
    @???
    List<B> bs;
}

@????
class B{
    @ManyToOne
    A a;
    @OneToOne
    C c;
    Integer a,b,c,d,e;
}

how can i make hibernate to handle it ?? 我如何让hibernate来处理它? i dont want to put id on class B as it's a weak entity? 我不想把ID放在B级,因为它是一个弱实体?

What do you mean by 'weak' entity? “弱”实体是什么意思? It just doesn't have an ID? 它只是没有ID? Use 采用

@ElementCollection
List<B> bs;

Along with 随着

@Embeddable
class B {}

Find an example for instance here 例如, 在这里找一个例子

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

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