wsql

package wsql

Members list

Packages

package wsql.macros

Type members

Classlikes

trait Batch[T]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class BatchImpl[T]
object BatchImpl

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
BatchImpl.type
class BatchImpl[T](conn: Connection, statement: String)(proc: T => List[JdbcValue[_] | Null]) extends Batch[T]

Attributes

Companion
object
Supertypes
trait Batch[T]
class Object
trait Matchable
class Any
object BeanBuilder

TODO support camel and underscore name mapping like doSomething <-> do_something

TODO support camel and underscore name mapping like doSomething <-> do_something

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any

currently, only classes supprt, dont support object yet. mapping a column name to a field name. such as field: userName, column: user_name

currently, only classes supprt, dont support object yet. mapping a column name to a field name. such as field: userName, column: user_name

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object given_ConnectionOps.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object given_DataSourceOps.type
trait DbEnum

Attributes

Supertypes
class Object
trait Matchable
class Any
class DbEnumJdbcValueAccessor[T <: DbEnum](valueOf: Int => T) extends JdbcValueAccessor[T]

Attributes

Supertypes
class Object
trait Matchable
class Any

Attributes

Supertypes
class Object
trait Matchable
class Any
sealed case class JdbcValue[T](value: T)(implicit evidence$1: JdbcValueAccessor[T])

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object JdbcValue

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
JdbcValue.type

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:

  • boolean, byte, short, Int, Long, Float, Double, BigDecimal, scala.BigDecimal

  • String

  • Date, Time, Timestamp

  • Blob, Clob, byte[]

  • Option[T] if T has JdbcValueAccessor context bounded

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:

  • pass in statement using sql"... where date_field = $myDate"

  • passout from ResultSet, using rs.get[MyDate](field index or name)

  • mapping to a field of other CaseClass such as User, and then using rowsUser

  • mapping to a Row object and rowsRow, and then using row.get[MyDate](field index of name).

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object _jva_array0.type
object _jva_bd.type
object _jva_blob0.type
object _jva_clob0.type
object _jva_date0.type
object _jva_date2.type
object _jva_ts0.type
object jva_bd0.type
object jdbcValueAccessor.type
Show all

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
object NoopProcessor extends Any => Unit

Attributes

Supertypes
trait Any => Unit
class Object
trait Matchable
class Any
Self type
trait ResultSetMapper[T]

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]
}

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object _rsm_bd.type
object _rsm_bd0.type
object _rsm_date.type
object _rsm_date0.type
object _rsm_ts_0.type
object resultSetMapper.type
Show all

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
object Row

provide a offline Box for ResultSet which is scrollable and only valid with an open connection.

provide a offline Box for ResultSet which is scrollable and only valid with an open connection.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
Row.type
class Row(val cells: Seq[Cell[_]]) extends ResultSet

Attributes

Companion
object
Supertypes
trait ResultSet
trait AutoCloseable
trait Wrapper
class Object
trait Matchable
class Any
Show all
case class SQLWithArgs(sql: String, args: Seq[JdbcValue[_] | Null])

wrap a sql"select * from table where id = $id" object

wrap a sql"select * from table where id = $id" object

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
class UseColumnMapper(value: Class[_ <: CaseClassColumnMapper]) extends StaticAnnotation

annotated on a case class, to specify the column mapper, such as @UseColumnMapper(classOf[Camel2UnderscoreMapper]) default using IdentityMapping

annotated on a case class, to specify the column mapper, such as @UseColumnMapper(classOf[Camel2UnderscoreMapper]) default using IdentityMapping

Attributes

Supertypes
trait StaticAnnotation
class Annotation
class Object
trait Matchable
class Any
class db(name: String) extends StaticAnnotation

Attributes

Supertypes
trait StaticAnnotation
class Annotation
class Object
trait Matchable
class Any

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object given_Conversion_String_SQLWithArgs extends Conversion[String, SQLWithArgs]

Attributes

Supertypes
class Conversion[String, SQLWithArgs]
trait String => SQLWithArgs
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object mysql

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
mysql.type

Extensions

Extensions

extension (rs: ResultSet)(rs: ResultSet)
inline def get[T : JdbcValueAccessor](index: Int)(implicit evidence$2: JdbcValueAccessor[T]): T
inline def get[T : JdbcValueAccessor](label: String)(implicit evidence$3: JdbcValueAccessor[T]): T
inline def getOption[T : JdbcValueAccessor](index: Int)(implicit evidence$4: JdbcValueAccessor[T]): Option[T]
extension (sc: StringContext)(sc: StringContext)
def SQL(args: JdbcValue[_]*): SQLWithArgs

SQL"" will validate the sql statement at compiler time.

SQL"" will validate the sql statement at compiler time.

Attributes

def sql(args: JdbcValue[_] | Null*): SQLWithArgs