我有两个表:用户和团队
用户
用户身份
4位密码/密码
团队
Team_id
队名
约束 1 个用户只能属于一个团队,而 1 个团队可以有多个用户。我已经对数据库进行了规范化,名为 user_team 的第三个 table()Join Table) 将如下所示:
User_Team[加入表]
User_id(这是来自用户表的外键)
Team_Id(这是来自团队表的外键)
在使用 @JoinColumn 属性和 @OneToMany 注释在 Hibernate 中实现这一点时,它会抛出以下错误:
来自 com.project.hibernate.User 的外键引用 com.project.hibernate.Team 的列数错误。应该是 2
线程“主”org.hibernate.AnnotationException 中的异常:从 com.project.hibernate.User 引用 com.project.hibernate.Team 的外键具有错误的列数。在 org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1610) 在 org.hibernate.cfg.annotations 的 org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:657) 应该是 2。 CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1335) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:800) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:725) org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:54) 在 org.hibernate.boot.internal.InFlightMetadataCollectorImpl。
慕斯709654
相关分类