Created
February 23, 2018 02:54
-
-
Save devshorts/6d1bb71c08578b904ea02dd38141af03 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait BigIntegerTypesComponent extends RelationalTypesComponent { | |
self: JdbcProfile => | |
implicit def bigIntType = new BigIntegerJdbcType | |
implicit val bigIntSetParam = new SetParameter[BigInteger] { | |
override def apply(v1: BigInteger, v2: PositionedParameters): Unit = v2.setObject(v1, java.sql.Types.BIGINT) | |
} | |
class BigIntegerJdbcType extends DriverJdbcType[BigInteger] with NumericTypedType { | |
def sqlType = java.sql.Types.BIGINT | |
def setValue(v: BigInteger, p: PreparedStatement, idx: Int) = { | |
p.setObject(idx, v) | |
} | |
def getValue(r: ResultSet, idx: Int): BigInteger = { | |
val v = r.getObject(idx) | |
if (v eq null) { | |
null | |
} else { | |
v match { | |
case l: java.lang.Long => | |
BigInteger.valueOf(l) | |
case _ => | |
v.asInstanceOf[BigInteger] | |
} | |
} | |
} | |
def updateValue(v: BigInteger, r: ResultSet, idx: Int) = { | |
r.updateObject(idx, v) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment