您当前的位置: 首页 >  spring

水的精神

暂无认证

  • 2浏览

    0关注

    711博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

org.springframework.orm.jpa.JpaSystemException

水的精神 发布时间:2019-09-22 09:25:02 ,浏览量:2

错误回放:

   org.springframework.orm.jpa.JpaSystemException: Null value was assigned to a property of primitive type setter of com.rails.air.dataserver.entity.KTOrderMainEntity.flag1; nested exception is org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.rails.air.dataserver.entity.KTOrderMainEntity.flag1

# # 错误分析

  将Null值赋给com.rails.air.dataserver.entity.KTOrderMainEntity.flag1的基本类型setter的一个属性;嵌套异常是org.hibernate。PropertyAccessException: Null值被分配给com.rails.air.dataserver.entity.KTOrderMainEntity.flag1的基本类型setter的属性。

 

 # # 还原场景

  产生这样问题的原因是说从数据库中查询一条数的时候,这条数据有一个个字段没有设值,这就可能为空。然后在实体类中我们有set方法,因为是使用的JPA,查询到的数据给我们封装到实体类中。就是在这个封装的过程中,空值没办法set到比如 int类型的字段上。所以报错了。

 

  # # 解决方案

 解决问题的方案就是,给这条数据为null 的字段填值,在数据库方面,给字段设置默认值。

 

关注
打赏
1664074814
查看更多评论
立即登录/注册

微信扫码登录

0.3765s