Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

MappedBinary may not handle BLOBs correctly #4

Closed
dchenbecker opened this Issue · 3 comments

2 participants

@dchenbecker
Collaborator

Just looking at the source, we have:

def buildSetActualValue(accessor: Method, inst: AnyRef, columnName: String): (T, AnyRef) => Unit =
(inst, v) => doField(inst, accessor, {case f: MappedBinary[T] =>
  val toSet = v match {
    case null => null
    case ba: Array[Byte] => ba
    case other => other.toString.getBytes("UTF-8")
  }
  f.data() = toSet
  f.orgData() = toSet
})

But the toSet doesn't have a case for getting a java.sql.Blob instance. I think that converting a BLOB to a String and then back to bytes is much less efficient than just doing:

  val toSet = v match {
    case null => null
    case ba: Array[Byte] => ba
    case blob : Blob => blob.getBytes(1, blob.length)
    case other => other.toString.getBytes("UTF-8")
  }
@dchenbecker
Collaborator

Nevermind. I finally found the JDBC spec that says that ResultSet.getObject (in MetaMapper) will return an Array[Byte]

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.