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的异常, ...
随机推荐
- session锁问题
碰到个问题,在使用了session时(如用户登录),如果当前请求时间过长,再执行其他请求都不会有响应,查找了网上资料发现,这个是session锁的问题 目前我们的程序基本流程如下: (1)加载Sess ...
- Hibernate懒加载的三种解决方案
Hibernate懒加载的两种解决方案: 1.Hibernate.initialize(代理对象) 2.在*.hbm.xml映射文件中添加lazy="false"属性 3.使用op ...
- C-Sharp网络编程案例解析(Socket类的使用)
Server端: using System; using System.Collections.Generic; using System.Text; using System.Net; using ...
- Mac下使用Brew搭建PHP(LNMP/LAMP)开发环境
Mac下搭建lamp开发环境很容易,有xampp和mamp现成的集成环境.但是集成环境对于经常需要自定义一些配置的开发者来说会非常麻烦,而且Mac本身自带apache和php,在brew的帮助下非常容 ...
- Eclipse 打开文件所在文件夹
右击文件 > Show In > System Explorer
- 不使用模板导出Excel(C#版本)
不多说,直接上干货! using System; using System.Collections.Generic; using System.Linq; using System.Web; usin ...
- java算法 蓝桥杯 高精度加法
问题描述 在C/C++语言中,整型所能表示的范围一般为-231到231(大约21亿),即使long long型,一般也只能表示到-263到263.要想计算更加规模的数,就要用软件来扩展了,比如用数组或 ...
- 【G】开源的分布式部署解决方案 - 预告篇
为什么想到要做分布式部署解决方案? 当项目越做越大以后,你会发现部署变成一件极其头疼的事情.当然头疼的绝不仅仅在部署一个环节,比如新服务器环境搭建当中就许多坑要踩.各种重复性的工作,包括但不仅限于增加 ...
- Memcached在windows下的安装和使用
1.下载memcached安装文件及c#开发所需的dll 2.解压<memcached-1.2.6-win32-bin.zip>,并cmd,定位到解压目录. 3.安装服务:输入命令 mem ...
- 通过spring实现javamail发送邮件功能
以前很早的时候大家都用javamail实现发送邮件的功能,而且我们也一直沿用至今,代码拷过来用用就行了,现在我们改为用spring来实现,这样一来减少代码的复杂度,也能更好的契合spring理念 首先 ...