gpt4 book ai didi

java - hibernate:如何将变量映射为外键

转载 作者:行者123 更新时间:2023-12-01 05:09:33 25 4
gpt4 key购买 nike

是否可以将变量Long documentID声明为外键而不是自然的Document文档?下面的示例:

@Entity
@Table("document")
class Document{
...
@Id
Long id;
...
}

@Entity
@Table("something")
class Something{
....
//instead of
@ManyToOne
Document document;

// this one with the appropriate annotations
Long documentID;
...
}

提前致谢......

最佳答案

似乎类似的问题已经出现过:Hibernate. Foreign key mapping by id

不建议以这种方式使用 hibernate。

关于java - hibernate:如何将变量映射为外键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12215906/

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