Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import scala.reflect.runtime.universe._
class GettableDataToMappedTypeConverter[T : TypeTag : ColumnMapper](
structDef: StructDef,
columnSelection: IndexedSeq[ColumnRef])
extends TypeConverter[T] {
extends NullableTypeConverter[T] {

// can't be lazy, because TypeTags are not serializable, and if we made it lazy,
// the right side would be stored in a hidden serialized variable anyway
Expand Down Expand Up @@ -267,4 +267,4 @@ class GettableDataToMappedTypeConverter[T : TypeTag : ColumnMapper](
fillBuffer(data, buf)
factory.newInstance(buf: _*)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,16 @@ class GettableDataToMappedTypeConverterSpec extends FlatSpec with Matchers {
user.getAddress.getNumber shouldBe 5
}

it should "convert a CassandraRow with null UDTs to nested JavaBeans" in {
implicit val cm: ColumnMapper[UserBeanWithAddress] = new JavaBeanColumnMapper[UserBeanWithAddress]
val row = CassandraRow.fromMap(Map("login" -> "foo", "address" -> null))
val converter = new GettableDataToMappedTypeConverter[UserBeanWithAddress](
userTable, userTable.columnRefs)
val user = converter.convert(row)
user.getLogin shouldBe "foo"
user.getAddress shouldBe null
}

class LongBean {
private[this] var number: java.lang.Long = null
def getNumber: java.lang.Long = number
Expand Down Expand Up @@ -410,4 +420,4 @@ class GettableDataToMappedTypeConverterSpec extends FlatSpec with Matchers {
val deserialized = SerializationUtils.roundtrip(converter)
a [NullPointerException] should be thrownBy deserialized.targetTypeTag
}
}
}