码迷,mamicode.com
首页 > Web开发 > 详细

hibernate之persistence错误

时间:2016-06-17 19:20:58      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:

错误码:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory‘ defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory

 

上述错误码nested exception is javax.persistence.PersistenceException可知是实体类实例化的时候报错,所以应该查看实体类是否有注解、字段书写的错误,我的是因为之前做关联,后面去掉了,但注解没有去掉导致,出错代码:

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id", nullable = false)
    private long userId;

之前是:

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id", nullable = false)
    private User user;

正确的是:
  @JoinColumn(name = "user_id", nullable = false)
  private long userId;

 

hibernate之persistence错误

标签:

原文地址:http://www.cnblogs.com/sunjf/p/hibernate_persistence.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!