package jdbc
- Alphabetic
- Public
- All
Type Members
-
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).
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
alphaandbravonamespaces and combine them into acommonnamespace. Also be sure to set the memberNamer correctly so that the different querySchemas generated won't all be called '.query' in theCommonobject.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=truein 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] -
class
SimpleJdbcCodegen extends JdbcGeneratorBase
The purpose of the simple code generator is to generate simple case classes representing tables in a database.
The purpose of the simple code generator is to generate simple case classes representing tables in a database. Create one or multiple
CodeGeneratorConfigobjects and call the.writeFilesor.writeStringsmethods on the code generator and the reset happens automatically.
Value Members
- object DatabaseTypes