Skip to content

Commit

Permalink
[#1] Move project to jOOQ-pro subdirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaseder committed May 25, 2022
1 parent e853be2 commit 94db77c
Show file tree
Hide file tree
Showing 186 changed files with 38 additions and 17 deletions.
3 changes: 3 additions & 0 deletions jOOQ-oss/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.iml
/.idea/
/target
3 changes: 3 additions & 0 deletions jOOQ-pro/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.iml
/.idea/
/target
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jooq.demo;

import org.jooq.DSLContext;
import org.jooq.ExecuteListener;
import org.jooq.SQLDialect;
import org.jooq.conf.Settings;
import org.jooq.impl.DefaultConfiguration;
Expand All @@ -12,7 +13,9 @@
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
import java.util.stream.Stream;

import static org.jooq.SQLDialect.*;
import static org.jooq.demo.java.db.Tables.ACTOR;
import static org.jooq.impl.DSL.using;

Expand Down Expand Up @@ -41,17 +44,17 @@ public void setup() throws IOException, SQLException {
.set(connection)
.set(SQLDialect.COCKROACHDB)
.set(new Settings()
// .withRenderFormatted(true)
.withRenderFormatted(true)
)

// Activate this to get the output from different dialects
// .set(ExecuteListener.onExecuteStart(e -> Stream
// .of(MYSQL, ORACLE, POSTGRES, SQLSERVER)
// .map(d -> using(d, new Settings().withRenderFormatted(true)))
// .forEach(c -> {
// title(c.dialect());
// println(c.renderInlined(e.query()));
// })))
.set(ExecuteListener.onExecuteStart(e -> Stream
.of(MYSQL, ORACLE, POSTGRES, SQLSERVER)
.map(d -> using(d, new Settings().withRenderFormatted(true)))
.forEach(c -> {
title(c.dialect());
println(c.renderInlined(e.query()));
})))
);

// Initialise classes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public void typeSafetyActiveRecords() {
.fetchSingle();

println("Resulting actor: %s %s".formatted(actor.getFirstName(), actor.getLastName()));

// More on these UpdatableRecords later
}

Expand Down Expand Up @@ -188,7 +187,10 @@ public void typeSafetyAliasing() {
@Test
public void implicitJoins() {
title("No need to spell out trivial to-one joins");
ctx.select(CUSTOMER.FIRST_NAME, CUSTOMER.LAST_NAME, CUSTOMER.address().city().country().COUNTRY_)
ctx.select(
CUSTOMER.FIRST_NAME,
CUSTOMER.LAST_NAME,
CUSTOMER.address().city().country().COUNTRY_)
.from(CUSTOMER)
.orderBy(1, 2)
.limit(5)
Expand Down Expand Up @@ -218,7 +220,10 @@ record Customer(String firstName, String lastName, Country country) {}

title("Nesting is particularly useful when using ad-hoc converters");
List<Customer> r =
ctx.select(CUSTOMER.FIRST_NAME, CUSTOMER.LAST_NAME, CUSTOMER.address().city().country().COUNTRY_.convertFrom(Country::new))
ctx.select(
CUSTOMER.FIRST_NAME,
CUSTOMER.LAST_NAME,
CUSTOMER.address().city().country().COUNTRY_.convertFrom(Country::new))
.from(CUSTOMER)
.orderBy(1, 2)
.limit(5)
Expand Down Expand Up @@ -250,7 +255,7 @@ record Customer(String firstName, String lastName, Country country) {}
@Test
public void nestingToManyRelationships() {
title("The envy of all other ORMs: MULTISET!");
var r =
Result<Record3<String, Result<Record2<String, String>>, Result<Record1<String>>>> r =
ctx.select(
FILM.TITLE,
multiset(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.jooq.kotlin.mapping
import org.junit.Test
import java.math.BigDecimal
import java.time.LocalDate
import java.time.LocalDateTime
import java.util.function.BiConsumer

class Demo01Querying : AbstractDemo() {
Expand All @@ -29,7 +30,7 @@ class Demo01Querying : AbstractDemo() {
@Test
fun typeSafetySimpleQuery() {
title("A simple type safe query")
val r = ctx.select(ACTOR.FIRST_NAME, ACTOR.LAST_NAME)
val r = ctx.select(ACTOR.FIRST_NAME, ACTOR.LAST_UPDATE)
.from(ACTOR)
.where(ACTOR.LAST_NAME.like("A%"))
.orderBy(ACTOR.FIRST_NAME.asc())
Expand Down Expand Up @@ -102,7 +103,7 @@ class Demo01Querying : AbstractDemo() {
val result = ctx.select(ACTOR.FIRST_NAME, ACTOR.LAST_NAME)
.from(ACTOR)
.where(ACTOR.FIRST_NAME.like("A%"))
.union(
.unionAll(
select(CUSTOMER.FIRST_NAME, CUSTOMER.LAST_NAME)
.from(CUSTOMER)
.where(CUSTOMER.FIRST_NAME.like("A%"))
Expand Down Expand Up @@ -134,6 +135,7 @@ class Demo01Querying : AbstractDemo() {
@Test
fun standardisationLimit() {
title("LIMIT .. OFFSET works in (almost) all dialects")

val r1 = ctx.select(ACTOR.FIRST_NAME, ACTOR.LAST_NAME)
.from(ACTOR)
.where(ACTOR.FIRST_NAME.like("A%"))
Expand Down Expand Up @@ -220,7 +222,8 @@ class Demo01Querying : AbstractDemo() {
.select(
CUSTOMER.FIRST_NAME,
CUSTOMER.LAST_NAME,
CUSTOMER.address.city.country.COUNTRY_.convertFrom(::Country))
CUSTOMER.address.city.country.COUNTRY_.convertFrom(::Country)
)
.from(CUSTOMER)
.orderBy(1, 2)
.limit(5)
Expand Down Expand Up @@ -249,13 +252,17 @@ class Demo01Querying : AbstractDemo() {
@Test
fun nestingToManyRelationships() {
title("The envy of all other ORMs: MULTISET!")
val r = ctx
val r: Result<Record3<
String?,
Result<Record2<String?, LocalDateTime?>>,
Result<Record1<String?>>
>> = ctx
.select(
FILM.TITLE,
multiset(
select(
FILM_ACTOR.actor.FIRST_NAME,
FILM_ACTOR.actor.LAST_NAME
FILM_ACTOR.actor.LAST_UPDATE
)
.from(FILM_ACTOR)
.where(FILM_ACTOR.FILM_ID.eq(FILM.FILM_ID))
Expand Down

0 comments on commit 94db77c

Please sign in to comment.