jooq-scala-macro

A public type provider macro which produces a set of objects and classes based on those generated by Jooq

License

License

Categories

Categories

Scala Languages jOOQ Data Databases
GroupId

GroupId

io.github.streetcontxt
ArtifactId

ArtifactId

jooq-scala-macro_2.12
Last Version

Last Version

14.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

jooq-scala-macro
A public type provider macro which produces a set of objects and classes based on those generated by Jooq
Project URL

Project URL

https://github.com/streetcontxt/jooq-scala-macro
Project Organization

Project Organization

io.github.streetcontxt
Source Code Management

Source Code Management

https://github.com/StreetContxt/jooq-scala-macro

Download jooq-scala-macro_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.streetcontxt/jooq-scala-macro_2.12/ -->
<dependency>
    <groupId>io.github.streetcontxt</groupId>
    <artifactId>jooq-scala-macro_2.12</artifactId>
    <version>14.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.streetcontxt/jooq-scala-macro_2.12/
implementation 'io.github.streetcontxt:jooq-scala-macro_2.12:14.0.0'
// https://jarcasting.com/artifacts/io.github.streetcontxt/jooq-scala-macro_2.12/
implementation ("io.github.streetcontxt:jooq-scala-macro_2.12:14.0.0")
'io.github.streetcontxt:jooq-scala-macro_2.12:jar:14.0.0'
<dependency org="io.github.streetcontxt" name="jooq-scala-macro_2.12" rev="14.0.0">
  <artifact name="jooq-scala-macro_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.streetcontxt', module='jooq-scala-macro_2.12', version='14.0.0')
)
libraryDependencies += "io.github.streetcontxt" % "jooq-scala-macro_2.12" % "14.0.0"
[io.github.streetcontxt/jooq-scala-macro_2.12 "14.0.0"]

Dependencies

compile (5)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.11
org.scala-lang : scala-reflect jar 2.12.11
org.jooq : jooq jar 3.10.8
org.jooq : jooq-scala_2.12 jar 3.10.8
org.scala-lang.modules : scala-collection-compat_2.12 jar 2.1.6

provided (1)

Group / Artifact Type Version
org.scala-lang : scala-compiler jar 2.12.11

Project Modules

There are no modules declared in this project.

CircleCI Bintray

Introduction

The jooq-scala-macro project consists of a public type provider for Scala which generates immutable Scala classes based on the standard generated JOOQ meta-model classes.

Implicit conversions are also provided to go to/from the Java and Scala representations, and the companion object for a table extends the org.jooq.Table implementation allowing the companion to be used in JOOQ queries.

More detailed documentation is being worked on, in the meantime feel free to ask questions in the Gitter Channel.

Scala & JOOQ versions support

Version 13.0:

Scala version JOOQ version
2.11.x ≥ 3.10.2
2.12.x ≥ 3.10.2

Version 13.1+:

Scala version JOOQ version
2.11.x ≥ 3.10.8
2.12.x ≥ 3.10.8
2.13.x* ≥ 3.13.2

* JOOQ configuration notes for Scala 2.13.x & JOOQ 3.13.x:

The JOOQ code generation process default settings has an important change in v3.13. By default, array types were using varargs setters in versions 3.9..3.12, but then this has been switched to collections in 3.13.

The macro code does not have any knowledge about the settings used in generation, and assumes the varargs setters for backward compatibility, which could generate an incompatible code:

... type mismatch;
[error]  found   : Array[String]
[error]  required: Array[_ <: Array[String]]
[error] @fromCatalog[DefaultCatalog]

To fix the above error, the varargs setters should be explicitly enabled in JOOQ codegen configuration in the client code:

<configuration>
    ...
    <generator>
        ...
        <generate>
            <varargSetters>true</varargSetters>
        </generate>
    </generator>
</configuration>

Example Code

import my.jooq.generated.package.DefaultCatalog

@fromCatalog[DefaultCatalog]
object Database { }

import Database._
import Database.MySchema._

val dsl: DSLContxt = ???

// implicitly converts from AuthorRecord to Author
// the companion object for Author extends the jooq generated table for Author
val author: Author = dsl.selectFrom(Author)
                        .where(Author.ID === 1)
                        .fetchOne()

// generated classes have a .copy() which "remembers" which fields were modified
author.copy(firstName = "Bob")

// implicitly converts from Author to AuthorRecord
author.changed(Author.FIRST_NAME)

Questions and issues

The github issue tracker can be used for bug reports and feature requests.

Our Gitter channel can be used to ask questions.

Note

This project was written separately from the JOOQ project, our use of the name shouldn't be taken as any sort of endorsement from the developers of that library.

io.github.streetcontxt

Street Contxt

Street Contxt connects the sell and buying sides of institutional finance, bringing clarity to the exchange of content between the broker and their client.

Versions

Version
14.0.0