nested exception is org.hibernate.AnnotationException: Unknown mappedBy in
来源:互联网 发布:成都人工智能公司 编辑:程序博客网 时间:2024/06/16 18:21
使用注解的方式进行hibernate逆向工程出现的Bug
设有表A与表B是一对一的关系(其中外键存在于表B中指向表A)
逆向工程生成的模式是:
表 A(实体类) :
...
@OneToOne(fetch = FetchType.LAZY, mappedBy = "a")
...
表 B(实体类):
....
@OneToOne(fetch = FetchType.LAZY, mappedBy = "b")
....
而实际上mappedBy是使用在OneToOne, OneToMany, ManyToMany中没有外键的一方
而存在外键的一方应该使用
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "a")
so正确应该是 :
表A:
...
@OneToOne(fetch = FetchType.LAZY, mappedBy = "a")
...
表B:
...
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "b_a")
...
结论 : 逆向工程也可能出错
阅读全文
0 0
- nested exception is org.hibernate.AnnotationException: Unknown mappedBy in
- org.hibernate.AnnotationException: mappedBy reference an unknown target entity property
- nested exception is org.hibernate.MappingException: Unknown entity,问题解决
- nested exception is org.hibernate.MappingException: Unknown en
- nested exception is org.hibernate.MappingException: Unknown entity:
- nested exception is org.hibernate.AnnotationException: No identifier specified for entity
- 2.Unknown entity: java.util.ArrayList; nested exception is org.hibernate.MappingException: Unknown e
- Unknown integral data type for ids : java.lang.String; nested exception is org.hibernate.id.Identifi
- Unknown integral data type for ids : java.lang.String; nested exception is org.hibernate.id.Identifi
- org.hibernate.AnnotationException: Referenced property not a (One|Many)ToOne: in mappedBy of
- org.hibernate.AnnotationException: Unknown Id.generator: Teacher_GEN
- nested exception is org.hibernate.exception.DataException的问题
- nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection
- Error while indexing in Hibernate Search(before transaction completion); nested exception is org.hib
- nested exception is java.lang.ClassCastException: org.hibernate.type.StringType
- nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
- nested exception is org.hibernate.QueryException:could not resolve property:
- org.springframework.data.redis.RedisSystemException: Unknown redis exception; nested exception is ja
- Vrui VR Toolkit --- Vrui 虚拟现实工具集
- 《从Paxos到zookeeper分布式一致性原理与实践》笔记
- Spring MVC请求流程
- windbg扩展python脚本
- java基础—实用的工具方法
- nested exception is org.hibernate.AnnotationException: Unknown mappedBy in
- 深拷贝与浅拷贝实现(参考jquery)
- XML上——JAVA读取XML文件
- palindrome-number
- C/C++ sort函数的用法
- 进程间通信—命名管道
- spark-调优-shuffle
- ActionContext 、ServletContext 和 ServletActionContext 的区别
- 错位的字符串问题