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. iOS 错误 之 Unexpected interface name 'HomeListCell': expected expression

    说明:不应该是类HomeListCell:应该是表达式. 出现场景:赋值时,等号右面是个类名,而不是变量名.

  2. spring3.1........jar包下载

    1.common-dbcp-1.4.jar 下载地址:http://commons.apache.org/dbcp/ 2.common-pool-1.6.jar 下载地址:http://commons ...

  3. CSS图形形状大全

    The Shapes of CSS All of the below use only a single HTML element. Any kind of CSS goes, as long as ...

  4. MySQL主从同步校验与重新同步

    主从复制环境中,可能有种种原因导致主.从库数据不一致的情况,主从一致性也一直是DBA需要关注的问题,校验MySQL的主从一致性一般有多种工具,诸如MySQL自带的checksum.mysqldiff. ...

  5. Java jsp基本结构

    <!DOCTYPE html> <!-- [ published at 2015-11-13 12:30:50 ] --> <html> <head> ...

  6. 在ubuntu下增加root用户并登录

    1.打开终端. 2.输入sudo gedit /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf 3.在弹出的编辑框里输入:greeter-show-ma ...

  7. es6笔记3^_^object

    一.destructuring ES6允许按照一定模式,从数组和对象中提取值,对变量进行赋值,这被称为解构Destructuring. //es5 if(1){ let cat = 'ken'; le ...

  8. 美丽的Java图表类库

    摘要 在使用java做后台站点的开发张,图表和报表功能都是不可或缺 的.本文推荐了8款最精彩实用的Java图表应用,大部分图表应用的功能都类似,主要在于界面的美观性和使用的灵活性上有一点高低. 正文 ...

  9. IE和FF的差异

    ie和ff的差异   1. document.form.item 问题 1)现有问题: 现有代码中存在许多 document.formName.item("itemName") 这 ...

  10. B树的查找、插入、删除(附源代码)

    B-Tree Index B-Tree搜索 B-Tree插入 分裂节点 插入节点 B-Tree删除 合并节点 删除节点 Basic B-Tree有两个比较重要的性质: 所有的leaf均在同一个leve ...