在尝试将Scala与JPA一起使用时,我将以下片段作为实体定义的一部分
@Column(name = "ACC_INT", nullable = true)
@BeanProperty var accInt: Double = _
一切正常,直到我检索到一些数据并得到以下异常:
org.springframework.orm.hibernate3.HibernateSystemException: Null value was assigned to a property of primitive type setter of com.jim.fi.sppa.RiskData.accInt; nested exception is org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.jim.fi.sppa.RiskData.accInt
....
Caused by: org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.jim.fi.sppa.RiskData.accInt
at ...
Caused by: java.lang.IllegalArgumentException: Can not set double field com.jim.fi..sppa.RiskData.accInt to null value
我想我得到了正在发生的事情--Scala试图将我的Double视为双重,但我不确定如何绕过它。
答案 0 :(得分:4)
Double
实际上是double
,是原始类型。对于包装器类型,请参阅java.lang.Double
。