Packages

c

io.getquill.codegen.jdbc

ComposeableTraitsJdbcCodegen

class ComposeableTraitsJdbcCodegen extends JdbcGeneratorBase

This generator generates a query schema trait which can be composed with a custom context that you create in your client code (called MySchemaExtensions below because it extends and existing quill context with your query schemas). Here is what that looks like:

case class Person(firstName:String, lastName:String, age:Int)
case class Address(...)

trait PublicExtensions[+Idiom <: io.getquill.idiom.Idiom, Naming <:
io.getquill.NamingStrategy] { this:io.getquill.context.Context[Idiom, Naming]
=>

object PersonDao { def query = querySchema[Person](...)  object AddressDao {
def query = querySchema[Address](...) } }

// Then when declaring your context: import io.getquill._ object
MyCustomContext extends SqlMirrorContext[H2Dialect, Literal](H2Dialect,
Literal) with PublicExtensions[H2Dialect, Literal]

}

A Note on Stereotyping

Stereotyping using the ComposeableTraitsGen is done in the following manner. Firstly, extend a ComposeableTraitsGen and add the Namespacer of your choice. Let's take the alpha and bravo namespaces and combine them into a common namespace. Also be sure to set the memberNamer correctly so that the different querySchemas generated won't all be called '.query' in the Common object.

 class MyStereotypingGen(...) extends ComposeableTraitsGen(...) {
override def namespacer: Namespacer = ts=> if(ts.tableSchema == "alpha" ||
ts.tableSchema == "bravo") "common" else ts.tableSchema

override def memberNamer: MemberNamer = ts => ts.tableName.snakeToLowerCamel
} 

The following schema should result:

 trait CommonExtensions[+Idiom <:
io.getquill.idiom.Idiom, Naming <: io.getquill.NamingStrategy] {
this:io.getquill.context.Context[Idiom, Naming] =>

object PersonDao { // you don't want each of these to be called 'query' so
choose an appropriate memberNamer def alphaPerson = querySchema[Person](...)
def bravoPerson = querySchema[Person](...) } }

trait PublicExtensions[+Idiom <: io.getquill.idiom.Idiom, Naming <:
io.getquill.NamingStrategy] { this:io.getquill.context.Context[Idiom, Naming]
\=>

object AddressDao { def publicAddress = querySchema[Address](...) } } 

When DAO Objects Collide

Now when you are trying to generate schemas which are not being stereotyped but have equivalent table names for example:

 trait AlphaExtensions[+Idiom <: io.getquill.idiom.Idiom, Naming <:
io.getquill.NamingStrategy] { this:io.getquill.context.Context[Idiom, Naming]
\=>

object PersonDao { def query = querySchema[Person](...) } }

trait BravoExtensions[+Idiom <: io.getquill.idiom.Idiom, Naming <:
io.getquill.NamingStrategy] { this:io.getquill.context.Context[Idiom, Naming]
\=>

object PersonDao { def query = querySchema[Person](...) } }

// Invalid because MyCustomContext has a PersonDao from AlphaExtensions and
and a PersonDao from BravoExtensions which collide. object MyCustomContext
extends SqlMirrorContext[H2Dialect, Literal](H2Dialect, Literal) with
AlphaExtensions[H2Dialect, Literal] with BravoExtensions[H2Dialect, Literal]

You will not be able to append these two traits to the same quill context because the PersonDao inside alpha and bravo will collide inside of MyCustomContext. Use the parameter nestedTrait=true in order to get around this.

 trait AlphaExtensions[+Idiom <: io.getquill.idiom.Idiom, Naming <:
io.getquill.NamingStrategy] { this:io.getquill.context.Context[Idiom, Naming]
\=>

trait AlphaSchema { object PersonDao { def query = querySchema[Person](...) }
} }

trait BravoExtensions[+Idiom <: io.getquill.idiom.Idiom, Naming <:
io.getquill.NamingStrategy] { this:io.getquill.context.Context[Idiom, Naming]
\=>

trait BravoSchema { object PersonDao { def query = querySchema[Person](...) }
} }

// Since PersonDao is inside MyCustomContext.alpha and MyCustomContext.bravo
as opposed to MyCustomContext // there will be no collision. object
MyCustomContext extends SqlMirrorContext[H2Dialect, Literal](H2Dialect,
Literal) with AlphaExtensions[H2Dialect, Literal] with
BravoExtensions[H2Dialect, Literal] 

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ComposeableTraitsJdbcCodegen
  2. JdbcGeneratorBase
  3. JdbcStereotyper
  4. Stereotyper
  5. JdbcCodeGeneratorComponents
  6. CodeGeneratorComponents
  7. QuerySchemaNaming
  8. HasBasicMeta
  9. JdbcGenerator
  10. Generator
  11. AnyRef
  12. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ComposeableTraitsJdbcCodegen(connectionMaker: JdbcConnectionMaker, packagePrefix: String)
  2. new ComposeableTraitsJdbcCodegen(configPrefix: String, packagePrefix: String, nestedTrait: Boolean)
  3. new ComposeableTraitsJdbcCodegen(config: Config, packagePrefix: String, nestedTrait: Boolean)
  4. new ComposeableTraitsJdbcCodegen(config: JdbcContextConfig, packagePrefix: String, nestedTrait: Boolean)
  5. new ComposeableTraitsJdbcCodegen(dataSource: DataSource, packagePrefix: String, nestedTrait: Boolean)

    Simple convenience constructor in the case there is a single datasource.

    Simple convenience constructor in the case there is a single datasource. Useful in order to not have to construct the datasource over and over again.

  6. new ComposeableTraitsJdbcCodegen(connectionMaker: JdbcConnectionMaker, packagePrefix: String, nestedTrait: Boolean)
  7. new ComposeableTraitsJdbcCodegen(connectionMakers: Seq[JdbcConnectionMaker], packagePrefix: String = "", nestedTrait: Boolean = false)

Type Members

  1. class CodeEmitter extends AbstractCodeEmitter with PackageGen
    Definition Classes
    Generator
  2. type ColumnGetter = (ColumnMeta) ⇒ String
    Definition Classes
    CodeGeneratorComponents
  3. type ColumnMeta = JdbcColumnMeta
    Definition Classes
    JdbcGeneratorBaseJdbcStereotyperJdbcCodeGeneratorComponents → HasBasicMeta
  4. type ConnectionMaker = () ⇒ Connection
    Definition Classes
    JdbcCodeGeneratorComponents → CodeGeneratorComponents
  5. class ContextifiedUnitGenerator extends CodeEmitter
  6. type JdbcStereotypingFunction = (Seq[RawSchema[JdbcTableMeta, JdbcColumnMeta]]) ⇒ Seq[TableStereotype[JdbcTableMeta, JdbcColumnMeta]]
    Definition Classes
    JdbcStereotyper
  7. class MultiGeneratorFactory[Emitter <: CodeEmitter] extends AnyRef
    Definition Classes
    Generator
  8. type QuerySchemaNaming = (JdbcTableMeta) ⇒ String
    Definition Classes
    JdbcCodeGeneratorComponents → CodeGeneratorComponents
  9. type SchemaReader = (JdbcConnectionMaker) ⇒ Seq[RawSchema[JdbcTableMeta, JdbcColumnMeta]]
    Definition Classes
    JdbcCodeGeneratorComponents → CodeGeneratorComponents
  10. type SingleGeneratorFactory[Emitter <: CodeEmitter] = (EmitterSettings[TableMeta, ColumnMeta]) ⇒ Emitter
    Definition Classes
    Generator
  11. type TableMeta = JdbcTableMeta
    Definition Classes
    JdbcGeneratorBaseJdbcStereotyperJdbcCodeGeneratorComponents → HasBasicMeta
  12. type TypeInfo = JdbcTypeInfo
    Definition Classes
    JdbcCodeGeneratorComponents → CodeGeneratorComponents
  13. type Typer = (JdbcTypeInfo) ⇒ Option[ClassTag[_]]
    Definition Classes
    JdbcCodeGeneratorComponents → CodeGeneratorComponents
  14. class JdbcStereotypingHelper extends JdbcStereotypingFunction
    Definition Classes
    JdbcStereotyper

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  6. val columnGetter: (ComposeableTraitsJdbcCodegen.ColumnMeta) ⇒ String
    Definition Classes
    JdbcGenerator
  7. val connectionMakers: Seq[JdbcConnectionMaker]
    Definition Classes
    ComposeableTraitsJdbcCodegenJdbcGeneratorBaseJdbcGenerator → Generator
  8. val databaseType: DatabaseType
    Definition Classes
    JdbcGenerator
  9. def defaultExcludedSchemas: Set[String]
    Definition Classes
    JdbcCodeGeneratorComponents → CodeGeneratorComponents
  10. def defaultNamespace: String
    Definition Classes
    CodeGeneratorComponents
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  13. def expresser: Expresser[JdbcTableMeta, JdbcColumnMeta]
    Definition Classes
    JdbcStereotyper
  14. def filter(tc: RawSchema[JdbcTableMeta, JdbcColumnMeta]): Boolean
    Definition Classes
    JdbcGenerator → Generator
  15. def fuser: Fuser[JdbcTableMeta, JdbcColumnMeta]
    Definition Classes
    JdbcStereotyper
  16. def generatorMaker: SingleGeneratorFactory[ContextifiedUnitGenerator]
    Definition Classes
    ComposeableTraitsJdbcCodegen → Generator
  17. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  18. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  19. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  20. def makeGenerators: Seq[ContextifiedUnitGenerator]
    Definition Classes
    ComposeableTraitsJdbcCodegen → Generator
  21. def nameParser: NameParser
    Definition Classes
    JdbcCodeGeneratorComponents → CodeGeneratorComponents
  22. def namespacer: Namespacer[ComposeableTraitsJdbcCodegen.TableMeta]
    Definition Classes
    JdbcGenerator
  23. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  24. val nestedTrait: Boolean
  25. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  26. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  27. def numericPreference: NumericPreference

    When the Jdbc Typer sees a NUMERIC jdbc column, should it use int/long instead of BigInteger if the scale allows?

    When the Jdbc Typer sees a NUMERIC jdbc column, should it use int/long instead of BigInteger if the scale allows?

    Definition Classes
    JdbcCodeGeneratorComponents
  28. val packagePrefix: String
  29. def packagingStrategy: PackagingStrategy
    Definition Classes
    ComposeableTraitsJdbcCodegenJdbcCodeGeneratorComponents → CodeGeneratorComponents
  30. def querySchemaImports: String
    Definition Classes
    CodeGeneratorComponents
  31. def querySchemaNaming: ComposeableTraitsJdbcCodegen.QuerySchemaNaming
    Definition Classes
    CodeGeneratorComponents
  32. val renderMembers: Boolean
    Definition Classes
    Generator
  33. def schemaReader: SchemaReader
    Definition Classes
    JdbcCodeGeneratorComponents → CodeGeneratorComponents
  34. def stereotype(schemas: Seq[RawSchema[JdbcTableMeta, JdbcColumnMeta]]): Seq[TableStereotype[JdbcTableMeta, JdbcColumnMeta]]
    Definition Classes
    JdbcStereotyper → Stereotyper
  35. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  36. def toString(): String
    Definition Classes
    AnyRef → Any
  37. def typer: Typer
    Definition Classes
    JdbcCodeGeneratorComponents → CodeGeneratorComponents
  38. def unrecognizedTypeStrategy: UnrecognizedTypeStrategy

    When the Jdbc Typer tries to figure out which Scala/Java objects to use for which JDBC type (e.g.

    When the Jdbc Typer tries to figure out which Scala/Java objects to use for which JDBC type (e.g. use String for Varchar(...), Long for bigint etc...), what do we do when we discover a JDBC type which we cannot translate (e.g. blob which is currently not supported by quill). The simplest thing to do is to skip the column.

    Definition Classes
    JdbcCodeGeneratorComponents → CodeGeneratorComponents
  39. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  40. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  41. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  42. def writeAllFiles(location: String): Future[Seq[Path]]
    Definition Classes
    Generator
  43. def writeFiles(location: String): Seq[Future[Path]]
    Definition Classes
    Generator
  44. def writeStrings: Seq[String]
    Definition Classes
    Generator

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from JdbcGeneratorBase

Inherited from JdbcStereotyper

Inherited from Stereotyper

Inherited from CodeGeneratorComponents

Inherited from gen.QuerySchemaNaming

Inherited from HasBasicMeta

Inherited from JdbcGenerator

Inherited from Generator

Inherited from AnyRef

Inherited from Any

Ungrouped