异常:
javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.copa.Payment.tranId
我今天开发碰上这事,看到查询赋值该字段为null的时候付不了值给该实体类,之后我看了一下
private int tranId;
一看这个就立马知道被坑了,因为int是基本数据类型默认赋值为0,不能赋值为null,因为它并不表示类
如果用对应包装int的Integer就可以,因为Integer就是一个类,就可以赋值为null,避免该异常的发生~
修改如下:
private Integer tranId;