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. 常用的JavaScript字符串处理函数及用法

    最近参加了几次前端实习生招聘的笔试,发现很多笔试题都会考到字符串的处理,比方说去哪儿网笔试题.淘宝的笔试题等,如果你经常参加笔试或者也是一个过来人,相信你也跟我一样,发现字符串的处理是前端招聘过程中最 ...

  2. js架构设计模式——MVC,MVP 和 MVVM 的图示及简单明了的区别说明

    MVC,MVP 和 MVVM 的图示 复杂的软件必须有清晰合理的架构,否则无法开发和维护. MVC(Model-View-Controller)是最常见的软件架构之一,业界有着广泛应用.它本身很容易理 ...

  3. NodeMCU之旅(一):构建、刷入固件,上传代码

    扬帆起航 本系列文章将试图实现,使用Web页面远程点亮led.具体包括: 在NodeMCU上搭建HTTP服务器,使其可以通过Web页面配置要接入的网络. 在配置页面可以显示附近中英网络名与信号强度. ...

  4. HTML5 Canvas、内联 SVG、Canvas vs. SVG

    canvas 元素用于在网页上绘制图形. 什么是 Canvas? HTML5 的 canvas 元素使用 JavaScript 在网页上绘制图像. 画布是一个矩形区域,您可以控制其每一像素. canv ...

  5. Flex中escape/encodeURI/encodeURIComponent的区别

    Flex中提供了三种转码函数,各有各的区别, escape,encodeURI,encodeURIComponent 这三个函数不仅在flex中有道运用在javascript中同样的含义 ,今天我仔细 ...

  6. AtomicInteger相关类

    引用地址:http://blog.csdn.net/xh16319/article/details/17056767 在java6以后我们不但接触到了Lock相关的锁,也接触到了很多更加乐观的原子修改 ...

  7. UWP开发技巧:实现SMB协议操作文件服务器文件

    问题来源 文件服务器文件夹操作在PC与Surface端确实还是和传统操作一样没什么区别,但是到了手机端与Surface Hub就没那么方便了,因为文件资源管理器Explorer根本没法添加网路硬盘.对 ...

  8. spring-dwr注解整合

    注解配置 1.web.xml 只需将DwrServlet换为DwrSpringServlet(包名不同) 2.dwr类 3.applicationContext.xml 4.annotationCon ...

  9. 有趣的++i和i++

    作为一个天天和代码“约会”的人来说i++和++i这玩意再熟悉不过了,因为使用频率太高了. 虽然如此,但也未必见得我们真的了解她,不妨猜猜下面的输出结果. #inlcude <stdio.h> ...

  10. 第二章:在HTML中使用JavaScript

    1:在使用<script>嵌入JavaScript代码死,记住不要在代码中的任何地方出现"</script>"字符串 例如,浏览器在加载下面所示代码时就会产 ...