org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.entity.annotations.House.district in
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.entity.annotations.House.district in com.entity.annotations.Street.houses
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:578)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:543)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:66)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1177)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:329)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1333)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at com.test.Demo04.saveHouseInfo(Demo04.java:53)
at com.test.Demo04.main(Demo04.java:18)
Exception in thread "main" java.lang.NullPointerException
at com.test.Demo04.saveHouseInfo(Demo04.java:74)
at com.test.Demo04.main(Demo04.java:18)
House.java
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_house")
@SequenceGenerator(name = "seq_house", sequenceName = "seq_house_id", allocationSize = 100, initialValue = 61)
private int id;
@Column(name = "title")
private String title; // 标题
@Column(name = "description")
private String description; // 描述
@Column(name = "price")
private int price; // 出租价格
@Column(name = "pubdate")
private Date pubdate; // 发布时间
@Column(name = "floorage")
private int floorage; // 面积
@Column(name = "contact")
private String contact; // 联系人
@Column(name = "user_id")
private int user_id; // 用户编号
@Column(name = "type_id")
private int type_id; // 类型编号
// private int street_id; // 街道编号
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "street_id")
private Street streets;
Street.java
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_street")
@SequenceGenerator(name = "seq_street", sequenceName = "seq_street_id", allocationSize = 100, initialValue = 11)
private int id;
@Column(name = "name")
private String name;
@OneToMany(mappedBy = "district", cascade = { CascadeType.ALL })
private List<House> houses = new ArrayList<House>();
错误的原因是: @OneToMany(mappedBy = "district", cascade = { CascadeType.ALL }) 这里面的 mappedBy中“district”写错了映射的对象
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.entity.annotations.House.district in的更多相关文章
- org.hibernate.AnnotationException: mappedBy reference an unknown target entity property
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: xxxxxxx 原因是 ...
- mappedBy reference an unknown target entity property解决方法
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error ...
- org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.demo.pojo.IdCard
转自:https://blog.csdn.net/zheng0518/article/details/11029733 TestStudent.testSchemaExporttestSchemaEx ...
- Hibernate之mappedBy
Hibernate之mappedBy 摘要: 一.mappedBy单向关系不需要设置该属性,双向关系必须设置,避免双方都建立外键字段 数据库中1对多的关系,关联关系总是被多方维护的即外键建在多方,我们 ...
- JPA error org.hibernate.AnnotationException: No identifier specified for entity
错误:org.hibernate.AnnotationException: No identifier specified for entity 原因:JPA所使用的Entity需要标注@Id,在引用 ...
- 报错Caused by: org.hibernate.AnnotationException: No identifier specified for entity:
Caused by: org.hibernate.AnnotationException: No identifier specified for entity:. 原因: 1.没有给实体类ID 解决 ...
- Springboot- Caused by: org.hibernate.AnnotationException: No identifier specified for entity:
错误与异常: Caused by: org.hibernate.AnnotationException: No identifier specified for entity: 原因:引用了不对的包, ...
- org.hibernate.AnnotationException: No identifier specified for entity: com.example1.demo1.Entity.User错误
最近在公司带人,他们问我的问题在这里也顺便总结下. 此项目为SpringDataJpa项目. 出现的错误如下: Caused by: org.hibernate.AnnotationException ...
- org.hibernate.AnnotationException: No identifier specified for entity:
使用hibernate的e-r映射pojo类的时候遇到org.hibernate.AnnotationException: No identifier specified for entity的异常, ...
随机推荐
- add jars和add external jars有什么区别
原文add jars和add external jars有什么区别? add jars和add external jars有什么区别? add external jars = 增加工程外部的 ...
- maven 第一次运行报错
在大中国的网络环境下,使用一些国外的资源,是一件很痛苦的事情... 大概在好几个月以前,一个同事跟我说,没事的时候学习maven,现在公司项目都用这个做管理 还给了我电子书<Maven实战> ...
- eclipse 标签标题乱码解决方法
一般出现此类问题都是由于更改本地语言设置引起的. 解决办法: 1.恢复到原来默认的语言和地域 2.更改eclipse主题(Window-->preferences-->General--& ...
- 第十八篇、OC_使用OAStackView FDStackView (第三方框架)可以使用在ios 7及以上的版本
UILabel *view1 = [[UILabel alloc]init]; view1.text = @"Label1"; view1.backgroundColor = [U ...
- C# backgroundworker使用方法
# BackgroundWorker 控件的几个实例(C# backgroundworker使用方法): 在 WinForms 中,有时要执行耗时的操作,在该操作未完成之前操作用户界面,会导致用户界面 ...
- mybatis springmvc调用oracle存储过程,返回记录集
参考: http://bbs.csdn.net/topics/390866155 辅助参考: http://www.2cto.com/kf/201307/226848.html http://blog ...
- spring MVC cors跨域实现源码解析
# spring MVC cors跨域实现源码解析 > 名词解释:跨域资源共享(Cross-Origin Resource Sharing) 简单说就是只要协议.IP.http方法任意一个不同就 ...
- 微信小程序 JS动态修改样式
微信小程序这个坑啊,js动态修改样式,我们并不能用js或者jq 轻轻松松一行代码搞定.或者用removeClass addClass 来修改样式. 以下是一种动态修改样式的方法,原理是绑定数据,然后动 ...
- 关于js的parseInt方式在不同浏览器下的表现
今天开发期间遇到个需求要把日期格式转换成毫秒数 日期为:2015-08-10 split之后使用parseInt将2015,08,10分别转化为数字格式. 但是使用parseInt('08')的时候却 ...
- android 项目更改包名的方法
本文章全文转载: http://www.2cto.com/kf/201304/206747.html 1.在项目上右键,选择android tools->rename application p ...