Scala,JPA&可空的领域

时间:2010-10-08 05:05:44

标签: scala jpa

在尝试将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视为双重,但我不确定如何绕过它。

1 个答案:

答案 0 :(得分:4)

Scala中的

Double实际上是double,是原始类型。对于包装器类型,请参阅java.lang.Double