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. eclipse中创建类和方法自动注释

    <?xml version="1.0" encoding="UTF-8"?><templates><template autoin ...

  2. PHP正则表达式验证是否含有中文

    判断是否 有中文. if (preg_match("/[\x7f-\xff]/", $string)) { echo "true"; }else{ echo & ...

  3. eQTL

    首先QTL是数量性状位点,比如身高是一个数量性状,其对应的控制基因的位点就是一个数量性状位点,而eQTL就是控制数量性状表达位点,即能控制数量性状基因(如身高基因)表达水平高低的那些基因的位点. 数量 ...

  4. 超强JavaScript编辑器WebStorm代码提示迟缓问题及其它想到的

    去D2后发现 Hedger 的js编辑器是webStorm,便下载来试试,结果发现: 虽然WebStorm的js的提示远远不如aptana那么强悍(输入字母d不提示document),但是做为 Int ...

  5. 关于android:id="@+id/xx"的理解

    之前学习android的时候,对android:id="@+id/xx"总感觉混淆,不理解,刚看了一篇文章.现在貌似是恍然大悟.故做了一下笔记,希望帮助有共同问题的人... and ...

  6. AngularJS中$http服务的简单用法

    我们可以使用内置的$http服务直接同外部进行通信.$http服务只是简单的封装了浏览器原生的XMLHttpRequest对象. 1.链式调用 $http服务是只能接受一个参数的函数,这个参数是一个对 ...

  7. HTML 5 服务器发送事件、Input 类型、表单元素、表单属性

    HTML5 服务器发送事件(server-sent event)允许网页获得来自服务器的更新. Server-Sent 事件 - 单向消息传递 Server-Sent 事件指的是网页自动获取来自服务器 ...

  8. Ubuntu 14.04下搭建Node.js的开发环境

    最近想找一个轻量级且支持快速开发的服务开发平台,选来选去选择了Node.js,当时有几种选择: Python + Django(用过Django,虽然开发快速,但是感觉性能并不太好). Ruby + ...

  9. C++实现具有基本功能的智能指针

    C++中的智能指针实际上是代理模式与RAII的结合. 自定义unique_ptr,主要是release()和reset().代码如下. #include <iostream> using ...

  10. vue原来可以这样上手

    今儿与一群友讨论vue相关问题让我思量极深,1.我们是否在争对性解决问题或者说是帮助别人:2.我们是否在炫耀自己的技能.以下是被戏剧化的对白: "群友":最近按照vue官网示例学习 ...