tags:

views:

57

answers:

1

In trying to use Scala with JPA, I have the following snippet as part of the definition of an entity

 @Column(name = "ACC_INT", nullable = true)
 @BeanProperty var accInt: Double = _

All is fine until I retrieve some data and I get the following exception:

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

I think I get what is going on here -- Scala is trying to treat my Double like a double, but I'm not sure how to get around it.

A: 

Double in Scala is actually double, the primitive type. For the wrapper type refer to java.lang.Double.

Timo Westkämper