gpt4 book ai didi

java - Hibernate 中的弱实体映射

转载 作者:行者123 更新时间:2023-12-02 07:25:46 24 4
gpt4 key购买 nike

我有两门课:

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

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

我怎样才能让 hibernate 来处理它?我不想将 id 放在 B 类上,因为它是一个弱实体?

最佳答案

“弱”实体是什么意思?只是没有身份证吗?使用

@ElementCollection
List<B> bs;

随着

@Embeddable
class B {}

找一个例子,例如 here

关于java - Hibernate 中的弱实体映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13608054/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com