当前位置:Gxlcms > 
数据库问题 > 
hibernate.PropertyAccessException: Null value was assigned to a property of primitive type
                     
                    
                        hibernate.PropertyAccessException: Null value was assigned to a property of primitive type
                        
                            时间:2021-07-01 10:21:17
                            帮助过:18人阅读
							                        
                     
                    
                    
                    @Table(name = 
"table_name")
public class WfFlowLinkInst 
extends AuditAuto {   
@Column(name = 
"next_sort")   
private int nextSort;   
   //getter setter  .....
}
数据库该属性对应字段:next_sort   tinyint(4)   NULL   下一个审批节点序号
原因:          数据库字段为整型,  实体类中对应字段为int,  如果数据库中该字段查询到的值为null, 则hibernate无法将其映射为基本类型int.解决办法:   
     将实体类的数据类型设置为基本类型的包装类.  Integer  , 尽量避免实体类属性使用基本类型!!!!包装类可以解决部分空指针问题.        @Column(name = "next_sort")
       private Integer nextSort; 
来自为知笔记(Wiz)
hibernate.PropertyAccessException: Null value was assigned to a property of primitive type
标签:tran   原因   dea   mic   with   str   public   and   实体