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的更多相关文章

  1. org.hibernate.AnnotationException: mappedBy reference an unknown target entity property

    org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: xxxxxxx 原因是 ...

  2. mappedBy reference an unknown target entity property解决方法

    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error ...

  3. org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.demo.pojo.IdCard

    转自:https://blog.csdn.net/zheng0518/article/details/11029733 TestStudent.testSchemaExporttestSchemaEx ...

  4. Hibernate之mappedBy

    Hibernate之mappedBy 摘要: 一.mappedBy单向关系不需要设置该属性,双向关系必须设置,避免双方都建立外键字段 数据库中1对多的关系,关联关系总是被多方维护的即外键建在多方,我们 ...

  5. JPA error org.hibernate.AnnotationException: No identifier specified for entity

    错误:org.hibernate.AnnotationException: No identifier specified for entity 原因:JPA所使用的Entity需要标注@Id,在引用 ...

  6. 报错Caused by: org.hibernate.AnnotationException: No identifier specified for entity:

    Caused by: org.hibernate.AnnotationException: No identifier specified for entity:. 原因: 1.没有给实体类ID 解决 ...

  7. Springboot- Caused by: org.hibernate.AnnotationException: No identifier specified for entity:

    错误与异常: Caused by: org.hibernate.AnnotationException: No identifier specified for entity: 原因:引用了不对的包, ...

  8. org.hibernate.AnnotationException: No identifier specified for entity: com.example1.demo1.Entity.User错误

    最近在公司带人,他们问我的问题在这里也顺便总结下. 此项目为SpringDataJpa项目. 出现的错误如下: Caused by: org.hibernate.AnnotationException ...

  9. org.hibernate.AnnotationException: No identifier specified for entity:

    使用hibernate的e-r映射pojo类的时候遇到org.hibernate.AnnotationException: No identifier specified for entity的异常, ...

随机推荐

  1. Arcgis js API使用wmts方式加载GeoWebCache中的切片地图(转载)

    使用GeoWebCache的主要目的是其独立安装版能够发布arcgis的切片.我们知道,使用openlayer是调用geoserver最方便的方法,那么在发布完arcgis的切片后,怎么用arcgis ...

  2. 配置Log4J(转载)

    Log4J的配置文件(Configuration File)就是用来设置记录器的级别.存放器和布局的,它可接key=value格式的设置或xml格式的设置信息.通过配置,可以创建出Log4J的运行环境 ...

  3. Android测试点

    记录下之前项目测试中涉及到的Android测试点: 1.APP基本功能 按照back log整理测试用例,测试中发现有需求变动.或未考虑完全,及时更新测试用例. 测试用例包括:全功能点用例+重点功能快 ...

  4. animate的{queue:false,duration:400}意思

    示例:$(document).ready(function(){ $('.tmplS').hover(function(){ $(".cover", this).stop().an ...

  5. 解剖 Elasticsearch 集群 - 之三

    解剖 Elasticsearch 集群 - 之三 本篇文章是一系列涵盖 Elasticsearch 底层架构和原型示例的其中一篇.在本篇文章中,我们会讨论 Elasticsearch 如何提供准实时搜 ...

  6. 搭建Minisipserve服务器实现局域网内IOS客户端idoubs的通信

    idoubs是IOS设备开发的第一款全功能并开放源码的3GPP IMS客户端,它同时专为IOS平台开发设计的voIP测试版客户端,以doubango为框架,能实现当前最先进的多媒体功能,主要功能有:语 ...

  7. spring EL表达式,null-safe表达式

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns:xsi="http://ww ...

  8. SQL索引--基础理论

    1.索引的定义 索引是数据库表中一列或多列的值进行的一种排序,用于快速找出在某一列中特定的值. 2.索引的原理 如果不使用索引,则通常的查询数据中,需要对表中数据做一一对应的比较,直到找出所有相关的行 ...

  9. ubuntu 下安装 cudnn

    安装cudnn前后,GPU跑一个算法的速度分别是139ms和26ms ! 1. 在以下网址选择  cuDNN v5.1 Library for Linux 下载 https://developer.n ...

  10. [JQuery] Ajax使用过程中的问题总结

    JQuery提供的ajax函数,在使用过程中,因为对参数的不了解,导致了很多错误,现在总结如下,以便时常温固,不犯同样的错误. 1.我在项目中使用到的ajax请求格式如下: $.ajax({ url: ...