首页 > Web开发 > 详细

hibernate之persistence错误

时间:2016-06-17 19:18:52      阅读:255      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!