the base class used in automate generated ResultSetMapper.
for values(of type T) to passed into Statement or passed out from ResultSet, it should has a contxt bound of JdbcValueAccessor[T]
for values(of type T) to passed into Statement or passed out from ResultSet, it should has a contxt bound of JdbcValueAccessor[T]
package wangzx.scala_commons.sql prdefined a lot of pre-defined implementation for the jdbc value types:
developer can define your's value type such as a MyDate which stored as database Date
, you need only define
an implicit value of JdbcValueAccessor[MyDate], then you can:
any record level(a table row) having a ResultSetMapper context bound can used in rows[T](sql)
any record level(a table row) having a ResultSetMapper context bound can used in rows[T](sql)
the scala-sql library provide a Macro to automate generate the implementation for a given case class T if all it's field is JdbcValueAccess-able(having a JdbcValueAccess context bound).
since the macro will generate a ResultSetMapper class for you anytime if there is not an explicit imported implicit value, maybe a lot of anonymous class will be generated. that is no problem but a bigger jar. to avoid this problem, you can define a implicit ResultSetMappper value in the Case Class's companion object.
case class User(name: String, age: Int) object User { implicit val resultSetmapper = ResultSetMapper.material[User] }
wrap a sql"select * from table where id = $id" object
TODO support camel and underscore name mapping like doSomething <-> do_something
provide a offline Box for ResultSet which is scrollable and only valid with an open connection.