diff --git a/.circleci/config.yml b/.circleci/config.yml index 99f982bcd0..33f396db42 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -144,7 +144,7 @@ jobs: - run: name: 'Build and test examples' command: | - ./mvnw -ntp -B verify -Pexamples -rf :querydsl-examples + ./mvnw -ntp -B verify -Pexamples -rf :querydsl-examples -pl -:querydsl-example-hibernate-reactive-quarkus - save-test-results buildQuarkusExample: <<: *defaults @@ -226,7 +226,8 @@ jobs: - run: name: 'Test' command: | - ./mvnw -ntp -B package -Pci -Dgroups=com.querydsl.core.testutil.PostgreSQL + ./mvnw -ntp -B install -Pci -Dgroups=com.querydsl.core.testutil.PostgreSQL + ./mvnw -ntp -B verify -Pexamples -pl :querydsl-example-hibernate-reactive-quarkus - save-test-results testCUBRID: <<: *defaults diff --git a/querydsl-examples/pom.xml b/querydsl-examples/pom.xml index 0570ef0142..5e65482274 100644 --- a/querydsl-examples/pom.xml +++ b/querydsl-examples/pom.xml @@ -25,8 +25,13 @@ querydsl-example-kotlin-mongodb querydsl-example-r2dbc-sql-codegen + querydsl-example-hibernate-reactive-quarkus + + 3.14.1 + + @@ -112,4 +117,5 @@ + diff --git a/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/.dockerignore b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/.dockerignore new file mode 100644 index 0000000000..ab14769c34 --- /dev/null +++ b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/.dockerignore @@ -0,0 +1,5 @@ +* +!target/*-runner +!target/*-runner.jar +!target/lib/* +!target/quarkus-app/ diff --git a/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/.mvn/wrapper/maven-wrapper.jar b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000000..bf82ff01c6 Binary files /dev/null and b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/.mvn/wrapper/maven-wrapper.jar differ diff --git a/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/.mvn/wrapper/maven-wrapper.properties b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000000..dc3affce3d --- /dev/null +++ b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/pom.xml b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/pom.xml new file mode 100644 index 0000000000..a9d413ed31 --- /dev/null +++ b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/pom.xml @@ -0,0 +1,116 @@ + + + 4.0.0 + + + io.github.openfeign.querydsl + querydsl-examples + 7.0-SNAPSHOT + + + querydsl-example-hibernate-reactive-quarkus + Querydsl example - Hibernate reactive Quarkus + + + + + io.quarkus.platform + quarkus-bom + ${quarkus.version} + pom + import + + + + + + + io.github.openfeign.querydsl + querydsl-hibernate-reactive + ${project.version} + + + + io.quarkus + quarkus-hibernate-reactive + + + + io.quarkus + quarkus-reactive-pg-client + + + + + io.quarkus + quarkus-reactive-routes + + + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + io.github.openfeign.querydsl + querydsl-apt + ${project.version} + jpa + + + + + true + + + + io.github.openfeign.querydsl + querydsl-apt + ${project.version} + + + + + + + maven-surefire-plugin + + + org.jboss.logmanager.LogManager + ${maven.home} + + + + + + + io.quarkus.platform + quarkus-maven-plugin + ${quarkus.version} + + + + build + + + + + + + + diff --git a/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/main/java/com/querydsl/example/reactive/Fruit.java b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/main/java/com/querydsl/example/reactive/Fruit.java new file mode 100644 index 0000000000..a17f7605ff --- /dev/null +++ b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/main/java/com/querydsl/example/reactive/Fruit.java @@ -0,0 +1,55 @@ +package com.querydsl.example.reactive; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.SequenceGenerator; +import jakarta.persistence.Table; + +@Entity +@Table(name = "known_fruits") +@NamedQuery(name = Fruit.FIND_ALL, query = "SELECT f FROM Fruit f ORDER BY f.name") +public class Fruit { + public static final String FIND_ALL = "Fruits.findAll"; + + @Id + @SequenceGenerator( + name = "fruitsSequence", + sequenceName = "known_fruits_id_seq", + allocationSize = 1, + initialValue = 10) + @GeneratedValue(generator = "fruitsSequence") + private Integer id; + + @Column(length = 40, unique = true) + private String name; + + public Fruit() {} + + public Fruit(String name) { + this.name = name; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "Fruit{" + id + "," + name + '}'; + } +} diff --git a/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/main/java/com/querydsl/example/reactive/FruitsRoutes.java b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/main/java/com/querydsl/example/reactive/FruitsRoutes.java new file mode 100644 index 0000000000..d312f0d8e5 --- /dev/null +++ b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/main/java/com/querydsl/example/reactive/FruitsRoutes.java @@ -0,0 +1,109 @@ +package com.querydsl.example.reactive; + +import static io.quarkus.vertx.web.Route.HandlerType.FAILURE; +import static io.quarkus.vertx.web.Route.HttpMethod.DELETE; +import static io.quarkus.vertx.web.Route.HttpMethod.GET; +import static io.quarkus.vertx.web.Route.HttpMethod.POST; +import static io.quarkus.vertx.web.Route.HttpMethod.PUT; + +import com.querydsl.jpa.hibernate.MutinyQueryFactory; +import io.quarkus.vertx.web.Body; +import io.quarkus.vertx.web.Param; +import io.quarkus.vertx.web.Route; +import io.quarkus.vertx.web.RouteBase; +import io.smallrye.mutiny.Uni; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.web.RoutingContext; +import jakarta.inject.Inject; +import java.util.List; +import java.util.NoSuchElementException; +import org.hibernate.reactive.mutiny.Mutiny; +import org.jboss.logging.Logger; + +/** An example using Vert.x Web, Hibernate Reactive and Mutiny. */ +@RouteBase(path = "/fruits", produces = "application/json") +public class FruitsRoutes { + + private static final Logger LOGGER = Logger.getLogger(FruitsRoutes.class.getName()); + + private final Mutiny.SessionFactory sf; + private final MutinyQueryFactory qf; + + @Inject + public FruitsRoutes(Mutiny.SessionFactory sf) { + this.sf = sf; + qf = new MutinyQueryFactory(sf); + } + + private static final QFruit f = new QFruit("f"); + + @Route(methods = GET, path = "/") + public Uni> getAll() { + return qf.withQuery(query -> query.select(f).from(f).orderBy(f.name.asc()).fetch()); + } + + @Route(methods = GET, path = "/:id") + public Uni getSingle(@Param Integer id) { + return qf.withQuery(query -> query.select(f).from(f).where(f.id.eq(id)).fetchOne()); + } + + @Route(methods = POST, path = "/") + public Uni create(@Body Fruit fruit, HttpServerResponse response) { + if (fruit == null || fruit.getId() != null) { + return Uni.createFrom() + .failure(new IllegalArgumentException("Fruit id invalidly set on request.")); + } + return sf.withTransaction((session, tx) -> session.persist(fruit)) + .invoke(() -> response.setStatusCode(201)) + .replaceWith(fruit); + } + + @Route(methods = PUT, path = "/:id") + public Uni update(@Body Fruit fruit, @Param Integer id) { + if (fruit == null || fruit.getName() == null) { + return Uni.createFrom() + .failure(new IllegalArgumentException("Fruit name was not set on request.")); + } + return qf.withUpdate( + f, update -> update.where(f.id.eq(id)).set(f.name, fruit.getName()).execute()) + .onItem() + .ifNull() + .fail() + .flatMap(a -> qf.withSelectFrom(f, select -> select.where(f.id.eq(id)).fetchOne())); + } + + @Route(methods = DELETE, path = "/:id") + public Uni delete(@Param Integer id, HttpServerResponse response) { + return qf.withDelete(f, delete -> delete.where(f.id.eq(id)).execute()) + .invoke(() -> response.setStatusCode(204)) + .onItem() + .ifNull() + .fail(); + } + + @Route(path = "/*", type = FAILURE) + public void error(RoutingContext context) { + Throwable t = context.failure(); + if (t != null) { + LOGGER.error("Failed to handle request", t); + int status = context.statusCode(); + String chunk = ""; + if (t instanceof NoSuchElementException) { + status = 404; + } else if (t instanceof IllegalArgumentException) { + status = 422; + chunk = + new JsonObject() + .put("code", status) + .put("exceptionType", t.getClass().getName()) + .put("error", t.getMessage()) + .encode(); + } + context.response().setStatusCode(status).end(chunk); + } else { + // Continue with the default error handler + context.next(); + } + } +} diff --git a/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/main/resources/META-INF/resources/index.html b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/main/resources/META-INF/resources/index.html new file mode 100644 index 0000000000..75958e2ef2 --- /dev/null +++ b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/main/resources/META-INF/resources/index.html @@ -0,0 +1,149 @@ + + + + + CRUD Mission - Quarkus + + + + + + + + +
+

CRUD Mission - Quarkus

+

This application demonstrates how a Quarkus application implements a CRUD endpoint to manage fruits. + This management interface invokes the CRUD service endpoint, which interacts with a database using JPA and several other well known libraries. +

+

Behind the scenes, we have: +

    +
  • Hibernate Reactive taking care of all CRUD operations
  • +
  • Vert.x Web routing powering the REST API
  • +
  • ArC, a CDI based dependency injection framework
  • +
  • The Undertow webserver
  • +
  • Some magic bytecode generation plugged in the compiler...
  • +
+

+ +

Add/Edit a fruit

+
+
+
+
+ +
+ +

Fruit List

+
+
Name
+
+
+
{{ fruit.name }}
+ +
+
+ + + diff --git a/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/main/resources/application.properties b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/main/resources/application.properties new file mode 100644 index 0000000000..4860771344 --- /dev/null +++ b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/main/resources/application.properties @@ -0,0 +1,16 @@ +%prod.quarkus.datasource.db-kind=postgresql +%prod.quarkus.datasource.username=quarkus_test +%prod.quarkus.datasource.password=quarkus_test + +quarkus.hibernate-orm.database.generation=drop-and-create +quarkus.hibernate-orm.log.sql=true +quarkus.hibernate-orm.sql-load-script=import.sql + +# Reactive config +%prod.quarkus.datasource.reactive.url=vertx-reactive:postgresql://localhost/quarkus_test + +quarkus.datasource.devservices.enabled=false +%test.quarkus.datasource.db-kind=postgresql +%test.quarkus.datasource.username=querydsl +%test.quarkus.datasource.password=querydsl +%test.quarkus.datasource.reactive.url=vertx-reactive:postgresql://localhost/querydsl diff --git a/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/main/resources/import.sql b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/main/resources/import.sql new file mode 100644 index 0000000000..a64afab059 --- /dev/null +++ b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/main/resources/import.sql @@ -0,0 +1,4 @@ +INSERT INTO known_fruits(id, name) VALUES (1, 'Cherry'); +INSERT INTO known_fruits(id, name) VALUES (2, 'Apple'); +INSERT INTO known_fruits(id, name) VALUES (3, 'Banana'); +ALTER SEQUENCE known_fruits_id_seq RESTART WITH 4; diff --git a/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/test/java/com/querydsl/example/reactive/FruitsEndpointIT.java b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/test/java/com/querydsl/example/reactive/FruitsEndpointIT.java new file mode 100644 index 0000000000..e7eec3b34e --- /dev/null +++ b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/test/java/com/querydsl/example/reactive/FruitsEndpointIT.java @@ -0,0 +1,10 @@ +package com.querydsl.example.reactive; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +public class FruitsEndpointIT extends FruitsEndpointTest { + + // Runs the same tests as the parent class + +} diff --git a/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/test/java/com/querydsl/example/reactive/FruitsEndpointTest.java b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/test/java/com/querydsl/example/reactive/FruitsEndpointTest.java new file mode 100644 index 0000000000..6b021089ff --- /dev/null +++ b/querydsl-examples/querydsl-example-hibernate-reactive-quarkus/src/test/java/com/querydsl/example/reactive/FruitsEndpointTest.java @@ -0,0 +1,78 @@ +package com.querydsl.example.reactive; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.core.IsNot.not; + +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Test; + +@QuarkusTest +public class FruitsEndpointTest { + + @Test + public void testListAllFruits() { + // List all, should have all 3 fruits the database has initially: + given() + .when() + .get("/fruits/") + .then() + .statusCode(200) + .body(containsString("Cherry"), containsString("Apple"), containsString("Banana")); + + // Update Cherry to Pineapple + given() + .when() + .body("{\"name\" : \"Pineapple\"}") + .contentType("application/json") + .put("/fruits/1") + .then() + .statusCode(200) + .body(containsString("\"id\":"), containsString("\"name\":\"Pineapple\"")); + + // List all, Pineapple should've replaced Cherry: + given() + .when() + .get("/fruits/") + .then() + .statusCode(200) + .body( + not(containsString("Cherry")), + containsString("Pineapple"), + containsString("Apple"), + containsString("Banana")); + + // Delete Pineapple: + given().when().delete("/fruits/1").then().statusCode(204); + + // List all, Pineapple should be missing now: + given() + .when() + .get("/fruits/") + .then() + .statusCode(200) + .body(not(containsString("Pineapple")), containsString("Apple"), containsString("Banana")); + + // Create the Pear: + given() + .when() + .body("{\"name\" : \"Pear\"}") + .contentType("application/json") + .post("/fruits/") + .then() + .statusCode(201) + .body(containsString("\"id\":"), containsString("\"name\":\"Pear\"")); + + // List all, Pineapple should be still missing now: + given() + .when() + .get("/fruits/") + .then() + .statusCode(200) + .body( + not(containsString("Pineapple")), + containsString("Apple"), + containsString("Banana"), + containsString("Pear")); + } +} diff --git a/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml b/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml index b6c5e0b056..09ee682514 100644 --- a/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml +++ b/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml @@ -11,10 +11,6 @@ querydsl-example-jpa-quarkus Querydsl example - JPA Quarkus - - 3.17.4 - - diff --git a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/main/java/com/querydsl/example/dao/OrderDaoImpl.java b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/main/java/com/querydsl/example/dao/OrderDaoImpl.java index e073f347bf..e191d86805 100644 --- a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/main/java/com/querydsl/example/dao/OrderDaoImpl.java +++ b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/main/java/com/querydsl/example/dao/OrderDaoImpl.java @@ -5,7 +5,7 @@ import static com.querydsl.example.r2dbc.QCustomerOrderProduct.customerOrderProduct; import static com.querydsl.example.r2dbc.QCustomerPaymentMethod.customerPaymentMethod; -import com.querydsl.core.dml.ReactiveStoreClause; +import com.querydsl.core.dml.StoreClause; import com.querydsl.core.group.GroupBy; import com.querydsl.core.types.Predicate; import com.querydsl.core.types.QBean; @@ -53,7 +53,7 @@ public Flux findAll(Predicate... where) { return getBaseQuery(where); } - private > T populate(T dml, Order o) { + private > T populate(T dml, Order o) { return dml.set(customerOrder.customerPaymentMethodId, o.getCustomerPaymentMethod().getId()) .set(customerOrder.orderPlacedDate, o.getOrderPlacedDate()) .set(customerOrder.totalOrderPrice, o.getTotalOrderPrice()); @@ -99,28 +99,26 @@ public Mono update(Order o) { .where(customerOrder.id.eq(id)) .execute() .flatMap( - __ -> { - // delete orderproduct rows - return queryFactory - .delete(customerOrderProduct) - .where(customerOrderProduct.orderId.eq(id)) - .execute() - .flatMap( - ___ -> { - return Flux.fromIterable(o.getOrderProducts()) - .map( - op -> - queryFactory - .insert(customerOrderProduct) - .set(customerOrderProduct.orderId, id) - .set(customerOrderProduct.comments, op.getComments()) - .set(customerOrderProduct.productId, op.getProductId()) - .set(customerOrderProduct.quantity, op.getQuantity()) - .execute()) - .collectList() - .map(____ -> o); - }); - }); + __ -> + queryFactory + .delete(customerOrderProduct) + .where(customerOrderProduct.orderId.eq(id)) + .execute() + .flatMap( + ___ -> { + return Flux.fromIterable(o.getOrderProducts()) + .map( + op -> + queryFactory + .insert(customerOrderProduct) + .set(customerOrderProduct.orderId, id) + .set(customerOrderProduct.comments, op.getComments()) + .set(customerOrderProduct.productId, op.getProductId()) + .set(customerOrderProduct.quantity, op.getQuantity()) + .execute()) + .collectList() + .map(____ -> o); + })); } @Override diff --git a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/main/java/com/querydsl/example/dao/ProductDaoImpl.java b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/main/java/com/querydsl/example/dao/ProductDaoImpl.java index 40f9bc77a9..7f00ed3b31 100644 --- a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/main/java/com/querydsl/example/dao/ProductDaoImpl.java +++ b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/src/main/java/com/querydsl/example/dao/ProductDaoImpl.java @@ -5,7 +5,7 @@ import static com.querydsl.example.r2dbc.QProductL10n.productL10n; import static com.querydsl.example.r2dbc.QSupplier.supplier; -import com.querydsl.core.dml.ReactiveStoreClause; +import com.querydsl.core.dml.StoreClause; import com.querydsl.core.group.GroupBy; import com.querydsl.core.types.Predicate; import com.querydsl.core.types.QBean; @@ -47,7 +47,7 @@ public Flux findAll(Predicate... where) { return getBaseQuery(where); } - private > T populate(T dml, Product p) { + private > T populate(T dml, Product p) { return dml.set(product.name, p.getName()) .set(product.otherProductDetails, p.getOtherProductDetails()) .set(product.price, p.getPrice()) @@ -98,34 +98,32 @@ public Mono update(Product p) { .where(product.id.eq(id)) .execute() .flatMap( - __ -> { - // delete l10n rows - return queryFactory - .delete(productL10n) - .where(productL10n.productId.eq(id)) - .execute() - .flatMapIterable( - ___ -> { - var insert = queryFactory.insert(productL10n); - return p.getLocalizations().stream() - .map( - l10n -> - insert - .set(productL10n.productId, id) - .set(productL10n.description, l10n.getDescription()) - .set(productL10n.lang, l10n.getLang()) - .set(productL10n.name, l10n.getName()) - .execute()) - .map( - ____ -> { - p.setId(id); - - return p; - }) - .toList(); - }) - .reduce((a, b) -> a); - }); + __ -> + queryFactory + .delete(productL10n) + .where(productL10n.productId.eq(id)) + .execute() + .flatMapIterable( + ___ -> { + var insert = queryFactory.insert(productL10n); + return p.getLocalizations().stream() + .map( + l10n -> + insert + .set(productL10n.productId, id) + .set(productL10n.description, l10n.getDescription()) + .set(productL10n.lang, l10n.getLang()) + .set(productL10n.name, l10n.getName()) + .execute()) + .map( + ____ -> { + p.setId(id); + + return p; + }) + .toList(); + }) + .reduce((a, b) -> a)); } @Override diff --git a/querydsl-libraries/pom.xml b/querydsl-libraries/pom.xml index 9fa800af9f..72bd4434a3 100644 --- a/querydsl-libraries/pom.xml +++ b/querydsl-libraries/pom.xml @@ -30,6 +30,9 @@ querydsl-jpa querydsl-jpa-spring + + querydsl-hibernate-reactive + querydsl-mongodb diff --git a/querydsl-libraries/querydsl-core/pom.xml b/querydsl-libraries/querydsl-core/pom.xml index b4bcb6dd34..4f702dc9bd 100644 --- a/querydsl-libraries/querydsl-core/pom.xml +++ b/querydsl-libraries/querydsl-core/pom.xml @@ -27,6 +27,12 @@ io.projectreactor reactor-core + + io.smallrye.reactive + mutiny + 2.6.0 + true + diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/CloseableIterator.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/CloseableIterator.java index bb96f837dc..10ad5e0461 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/CloseableIterator.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/CloseableIterator.java @@ -21,6 +21,9 @@ public static List asList(CloseableIterator iterator) { } public static CloseableIterator of(Iterator iterator) { + if (iterator instanceof AutoCloseable closeable) { + return of(iterator, closeable); + } return of(iterator, () -> {}); } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/InsertClause.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/InsertClause.java index ca368e888c..850d5d59cd 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/InsertClause.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/InsertClause.java @@ -22,7 +22,7 @@ * @author tiwe * @param concrete subtype */ -public interface InsertClause> extends StoreClause { +public interface InsertClause> extends StoreClause, DMLClause { /** * Define the columns to be populated diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveFilteredClause.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveFilteredClause.java deleted file mode 100644 index a813873833..0000000000 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveFilteredClause.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.querydsl.core.dml; - -import com.querydsl.core.types.Predicate; - -/** - * {@code ReactiveFilteredClause} is an interface for clauses with a filter condition - * - * @param concrete subtype - */ -public interface ReactiveFilteredClause> { - - /** - * Adds the given filter conditions - * - *

Skips null arguments - * - * @param o filter conditions to be added - * @return the current object - */ - C where(Predicate... o); -} diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveStoreClause.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveStoreClause.java deleted file mode 100644 index 8143e38870..0000000000 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveStoreClause.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.querydsl.core.dml; - -import com.querydsl.core.types.Expression; -import com.querydsl.core.types.Path; -import org.jetbrains.annotations.Nullable; - -/** - * Parent interface for {@link ReactiveInsertClause} and {@link ReactiveUpdateClause} - * - * @param concrete subtype - */ -public interface ReactiveStoreClause> - extends ReactiveDMLClause { - - /** - * Add a value binding - * - * @param - * @param path path to be updated - * @param value value to set - * @return the current object - */ - C set(Path path, @Nullable T value); - - /** - * Add an expression binding - * - * @param - * @param path path to be updated - * @param expression binding - * @return the current object - */ - C set(Path path, Expression expression); - - /** - * Bind the given path to null - * - * @param path path to be updated - * @return the current object - */ - C setNull(Path path); - - /** - * Returns true, if no bindings have been set, otherwise false. - * - * @return true, if empty, false, if not - */ - boolean isEmpty(); -} diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/StoreClause.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/StoreClause.java index 21929b8b93..a3e0a241d4 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/StoreClause.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/StoreClause.java @@ -23,7 +23,7 @@ * @author tiwe * @param concrete subtype */ -public interface StoreClause> extends DMLClause { +public interface StoreClause> { /** * Add a value binding diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/UpdateClause.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/UpdateClause.java index f7a6611368..d9b7b3603e 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/UpdateClause.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/UpdateClause.java @@ -23,7 +23,8 @@ * @author tiwe * @param concrete subtype */ -public interface UpdateClause> extends StoreClause, FilteredClause { +public interface UpdateClause> + extends StoreClause, FilteredClause, DMLClause { /** * Set the paths to be updated diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyDMLClause.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyDMLClause.java new file mode 100644 index 0000000000..736d371949 --- /dev/null +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyDMLClause.java @@ -0,0 +1,18 @@ +package com.querydsl.core.dml.mutiny; + +import io.smallrye.mutiny.Uni; + +/** + * Parent interface for DML clauses + * + * @param concrete subtype + */ +public interface MutinyDMLClause> { + + /** + * Execute the clause and return the amount of affected rows + * + * @return amount of affected rows or empty if not available + */ + Uni execute(); +} diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyDeleteClause.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyDeleteClause.java new file mode 100644 index 0000000000..1c2c2878f7 --- /dev/null +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyDeleteClause.java @@ -0,0 +1,11 @@ +package com.querydsl.core.dml.mutiny; + +import com.querydsl.core.FilteredClause; + +/** + * {@code ReactiveDeleteClause} defines a generic interface for Delete clauses + * + * @param concrete subtype + */ +public interface MutinyDeleteClause> + extends MutinyDMLClause, FilteredClause {} diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyFetchable.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyFetchable.java new file mode 100644 index 0000000000..c0e76c2be2 --- /dev/null +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyFetchable.java @@ -0,0 +1,42 @@ +package com.querydsl.core.dml.mutiny; + +import com.querydsl.core.Query; +import io.smallrye.mutiny.Uni; +import java.util.List; + +/** + * {@code MutinyFetchable} defines default projection methods for {@link Query} implementations. All + * Querydsl query implementations should implement this interface. + * + * @param result type + */ +public interface MutinyFetchable { + + /** + * Get the projection as a typed Flux. + * + * @return result + */ + Uni> fetch(); + + /** + * Get the first result of the projection. + * + * @return first result + */ + Uni fetchFirst(); + + /** + * Get the projection as a unique result. + * + * @return first result + */ + Uni fetchOne(); + + /** + * Get the count of matched elements + * + * @return row count + */ + Uni fetchCount(); +} diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyFetchableQuery.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyFetchableQuery.java new file mode 100644 index 0000000000..772d8fc25f --- /dev/null +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyFetchableQuery.java @@ -0,0 +1,45 @@ +package com.querydsl.core.dml.mutiny; + +import com.querydsl.core.ResultTransformer; +import com.querydsl.core.SimpleQuery; +import com.querydsl.core.Tuple; +import com.querydsl.core.types.Expression; +import org.reactivestreams.Publisher; + +/** + * {@code FetchableQuery} extends {@link MutinyFetchable} and {@link SimpleQuery} with projection + * changing methods and result aggregation functionality using {@link ResultTransformer} instances. + * + * @param element type + * @param concrete subtype + */ +public interface MutinyFetchableQuery> + extends SimpleQuery, MutinyFetchable { + + /** + * Change the projection of this query + * + * @param + * @param expr new projection + * @return the current object + */ + MutinyFetchableQuery select(Expression expr); + + /** + * Change the projection of this query + * + * @param exprs new projection + * @return the current object + */ + MutinyFetchableQuery select(Expression... exprs); + + /** + * Apply the given transformer to this {@code ReactiveFetchableQuery} instance and return the + * results + * + * @param + * @param transformer result transformer + * @return transformed result + */ + Publisher transform(MutinyResultTransformer transformer); +} diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyFetchableQueryBase.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyFetchableQueryBase.java new file mode 100644 index 0000000000..7e60649e67 --- /dev/null +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyFetchableQueryBase.java @@ -0,0 +1,36 @@ +package com.querydsl.core.dml.mutiny; + +import com.querydsl.core.support.QueryBase; +import com.querydsl.core.support.QueryMixin; +import com.querydsl.core.types.SubQueryExpression; +import org.reactivestreams.Publisher; + +/** + * {@code FetchableQueryBase} extends the {@link QueryBase} class to provide default implementations + * of the methods of the {@link com.querydsl.core.dml.reactive.ReactiveFetchable} interface + * + * @param result type + * @param concrete subtype + */ +public abstract class MutinyFetchableQueryBase> + extends QueryBase implements MutinyFetchable { + + public MutinyFetchableQueryBase(QueryMixin queryMixin) { + super(queryMixin); + } + + public Publisher transform(MutinyResultTransformer transformer) { + return transformer.transform((MutinyFetchableQuery) this); + } + + @Override + public final boolean equals(Object o) { + if (o == this) { + return true; + } else if (o instanceof SubQueryExpression s) { + return s.getMetadata().equals(queryMixin.getMetadata()); + } else { + return false; + } + } +} diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyFetchableSubQueryBase.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyFetchableSubQueryBase.java new file mode 100644 index 0000000000..f9bc6a92a9 --- /dev/null +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyFetchableSubQueryBase.java @@ -0,0 +1,166 @@ +package com.querydsl.core.dml.mutiny; + +import com.querydsl.core.QueryMetadata; +import com.querydsl.core.support.ExtendedSubQuery; +import com.querydsl.core.support.FetchableQueryBase; +import com.querydsl.core.support.QueryMixin; +import com.querydsl.core.types.ConstantImpl; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.Ops; +import com.querydsl.core.types.SubQueryExpression; +import com.querydsl.core.types.SubQueryExpressionImpl; +import com.querydsl.core.types.Visitor; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.core.types.dsl.BooleanOperation; +import com.querydsl.core.types.dsl.Expressions; +import java.util.Arrays; +import java.util.Collection; + +/** + * {@code FetchableSubQueryBase} extends {@link FetchableQueryBase} to provide fluent Expression + * creation functionality + * + * @param + * @param + */ +public abstract class MutinyFetchableSubQueryBase> + extends MutinyFetchableQueryBase implements ExtendedSubQuery { + + private final SubQueryExpression mixin; + + @SuppressWarnings("unchecked") + public MutinyFetchableSubQueryBase(QueryMixin queryMixin) { + super(queryMixin); + mixin = new SubQueryExpressionImpl((Class) Object.class, queryMixin.getMetadata()); + } + + @Override + public BooleanExpression contains(Expression right) { + return Expressions.predicate(Ops.IN, right, this); + } + + @Override + public BooleanExpression contains(T constant) { + return contains(Expressions.constant(constant)); + } + + @Override + public BooleanExpression exists() { + var metadata = getMetadata(); + if (metadata.getProjection() == null) { + queryMixin.setProjection(Expressions.ONE); + } + return Expressions.predicate(Ops.EXISTS, this); + } + + @Override + public BooleanExpression eq(Expression expr) { + return Expressions.predicate(Ops.EQ, this, expr); + } + + @Override + public BooleanExpression eq(T constant) { + return eq(Expressions.constant(constant)); + } + + @Override + public BooleanExpression ne(Expression expr) { + return Expressions.predicate(Ops.NE, this, expr); + } + + @Override + public BooleanExpression ne(T constant) { + return ne(Expressions.constant(constant)); + } + + @Override + public BooleanExpression notExists() { + return exists().not(); + } + + @Override + public BooleanExpression lt(Expression expr) { + return Expressions.predicate(Ops.LT, this, expr); + } + + @Override + public BooleanExpression lt(T constant) { + return lt(Expressions.constant(constant)); + } + + @Override + public BooleanExpression gt(Expression expr) { + return Expressions.predicate(Ops.GT, this, expr); + } + + @Override + public BooleanExpression gt(T constant) { + return gt(Expressions.constant(constant)); + } + + @Override + public BooleanExpression loe(Expression expr) { + return Expressions.predicate(Ops.LOE, this, expr); + } + + @Override + public BooleanExpression loe(T constant) { + return loe(Expressions.constant(constant)); + } + + @Override + public BooleanExpression goe(Expression expr) { + return Expressions.predicate(Ops.GOE, this, expr); + } + + @Override + public BooleanExpression goe(T constant) { + return goe(Expressions.constant(constant)); + } + + @Override + public BooleanOperation isNull() { + return Expressions.booleanOperation(Ops.IS_NULL, mixin); + } + + @Override + public BooleanOperation isNotNull() { + return Expressions.booleanOperation(Ops.IS_NOT_NULL, mixin); + } + + @Override + public final int hashCode() { + return mixin.hashCode(); + } + + @Override + public final QueryMetadata getMetadata() { + return queryMixin.getMetadata(); + } + + @Override + public R accept(Visitor v, C context) { + return mixin.accept(v, context); + } + + @SuppressWarnings("unchecked") + @Override + public Class getType() { + Expression projection = queryMixin.getMetadata().getProjection(); + return (Class) (projection != null ? projection.getType() : Void.class); + } + + @Override + public BooleanExpression in(Collection right) { + if (right.size() == 1) { + return eq(right.iterator().next()); + } else { + return Expressions.booleanOperation(Ops.IN, mixin, ConstantImpl.create(right)); + } + } + + @Override + public BooleanExpression in(T... right) { + return this.in(Arrays.asList(right)); + } +} diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyInsertClause.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyInsertClause.java new file mode 100644 index 0000000000..007135fedf --- /dev/null +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyInsertClause.java @@ -0,0 +1,38 @@ +package com.querydsl.core.dml.mutiny; + +import com.querydsl.core.dml.StoreClause; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.SubQueryExpression; + +/** + * {@code ReactiveInsertClause} defines a generic interface for Insert clauses + * + * @param concrete subtype + */ +public interface MutinyInsertClause> + extends StoreClause, MutinyDMLClause { + + /** + * Define the columns to be populated + * + * @param columns columns to be populated + * @return the current object + */ + C columns(Path... columns); + + /** + * Define the populate via subquery + * + * @param subQuery sub query to be used for population + * @return the current object + */ + C select(SubQueryExpression subQuery); + + /** + * Define the value bindings + * + * @param v values to be inserted + * @return the current object + */ + C values(Object... v); +} diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyResultTransformer.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyResultTransformer.java new file mode 100644 index 0000000000..4a05127e77 --- /dev/null +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyResultTransformer.java @@ -0,0 +1,35 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.core.dml.mutiny; + +import org.reactivestreams.Publisher; + +/** + * Executes query on a {@link MutinyFetchableQuery} and transforms results into T. This can be used + * for example to group projected columns or to filter out duplicate results. + * + * @param Transformations target type + * @author sasa + * @see com.querydsl.core.group.GroupBy + */ +public interface MutinyResultTransformer { + + /** + * Execute the given query and transform the results + * + * @param query query to be used for execution + * @return transformed results + */ + Publisher transform(MutinyFetchableQuery query); +} diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyUpdateClause.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyUpdateClause.java new file mode 100644 index 0000000000..1bd64c39e5 --- /dev/null +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/mutiny/MutinyUpdateClause.java @@ -0,0 +1,24 @@ +package com.querydsl.core.dml.mutiny; + +import com.querydsl.core.FilteredClause; +import com.querydsl.core.dml.StoreClause; +import com.querydsl.core.types.Path; +import java.util.List; + +/** + * {@code ReactiveUpdateClause} defines a generic extensible interface for Update clauses + * + * @param concrete subtype + */ +public interface MutinyUpdateClause> + extends StoreClause, FilteredClause, MutinyDMLClause { + + /** + * Set the paths to be updated + * + * @param paths paths to be updated + * @param values values to be set + * @return the current object + */ + C set(List> paths, List values); +} diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveDMLClause.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveDMLClause.java similarity index 89% rename from querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveDMLClause.java rename to querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveDMLClause.java index 4ffc0f7b08..5b35ed2257 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveDMLClause.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveDMLClause.java @@ -1,4 +1,4 @@ -package com.querydsl.core.dml; +package com.querydsl.core.dml.reactive; import reactor.core.publisher.Mono; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveDeleteClause.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveDeleteClause.java similarity index 58% rename from querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveDeleteClause.java rename to querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveDeleteClause.java index d0c4744273..7309deae11 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveDeleteClause.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveDeleteClause.java @@ -1,4 +1,6 @@ -package com.querydsl.core.dml; +package com.querydsl.core.dml.reactive; + +import com.querydsl.core.FilteredClause; /** * {@code ReactiveDeleteClause} defines a generic interface for Delete clauses @@ -6,4 +8,4 @@ * @param concrete subtype */ public interface ReactiveDeleteClause> - extends ReactiveDMLClause, ReactiveFilteredClause {} + extends ReactiveDMLClause, FilteredClause {} diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/ReactiveFetchable.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveFetchable.java similarity index 91% rename from querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/ReactiveFetchable.java rename to querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveFetchable.java index a328ec7f32..72e8cab12f 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/ReactiveFetchable.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveFetchable.java @@ -1,5 +1,6 @@ -package com.querydsl.core; +package com.querydsl.core.dml.reactive; +import com.querydsl.core.Query; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/ReactiveFetchableQuery.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveFetchableQuery.java similarity index 88% rename from querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/ReactiveFetchableQuery.java rename to querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveFetchableQuery.java index 4c96930458..b8e1d07611 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/ReactiveFetchableQuery.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveFetchableQuery.java @@ -1,5 +1,8 @@ -package com.querydsl.core; +package com.querydsl.core.dml.reactive; +import com.querydsl.core.ResultTransformer; +import com.querydsl.core.SimpleQuery; +import com.querydsl.core.Tuple; import com.querydsl.core.types.Expression; import org.reactivestreams.Publisher; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ReactiveFetchableQueryBase.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveFetchableQueryBase.java similarity index 81% rename from querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ReactiveFetchableQueryBase.java rename to querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveFetchableQueryBase.java index 0657a20470..00b19ea075 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ReactiveFetchableQueryBase.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveFetchableQueryBase.java @@ -1,15 +1,14 @@ -package com.querydsl.core.support; +package com.querydsl.core.dml.reactive; -import com.querydsl.core.ReactiveFetchable; -import com.querydsl.core.ReactiveFetchableQuery; -import com.querydsl.core.ReactiveResultTransformer; +import com.querydsl.core.support.QueryBase; +import com.querydsl.core.support.QueryMixin; import com.querydsl.core.types.SubQueryExpression; import org.reactivestreams.Publisher; import reactor.core.publisher.Mono; /** * {@code FetchableQueryBase} extends the {@link QueryBase} class to provide default implementations - * of the methods of the {@link com.querydsl.core.ReactiveFetchable} interface + * of the methods of the {@link com.querydsl.core.dml.reactive.ReactiveFetchable} interface * * @param result type * @param concrete subtype diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ReactiveFetchableSubQueryBase.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveFetchableSubQueryBase.java similarity index 95% rename from querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ReactiveFetchableSubQueryBase.java rename to querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveFetchableSubQueryBase.java index 0211b919d3..5e65147ae3 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ReactiveFetchableSubQueryBase.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveFetchableSubQueryBase.java @@ -1,6 +1,9 @@ -package com.querydsl.core.support; +package com.querydsl.core.dml.reactive; import com.querydsl.core.QueryMetadata; +import com.querydsl.core.support.ExtendedSubQuery; +import com.querydsl.core.support.FetchableQueryBase; +import com.querydsl.core.support.QueryMixin; import com.querydsl.core.types.ConstantImpl; import com.querydsl.core.types.Expression; import com.querydsl.core.types.Ops; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveInsertClause.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveInsertClause.java similarity index 85% rename from querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveInsertClause.java rename to querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveInsertClause.java index a379587bd3..8dc4d4d877 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveInsertClause.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveInsertClause.java @@ -1,5 +1,6 @@ -package com.querydsl.core.dml; +package com.querydsl.core.dml.reactive; +import com.querydsl.core.dml.StoreClause; import com.querydsl.core.types.Path; import com.querydsl.core.types.SubQueryExpression; @@ -9,7 +10,7 @@ * @param concrete subtype */ public interface ReactiveInsertClause> - extends ReactiveStoreClause { + extends StoreClause, ReactiveDMLClause { /** * Define the columns to be populated diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/ReactiveResultTransformer.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveResultTransformer.java similarity index 96% rename from querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/ReactiveResultTransformer.java rename to querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveResultTransformer.java index 0ddde5d905..a1c1ca8bcc 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/ReactiveResultTransformer.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveResultTransformer.java @@ -11,7 +11,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.querydsl.core; +package com.querydsl.core.dml.reactive; import org.reactivestreams.Publisher; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveUpdateClause.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveUpdateClause.java similarity index 71% rename from querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveUpdateClause.java rename to querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveUpdateClause.java index 76011b076e..28aeba6d6a 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/ReactiveUpdateClause.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/dml/reactive/ReactiveUpdateClause.java @@ -1,5 +1,7 @@ -package com.querydsl.core.dml; +package com.querydsl.core.dml.reactive; +import com.querydsl.core.FilteredClause; +import com.querydsl.core.dml.StoreClause; import com.querydsl.core.types.Path; import java.util.List; @@ -9,7 +11,7 @@ * @param concrete subtype */ public interface ReactiveUpdateClause> - extends ReactiveStoreClause, ReactiveFilteredClause { + extends StoreClause, FilteredClause, ReactiveDMLClause { /** * Set the paths to be updated diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java index 787cdb9dbd..226916c858 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java @@ -56,8 +56,7 @@ public class TemplateFactory { (\\d+)\ (?:([+-/*])(?:(\\d+)|'(-?\\d+(?:\\.\\d+)?)'))?\ ([slu%]?%?)\ - \\}\ - """); + \\}"""); private final Map cache = Collections.synchronizedMap(new WeakHashMap<>()); diff --git a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/ReactiveQueryExecution.java b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/ReactiveQueryExecution.java index 5abe60691c..d88cfa32c8 100644 --- a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/ReactiveQueryExecution.java +++ b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/ReactiveQueryExecution.java @@ -15,6 +15,8 @@ import static org.assertj.core.api.Assertions.fail; +import com.querydsl.core.dml.reactive.ReactiveFetchable; +import com.querydsl.core.dml.reactive.ReactiveFetchableQuery; import com.querydsl.core.support.QueryBase; import com.querydsl.core.types.CollectionExpression; import com.querydsl.core.types.Expression; diff --git a/querydsl-libraries/querydsl-hibernate-reactive/README.md b/querydsl-libraries/querydsl-hibernate-reactive/README.md new file mode 100644 index 0000000000..a5d6049732 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/README.md @@ -0,0 +1,76 @@ +## Querydsl JPA + +The JPA module provides integration with the JPA 2 persistence API. + +**Maven integration** + + Add the following dependencies to your Maven project : + +```XML + + io.github.openfeign.querydsl + querydsl-jpa + ${querydsl.version} + +``` + +And now, configure the Maven APT plugin : + +```XML + + + + ... + + com.mysema.maven + apt-maven-plugin + 1.1.3 + + + + process + + + target/generated-sources/java + com.querydsl.apt.jpa.JPAAnnotationProcessor + + + + + + io.github.openfeign.querydsl + querydsl-apt + ${querydsl.version} + + + + ... + + + +``` + +The JPAAnnotationProcessor finds domain types annotated with the jakarta.persistence.Entity annotation and generates query types for them. + +If you use Hibernate annotations in your domain types you should use the APT processor com.querydsl.apt.hibernate.HibernateAnnotationProcessor instead. + +Run clean install and you will get your Query types generated into target/generated-sources/java. + +If you use Eclipse, run mvn eclipse:eclipse to update your Eclipse project to include target/generated-sources/java as a source folder. + +Now you are able to construct JPQL query instances and instances of the query domain model. + +**Querying** + +Querying with Querydsl JPA is as simple as this : + +```JAVA +QCustomer customer = QCustomer.customer; +JPAQuery query = new JPAQuery(entityManager); +Customer bob = query.select(customer) + .from(customer) + .where(customer.firstName.eq("Bob")) + .fetchOne(); +``` + +For more information on the Querydsl JPA module visit the reference documentation http://www.querydsl.com/static/querydsl/latest/reference/html/ch02.html#jpa_integration diff --git a/querydsl-libraries/querydsl-hibernate-reactive/etc/features.txt b/querydsl-libraries/querydsl-hibernate-reactive/etc/features.txt new file mode 100644 index 0000000000..3255735ef4 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/etc/features.txt @@ -0,0 +1,39 @@ +* mathematical operators +, -, *, / + +* binary comparison operators =, >=, <=, <>, !=, like + +* logical operations and, or, not + +* Parentheses ( ), indicating grouping + +* in, not in, between, is null, is not null, is empty, is not empty, member of and not member of + +* "Simple" case, case ... when ... then ... else ... end, and "searched" case, case when ... then ... else ... end + +* string concatenation ...||... or concat(...,...) + +* current_date(), current_time(), current_timestamp() + +* second(...), minute(...), hour(...), day(...), month(...), year(...), + +* Any function or operator defined by EJB-QL 3.0: substring(), trim(), lower(), upper(), length(), locate(), abs(), sqrt(), bit_length(), mod() + +* coalesce() and nullif() + +* str() for converting numeric or temporal values to a readable string + +* cast(... as ...), where the second argument is the name of a Hibernate type, and extract(... from ...) if ANSI cast() and extract() is supported by the underlying database + +* the HQL index() function, that applies to aliases of a joined indexed collection + +* HQL functions that take collection-valued path expressions: size(), minelement(), maxelement(), minindex(), maxindex(), along with the special elements() and indices functions which may be quantified using some, all, exists, any, in. + +* Any database-supported SQL scalar function like sign(), trunc(), rtrim(), sin() + +* JDBC-style positional parameters ? + +* named parameters :name, :start_date, :x1 + +* SQL literals 'foo', 69, 6.66E+2, '1970-01-01 10:00:01.0' + +* Java public static final constants eg.Color.TABBY \ No newline at end of file diff --git a/querydsl-libraries/querydsl-hibernate-reactive/etc/precedence.txt b/querydsl-libraries/querydsl-hibernate-reactive/etc/precedence.txt new file mode 100644 index 0000000000..b857f7096a --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/etc/precedence.txt @@ -0,0 +1,40 @@ +BINARY, COLLATE +!, +NOT +- (unary minus), +~ (unary bit inversion) +^ +*, +/, +DIV, +%, +MOD +-, ++ +<<, +>> +& +| +=, +<=>, +>=, +>, +<=, +<, +<>, +!=, +IS, +LIKE, +REGEXP, +IN +BETWEEN, +CASE, +WHEN, +THEN, +ELSE +&&, +AND +||, +OR, +XOR +:= \ No newline at end of file diff --git a/querydsl-libraries/querydsl-hibernate-reactive/pom.xml b/querydsl-libraries/querydsl-hibernate-reactive/pom.xml new file mode 100644 index 0000000000..70d930a059 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/pom.xml @@ -0,0 +1,261 @@ + + + 4.0.0 + + + io.github.openfeign.querydsl + querydsl-libraries + 7.0-SNAPSHOT + + + querydsl-hibernate-reactive + Querydsl - Hibernate Reactive support + Hibernate reactive support for Querydsl + + + org.hibernate.reactive.*;version="[2.4.0.Final)",${osgi.import.package.root} + + + + + org.jetbrains + annotations + provided + + + + org.hibernate.reactive + hibernate-reactive-core + 2.4.0.Final + + + + io.github.openfeign.querydsl + querydsl-core + ${project.version} + + + io.github.openfeign.querydsl + querydsl-apt + ${project.version} + provided + + + + + org.postgresql + postgresql + ${postgresql.version} + test + + + org.slf4j + slf4j-simple + + + + + + commons-lang + commons-lang + 2.6 + test + + + + org.hsqldb + hsqldb + ${hsqldb.version} + test + + + + com.h2database + h2 + test + + + + org.apache.derby + derby + ${derby.version} + test + + + org.apache.derby + derbytools + ${derby.version} + test + + + mysql + mysql-connector-java + ${mysql.version} + test + + + com.microsoft.sqlserver + mssql-jdbc + ${mssql.version} + test + + + com.oracle.database.jdbc + ojdbc8 + ${oracle.version} + test + + + + io.github.openfeign.querydsl + querydsl-core + ${project.version} + test-jar + test + + + + io.github.classgraph + classgraph + test + + + + jdepend + jdepend + 2.9.1 + test + + + + jakarta.annotation + jakarta.annotation-api + provided + + + + + + + + org.apache.felix + maven-bundle-plugin + + + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + com.querydsl.jpa + + + + + + apt + + jar + + + apt + src/apt + + + + test-jar + + test-jar + + + + + + org.apache.maven.plugins + maven-source-plugin + + + + test-jar + + package + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + one-jars + + single + + package + + + src/main/assembly.xml + src/main/assembly-hibernate.xml + + ${project.build.directory} + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*Test.java + + + + derby.stream.error.file + target/derby.log + + + org.jboss.logging.provider + slf4j + + + + + + verification + + test + + verify + + + + version + ${project.version} + + + + com/querydsl/jpa/PackageVerification.java + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + com.querydsl.apt.hibernate.HibernateAnnotationProcessor + + + + + + + diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/apt-hibernate/META-INF/services/javax.annotation.processing.Processor b/querydsl-libraries/querydsl-hibernate-reactive/src/apt-hibernate/META-INF/services/javax.annotation.processing.Processor new file mode 100644 index 0000000000..bb12f8599e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/apt-hibernate/META-INF/services/javax.annotation.processing.Processor @@ -0,0 +1 @@ +com.querydsl.apt.hibernate.HibernateAnnotationProcessor \ No newline at end of file diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/apt/META-INF/services/javax.annotation.processing.Processor b/querydsl-libraries/querydsl-hibernate-reactive/src/apt/META-INF/services/javax.annotation.processing.Processor new file mode 100644 index 0000000000..720345c294 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/apt/META-INF/services/javax.annotation.processing.Processor @@ -0,0 +1 @@ +com.querydsl.apt.jpa.JPAAnnotationProcessor \ No newline at end of file diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/license/LICENSE.apache20.txt b/querydsl-libraries/querydsl-hibernate-reactive/src/license/LICENSE.apache20.txt new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/license/LICENSE.apache20.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/license/LICENSE.findbugs.txt b/querydsl-libraries/querydsl-hibernate-reactive/src/license/LICENSE.findbugs.txt new file mode 100644 index 0000000000..5ab7695ab8 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/license/LICENSE.findbugs.txt @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/license/LICENSE.querydsl.txt b/querydsl-libraries/querydsl-hibernate-reactive/src/license/LICENSE.querydsl.txt new file mode 100644 index 0000000000..5ab7695ab8 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/license/LICENSE.querydsl.txt @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/assembly-hibernate.xml b/querydsl-libraries/querydsl-hibernate-reactive/src/main/assembly-hibernate.xml new file mode 100644 index 0000000000..09fafacd2d --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/assembly-hibernate.xml @@ -0,0 +1,38 @@ + + apt-hibernate-one-jar + + jar + + false + + + src/apt-hibernate + / + + + src/license + /license + + + + + true + + io.github.openfeign.querydsl:querydsl-sql + io.github.openfeign.querydsl:querydsl-jpa + + + + true + provided + + io.github.openfeign.querydsl:* + com.querydsl.codegen.utils:* + org.hibernate.jpa:hibernate-core + + + + + diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/assembly.xml b/querydsl-libraries/querydsl-hibernate-reactive/src/main/assembly.xml new file mode 100644 index 0000000000..9285b96499 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/assembly.xml @@ -0,0 +1,44 @@ + + apt-one-jar + + jar + + false + + + src/apt + / + + **/* + + + + src/license + /license + + **/* + + + + + + true + + io.github.openfeign.querydsl:querydsl-sql + io.github.openfeign.querydsl:querydsl-jpa + + + + true + provided + + io.github.openfeign.querydsl:* + com.querydsl.codegen.utils:* + org.hibernate.jakarta.persistence:* + + + + + diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/Conversions.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/Conversions.java new file mode 100644 index 0000000000..f4f54fb965 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/Conversions.java @@ -0,0 +1,70 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.support.ConstantHidingExpression; +import com.querydsl.core.support.NumberConversion; +import com.querydsl.core.support.NumberConversions; +import com.querydsl.core.types.Constant; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.ExpressionUtils; +import com.querydsl.core.types.FactoryExpression; +import com.querydsl.core.types.Operation; +import com.querydsl.core.types.Ops; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.Expressions; + +/** + * {@code Conversions} provides module specific projection conversion functionality + * + * @author tiwe + */ +public final class Conversions { + + public static Expression convert(Expression expr) { + if (expr instanceof FactoryExpression) { + var factoryExpr = (FactoryExpression) expr; + for (Expression e : factoryExpr.getArgs()) { + if (needsConstantRemoval(e)) { + return convert(new ConstantHidingExpression<>(factoryExpr)); + } + } + for (Expression e : factoryExpr.getArgs()) { + if (needsNumberConversion(e)) { + return new NumberConversions<>(factoryExpr); + } + } + } else if (needsNumberConversion(expr)) { + return new NumberConversion<>(expr); + } + return expr; + } + + private static boolean needsConstantRemoval(Expression expr) { + expr = ExpressionUtils.extract(expr); + return expr instanceof Constant + || expr.equals(Expressions.TRUE) + || expr.equals(Expressions.FALSE) + || (expr instanceof Operation + && ((Operation) expr).getOperator() == Ops.ALIAS + && needsConstantRemoval(((Operation) expr).getArg(0))); + } + + private static boolean needsNumberConversion(Expression expr) { + expr = ExpressionUtils.extract(expr); + return Number.class.isAssignableFrom(expr.getType()) && !Path.class.isInstance(expr); + } + + private Conversions() {} +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/DataNucleusTemplates.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/DataNucleusTemplates.java new file mode 100644 index 0000000000..6f2f4daa0c --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/DataNucleusTemplates.java @@ -0,0 +1,42 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.types.Ops; + +/** + * {@code DataNucleusTemplates} extends {@link JPQLTemplates} with DataNucleus specific extensions + */ +public class DataNucleusTemplates extends JPQLTemplates { + + public static final DataNucleusTemplates DEFAULT = new DataNucleusTemplates(); + + public DataNucleusTemplates() { + this(DEFAULT_ESCAPE); + } + + public DataNucleusTemplates(char escape) { + super(escape); + add(Ops.LIKE, "{0} like {1}", 1); + add(Ops.MATCHES, "{0} like {1}", 27); // TODO : support real regexes + add(Ops.MATCHES_IC, "{0} like {1}", 27); // TODO : support real regexes + + add(Ops.STRING_CONTAINS, "{0} like {%1%}"); + add(Ops.STRING_CONTAINS_IC, "{0l} like {%%1%%}"); + add(Ops.ENDS_WITH, "{0} like {%1}"); + add(Ops.ENDS_WITH_IC, "{0l} like {%%1}"); + add(Ops.STARTS_WITH, "{0} like {1%}"); + add(Ops.STARTS_WITH_IC, "{0l} like {1%%}"); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/DefaultQueryHandler.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/DefaultQueryHandler.java new file mode 100644 index 0000000000..28ae1d81a8 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/DefaultQueryHandler.java @@ -0,0 +1,82 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.CloseableIterator; +import com.querydsl.core.types.FactoryExpression; +import jakarta.persistence.Query; +import java.util.Iterator; +import java.util.stream.Stream; +import org.jetbrains.annotations.Nullable; + +/** + * {@code DefaultQueryHandler} is the default implementation of the {@link QueryHandler} interface + * + * @author tiwe + */ +public final class DefaultQueryHandler implements QueryHandler { + + public static final QueryHandler DEFAULT = new DefaultQueryHandler(); + + @Override + public void addEntity(Query query, String alias, Class type) { + // do nothing + } + + @Override + public void addScalar(Query query, String alias, Class type) { + // do nothing + } + + @Override + public boolean createNativeQueryTyped() { + return true; + } + + @SuppressWarnings("unchecked") + @Override + public CloseableIterator iterate( + Query query, @Nullable final FactoryExpression projection) { + Iterator iterator = query.getResultList().iterator(); + if (projection != null) { + return new TransformingIterator<>(iterator, projection); + } else { + return CloseableIterator.of(iterator); + } + } + + @Override + public Stream stream(Query query, @Nullable FactoryExpression projection) { + final var resultStream = query.getResultStream(); + if (projection != null) { + return resultStream.map( + element -> + projection.newInstance( + (Object[]) (element.getClass().isArray() ? element : new Object[] {element}))); + } + return resultStream; + } + + @Override + public boolean transform(Query query, FactoryExpression projection) { + return false; + } + + @Override + public boolean wrapEntityProjections() { + return false; + } + + private DefaultQueryHandler() {} +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/FactoryExpressionTransformer.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/FactoryExpressionTransformer.java new file mode 100644 index 0000000000..5ad5742b27 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/FactoryExpressionTransformer.java @@ -0,0 +1,50 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.types.FactoryExpression; +import java.util.List; +import org.hibernate.transform.ResultTransformer; + +/** + * {@code FactoryExpressionTransformer} is a ResultTransformer implementation using + * FactoryExpression instances for transformation + * + * @author tiwe + */ +public final class FactoryExpressionTransformer implements ResultTransformer { + + private static final long serialVersionUID = -3625957233853100239L; + + private final transient FactoryExpression projection; + + public FactoryExpressionTransformer(FactoryExpression projection) { + this.projection = projection; + } + + @Override + public List transformList(List collection) { + return collection; + } + + @Override + public Object transformTuple(Object[] tuple, String[] aliases) { + if (projection.getArgs().size() < tuple.length) { + var shortened = new Object[projection.getArgs().size()]; + System.arraycopy(tuple, 0, shortened, 0, shortened.length); + tuple = shortened; + } + return projection.newInstance(tuple); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/HQLTemplates.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/HQLTemplates.java new file mode 100644 index 0000000000..81857ac070 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/HQLTemplates.java @@ -0,0 +1,119 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.types.Operator; +import com.querydsl.core.types.Ops; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * HQLTemplates extends {@link JPQLTemplates} with Hibernate specific extensions + * + * @author tiwe + */ +public class HQLTemplates extends JPQLTemplates { + + private static final QueryHandler QUERY_HANDLER; + + static { + QueryHandler instance; + try { + instance = (QueryHandler) Class.forName("com.querydsl.jpa.HibernateHandler").newInstance(); + } catch (NoClassDefFoundError | Exception e) { + instance = DefaultQueryHandler.DEFAULT; + } + QUERY_HANDLER = instance; + } + + private static final List wrapElements = + Arrays.asList( + Ops.QuantOps.ALL, Ops.QuantOps.ANY, Ops.QuantOps.AVG_IN_COL, Ops.EXISTS); + + public static final HQLTemplates DEFAULT = new HQLTemplates(); + + private final Map, String> typeNames; + + public HQLTemplates() { + this(DEFAULT_ESCAPE); + } + + @SuppressWarnings("unchecked") + public HQLTemplates(char escape) { + super(escape, QUERY_HANDLER); + + Map, String> builder = new HashMap<>(); + builder.put(Byte.class, "byte"); + builder.put(Short.class, "short"); + builder.put(Integer.class, "integer"); + builder.put(Long.class, "long"); + builder.put(BigInteger.class, "big_integer"); + builder.put(Float.class, "float"); + builder.put(Double.class, "double"); + builder.put(BigDecimal.class, "big_decimal"); + typeNames = Collections.unmodifiableMap(builder); + + // add Hibernate Spatial mappings, if on classpath + try { + Class cl = Class.forName("com.querydsl.spatial.hibernate.HibernateSpatialSupport"); + add((Map) cl.getMethod("getSpatialOps").invoke(null)); + } catch (Exception e) { + // do nothing + } + } + + @Override + public boolean wrapElements(Operator operator) { + // For example: JPaIntegration.docoExamples98_12 + return wrapElements.contains(operator); + } + + @Override + public String getTypeForCast(Class cl) { + var typeName = typeNames.get(cl); + if (typeName == null) { + return super.getTypeForCast(cl); + } + return typeName; + } + + @Override + public String getExistsProjection() { + // TODO Required / supported just for Hibernate? + return "1"; + } + + @Override + public boolean wrapConstant(Object constant) { + // related : https://hibernate.onjira.com/browse/HHH-6913 + Class type = constant.getClass(); + return type.isArray() || Collection.class.isAssignableFrom(type); + } + + @Override + public boolean isWithForOn() { + return true; + } + + @Override + public boolean isCaseWithLiterals() { + return true; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/Hibernate5Templates.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/Hibernate5Templates.java new file mode 100644 index 0000000000..e3664b6172 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/Hibernate5Templates.java @@ -0,0 +1,30 @@ +package com.querydsl.jpa; + +/** + * Hibernate5Templates extends {@link JPQLTemplates} with Hibernate specific extensions + * + * @author Jan-Willem Gmelig Meyling + */ +public class Hibernate5Templates extends HQLTemplates { + + public static final Hibernate5Templates DEFAULT = new Hibernate5Templates(); + + public Hibernate5Templates() {} + + public Hibernate5Templates(char escape) { + super(escape); + } + + @Override + public boolean wrapConstant(Object constant) { + // HHH-6913 is fixed in 5.0, default to JPA behaviour + return false; + } + + @Override + public boolean isWithForOn() { + // Hibernate supports the on-clause since 5.0, and the ON clause is actually mandatory for + // entity joins + return true; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/HibernateHandler.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/HibernateHandler.java new file mode 100644 index 0000000000..c014f9599e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/HibernateHandler.java @@ -0,0 +1,98 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.CloseableIterator; +import com.querydsl.core.types.FactoryExpression; +import jakarta.persistence.PersistenceException; +import jakarta.persistence.Query; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Stream; +import org.hibernate.query.NativeQuery; +import org.hibernate.transform.ResultTransformer; +import org.jetbrains.annotations.Nullable; + +/** + * {@code HibernateHandler} is the {@link QueryHandler} implementation for Hibernate + * + * @author tiwe + */ +public class HibernateHandler implements QueryHandler { + + @Override + public void addEntity(Query query, String alias, Class type) { + query.unwrap(NativeQuery.class).addEntity(alias, type); + } + + @Override + public void addScalar(Query query, String alias, Class type) { + query.unwrap(NativeQuery.class).addScalar(alias); + } + + @Override + public boolean createNativeQueryTyped() { + return false; + } + + @SuppressWarnings("unchecked") + @Override + public CloseableIterator iterate(Query query, FactoryExpression projection) { + try { + org.hibernate.query.Query unwrappedQuery = query.unwrap(org.hibernate.query.Query.class); + CloseableIterator iterator = + new ScrollableResultsIterator<>((List) unwrappedQuery.getResultList()); + if (projection != null) { + iterator = new TransformingIterator<>(iterator, projection); + } + return iterator; + } catch (PersistenceException e) { + Iterator iterator = query.getResultList().iterator(); + if (projection != null) { + return new TransformingIterator<>(iterator, projection); + } else { + return CloseableIterator.of(iterator); + } + } + } + + @Override + @SuppressWarnings({"unchecked", "rawtypes"}) + public Stream stream(Query query, @Nullable FactoryExpression projection) { + final var resultStream = query.getResultStream(); + if (projection != null) { + return resultStream.map( + element -> + projection.newInstance( + (Object[]) (element.getClass().isArray() ? element : new Object[] {element}))); + } + return resultStream; + } + + @Override + public boolean transform(Query query, FactoryExpression projection) { + try { + ResultTransformer transformer = new FactoryExpressionTransformer(projection); + query.unwrap(org.hibernate.query.Query.class).setResultTransformer(transformer); + return true; + } catch (PersistenceException e) { + return false; + } + } + + @Override + public boolean wrapEntityProjections() { + return true; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPACollectionAnyVisitor.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPACollectionAnyVisitor.java new file mode 100644 index 0000000000..0ffab7b5da --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPACollectionAnyVisitor.java @@ -0,0 +1,80 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.JoinType; +import com.querydsl.core.QueryMetadata; +import com.querydsl.core.support.CollectionAnyVisitor; +import com.querydsl.core.support.Context; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.ExpressionUtils; +import com.querydsl.core.types.Ops; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadataFactory; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.SubQueryExpressionImpl; +import com.querydsl.core.types.dsl.EntityPathBase; +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.core.types.dsl.SimplePath; +import jakarta.persistence.Entity; + +/** + * {@code JPACollectionAnyVisitor} extends the {@link CollectionAnyVisitor} class with module + * specific extensions + * + * @author tiwe + */ +class JPACollectionAnyVisitor extends CollectionAnyVisitor { + + @SuppressWarnings("unchecked") + @Override + protected Predicate exists(Context c, Predicate condition) { + JPAQueryMixin query = new JPAQueryMixin<>(); + query.setProjection(Expressions.ONE); + for (var i = 0; i < c.paths.size(); i++) { + Path child = c.paths.get(i).getMetadata().getParent(); + var replacement = (EntityPath) c.replacements.get(i); + if (c.paths.get(i).getType().isAnnotationPresent(Entity.class)) { + query.addJoin( + i == 0 ? JoinType.DEFAULT : JoinType.INNERJOIN, + Expressions.as( + Expressions.listPath( + (Class) c.paths.get(i).getType(), SimplePath.class, child.getMetadata()), + replacement)); + } else { + // join via parent + Path parent = child.getMetadata().getParent(); + var newParent = + new EntityPathBase( + parent.getType(), + ExpressionUtils.createRootVariable(parent, Math.abs(condition.hashCode()))); + var newChild = + new EntityPathBase( + child.getType(), + PathMetadataFactory.forProperty(newParent, child.getMetadata().getName())); + query.from(newParent); + query.addJoin(JoinType.INNERJOIN, Expressions.as(newChild, replacement)); + query.where(ExpressionUtils.eq(newParent, parent)); + } + } + c.clear(); + query.where(condition); + return ExpressionUtils.predicate(Ops.EXISTS, asExpression(query.getMetadata())); + } + + private Expression asExpression(QueryMetadata metadata) { + return new SubQueryExpressionImpl(metadata.getProjection().getType(), metadata); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPAExpressions.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPAExpressions.java new file mode 100644 index 0000000000..fe42f09929 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPAExpressions.java @@ -0,0 +1,203 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.Tuple; +import com.querydsl.core.types.CollectionExpression; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.ExpressionException; +import com.querydsl.core.types.Ops; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.PathType; +import com.querydsl.core.types.dsl.BeanPath; +import com.querydsl.core.types.dsl.ComparableExpression; +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.core.types.dsl.StringExpression; +import jakarta.persistence.Entity; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.ParameterizedType; + +/** + * {@code JPAExpressions} provides factory methods for JPQL specific operations elements. + * + * @author tiwe + */ +@SuppressWarnings("unchecked") +public final class JPAExpressions { + + /** + * Create a new detached JPQLQuery instance with the given projection + * + * @param expr projection + * @param + * @return select(expr) + */ + public static JPQLSubQuery select(Expression expr) { + return new JPASubQuery().select(expr); + } + + /** + * Create a new detached JPQLQuery instance with the given projection + * + * @param exprs projection + * @return select(exprs) + */ + public static JPQLSubQuery select(Expression... exprs) { + return new JPASubQuery().select(exprs); + } + + /** + * Create a new detached JPQLQuery instance with the given projection + * + * @param expr projection + * @param + * @return select(distinct expr) + */ + public static JPQLSubQuery selectDistinct(Expression expr) { + return new JPASubQuery().select(expr).distinct(); + } + + /** + * Create a new detached JPQLQuery instance with the given projection + * + * @param exprs projection + * @return select(distinct expr) + */ + public static JPQLSubQuery selectDistinct(Expression... exprs) { + return new JPASubQuery().select(exprs).distinct(); + } + + /** + * Create a new detached JPQLQuery instance with the projection zero + * + * @return select(0) + */ + public static JPQLSubQuery selectZero() { + return select(Expressions.ZERO); + } + + /** + * Create a new detached JPQLQuery instance with the projection one + * + * @return select(1) + */ + public static JPQLSubQuery selectOne() { + return select(Expressions.ONE); + } + + /** + * Create a new detached JPQLQuery instance with the given projection + * + * @param expr projection and source + * @param + * @return select(expr).from(expr) + */ + public static JPQLSubQuery selectFrom(EntityPath expr) { + return select(expr).from(expr); + } + + /** + * Create a JPA 2.1 treated path. + * + * @param path The path to apply the treat operation on + * @param subtype subtype class + * @param the subtype class + * @param the expression type + * @return subtype instance with the same identity + */ + public static , T> U treat( + BeanPath path, Class subtype) { + try { + Class entitySubType = getConcreteEntitySubType(subtype); + var pathMetadata = + new PathMetadata(path, getEntityName(entitySubType), PathType.TREATED_PATH); + return subtype.getConstructor(PathMetadata.class).newInstance(pathMetadata); + } catch (InstantiationException e) { + throw new ExpressionException(e.getMessage(), e); + } catch (IllegalAccessException e) { + throw new ExpressionException(e.getMessage(), e); + } catch (InvocationTargetException e) { + throw new ExpressionException(e.getMessage(), e); + } catch (NoSuchMethodException e) { + throw new ExpressionException(e.getMessage(), e); + } + } + + /** + * Create a avg(col) expression + * + * @param col collection + * @return avg(col) + */ + public static > ComparableExpression avg( + CollectionExpression col) { + return Expressions.comparableOperation( + (Class) col.getParameter(0), Ops.QuantOps.AVG_IN_COL, (Expression) col); + } + + /** + * Create a max(col) expression + * + * @param left collection + * @return max(col) + */ + public static > ComparableExpression max( + CollectionExpression left) { + return Expressions.comparableOperation( + (Class) left.getParameter(0), Ops.QuantOps.MAX_IN_COL, (Expression) left); + } + + /** + * Create a min(col) expression + * + * @param left collection + * @return min(col) + */ + public static > ComparableExpression min( + CollectionExpression left) { + return Expressions.comparableOperation( + (Class) left.getParameter(0), Ops.QuantOps.MIN_IN_COL, (Expression) left); + } + + /** + * Create a type(path) expression + * + * @param path entity + * @return type(path) + */ + public static StringExpression type(EntityPath path) { + return Expressions.stringOperation(JPQLOps.TYPE, path); + } + + private static String getEntityName(Class clazz) { + final var entityAnnotation = clazz.getAnnotation(Entity.class); + if (entityAnnotation != null && entityAnnotation.name().length() > 0) { + return entityAnnotation.name(); + } else if (clazz.getPackage() != null) { + var pn = clazz.getPackage().getName(); + return clazz.getName().substring(pn.length() + 1); + } else { + return clazz.getName(); + } + } + + private static , T> Class getConcreteEntitySubType( + Class subtype) { + return (Class) + ((ParameterizedType) subtype.getGenericSuperclass()).getActualTypeArguments()[0]; + } + + private JPAExpressions() {} +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPAListAccessVisitor.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPAListAccessVisitor.java new file mode 100644 index 0000000000..71470ba4a1 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPAListAccessVisitor.java @@ -0,0 +1,95 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.JoinType; +import com.querydsl.core.QueryMetadata; +import com.querydsl.core.support.ReplaceVisitor; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.ExpressionUtils; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.PathType; +import com.querydsl.core.types.dsl.Expressions; +import java.util.HashMap; +import java.util.Map; +import org.jetbrains.annotations.Nullable; + +class JPAListAccessVisitor extends ReplaceVisitor { + + private final QueryMetadata metadata; + + private final Map, Path> aliases; + + private final Map, Path> replacements = new HashMap<>(); + + JPAListAccessVisitor(QueryMetadata metadata, Map, Path> aliases) { + this.metadata = metadata; + this.aliases = aliases; + } + + @SuppressWarnings("unchecked") + @Override + public Expression visit(Path expr, @Nullable Void context) { + expr = (Path) super.visit(expr, null); + var pathMetadata = expr.getMetadata(); + if (pathMetadata.getPathType() == PathType.LISTVALUE + || pathMetadata.getPathType() == PathType.LISTVALUE_CONSTANT) { + Path replacement = replacements.get(expr); + if (replacement == null) { + // join parent as path123 on index(path123) = ... + Path parent = shorten(pathMetadata.getParent(), true); + replacement = + ExpressionUtils.path( + expr.getType(), ExpressionUtils.createRootVariable(parent, replacements.size())); + metadata.addJoin(JoinType.LEFTJOIN, ExpressionUtils.as(parent, replacement)); + metadata.addJoinCondition( + ExpressionUtils.eq( + (Expression) Expressions.operation(Integer.class, JPQLOps.INDEX, replacement), + ExpressionUtils.toExpression(pathMetadata.getElement()))); + replacements.put(expr, replacement); + } + return replacement; + } else { + return super.visit(expr, context); + } + } + + /** Shorten the parent path to a length of max 2 elements */ + private Path shorten(Path path, boolean outer) { + if (aliases.containsKey(path)) { + return aliases.get(path); + } else if (path.getMetadata().isRoot()) { + return path; + } else if (path.getMetadata().getParent().getMetadata().isRoot() && outer) { + return path; + } else { + Class type = JPAQueryMixin.getElementTypeOrType(path); + Path parent = shorten(path.getMetadata().getParent(), false); + Path oldPath = + ExpressionUtils.path( + path.getType(), + new PathMetadata( + parent, path.getMetadata().getElement(), path.getMetadata().getPathType())); + if (oldPath.getMetadata().getParent().getMetadata().isRoot() && outer) { + return oldPath; + } else { + Path newPath = ExpressionUtils.path(type, ExpressionUtils.createRootVariable(oldPath)); + aliases.put(path, newPath); + metadata.addJoin(JoinType.LEFTJOIN, ExpressionUtils.as(oldPath, newPath)); + return newPath; + } + } + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPAMapAccessVisitor.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPAMapAccessVisitor.java new file mode 100644 index 0000000000..96944fbd71 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPAMapAccessVisitor.java @@ -0,0 +1,124 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.JoinType; +import com.querydsl.core.QueryMetadata; +import com.querydsl.core.support.ReplaceVisitor; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.ExpressionUtils; +import com.querydsl.core.types.Operation; +import com.querydsl.core.types.Ops; +import com.querydsl.core.types.ParameterizedExpression; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.PathType; +import com.querydsl.core.types.dsl.Expressions; +import java.util.HashMap; +import java.util.Map; +import org.jetbrains.annotations.Nullable; + +class JPAMapAccessVisitor extends ReplaceVisitor { + + private final QueryMetadata metadata; + + private final Map, Path> aliases; + + private final Map, Path> replacements = new HashMap<>(); + + JPAMapAccessVisitor(QueryMetadata metadata, Map, Path> aliases) { + this.metadata = metadata; + this.aliases = aliases; + } + + @SuppressWarnings("unchecked") + @Override + public Expression visit(Operation expr, @Nullable Void context) { + if (expr.getOperator() == Ops.CONTAINS_KEY) { + ParameterizedExpression map = (ParameterizedExpression) expr.getArg(0); + Expression key = expr.getArg(1); + var replacement = + ExpressionUtils.path( + map.getParameter(1), + ExpressionUtils.createRootVariable((Path) map, Math.abs(expr.hashCode()))); + metadata.addJoin(JoinType.LEFTJOIN, ExpressionUtils.as(map, replacement)); + metadata.addJoinCondition( + ExpressionUtils.eq( + Expressions.operation(map.getParameter(0), JPQLOps.KEY, replacement), key)); + return ExpressionUtils.isNotNull(replacement); + } else if (expr.getOperator() == Ops.CONTAINS_VALUE) { + ParameterizedExpression map = (ParameterizedExpression) expr.getArg(0); + Expression value = expr.getArg(1); + return Expressions.predicate(JPQLOps.MEMBER_OF, value, map); + } else { + return super.visit(expr, context); + } + } + + @SuppressWarnings("unchecked") + @Override + public Expression visit(Path expr, @Nullable Void context) { + expr = (Path) super.visit(expr, null); + var pathMetadata = expr.getMetadata(); + if (pathMetadata.getPathType() == PathType.MAPVALUE + || pathMetadata.getPathType() == PathType.MAPVALUE_CONSTANT) { + Path replacement = replacements.get(expr); + if (replacement == null) { + // join parent as path123 on key(path123) = ... + Path parent = shorten(pathMetadata.getParent(), true); + var parExpr = (ParameterizedExpression) pathMetadata.getParent(); + replacement = + ExpressionUtils.path( + parExpr.getParameter(1), + ExpressionUtils.createRootVariable(parent, replacements.size())); + metadata.addJoin(JoinType.LEFTJOIN, ExpressionUtils.as(parent, replacement)); + metadata.addJoinCondition( + ExpressionUtils.eq( + Expressions.operation(parExpr.getParameter(0), JPQLOps.KEY, replacement), + ExpressionUtils.toExpression(pathMetadata.getElement()))); + replacements.put(expr, replacement); + } + return replacement; + } else { + return super.visit(expr, context); + } + } + + /** Shorten the parent path to a length of max 2 elements */ + private Path shorten(Path path, boolean outer) { + if (aliases.containsKey(path)) { + return aliases.get(path); + } else if (path.getMetadata().isRoot()) { + return path; + } else if (path.getMetadata().getParent().getMetadata().isRoot() && outer) { + return path; + } else { + Class type = JPAQueryMixin.getElementTypeOrType(path); + Path parent = shorten(path.getMetadata().getParent(), false); + Path oldPath = + ExpressionUtils.path( + path.getType(), + new PathMetadata( + parent, path.getMetadata().getElement(), path.getMetadata().getPathType())); + if (oldPath.getMetadata().getParent().getMetadata().isRoot() && outer) { + return oldPath; + } else { + Path newPath = ExpressionUtils.path(type, ExpressionUtils.createRootVariable(oldPath)); + aliases.put(path, newPath); + metadata.addJoin(JoinType.LEFTJOIN, ExpressionUtils.as(oldPath, newPath)); + return newPath; + } + } + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPAQueryBase.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPAQueryBase.java new file mode 100644 index 0000000000..31b1e404d2 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPAQueryBase.java @@ -0,0 +1,225 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.QueryMetadata; +import com.querydsl.core.dml.mutiny.MutinyFetchableSubQueryBase; +import com.querydsl.core.types.CollectionExpression; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.MapExpression; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.dsl.Expressions; + +/** + * {@code JPAQueryBase} is a base Query class for JPA queries + * + * @param result type + * @param concrete subtype + * @author tiwe + */ +public abstract class JPAQueryBase> + extends MutinyFetchableSubQueryBase implements JPQLQuery { + + protected final JPAQueryMixin queryMixin; + + private final JPQLTemplates templates; + + @SuppressWarnings("unchecked") + public JPAQueryBase(QueryMetadata md, JPQLTemplates templates) { + super(new JPAQueryMixin<>(md)); + super.queryMixin.setSelf((Q) this); + this.queryMixin = (JPAQueryMixin) super.queryMixin; + this.templates = templates; + } + + protected JPQLTemplates getTemplates() { + return templates; + } + + protected abstract JPQLSerializer createSerializer(); + + protected JPQLSerializer serialize(boolean forCountRow) { + return serialize(forCountRow, true); + } + + protected JPQLSerializer serialize(boolean forCountRow, boolean validate) { + if (validate) { + if (queryMixin.getMetadata().getJoins().isEmpty()) { + throw new IllegalArgumentException("No sources given"); + } + } + var serializer = createSerializer(); + serializer.serialize(queryMixin.getMetadata(), forCountRow, null); + return serializer; + } + + @Override + public Q fetchJoin() { + return queryMixin.fetchJoin(); + } + + public Q from(EntityPath arg) { + return queryMixin.from(arg); + } + + @Override + public Q from(EntityPath... args) { + return queryMixin.from(args); + } + + @SuppressWarnings("unchecked") + @Override + public

Q from(CollectionExpression target, Path

alias) { + return queryMixin.from(Expressions.as((Path) target, alias)); + } + + @Override + public

Q innerJoin(CollectionExpression target) { + return queryMixin.innerJoin(target); + } + + @Override + public

Q innerJoin(CollectionExpression target, Path

alias) { + return queryMixin.innerJoin(target, alias); + } + + @Override + public

Q innerJoin(EntityPath

target) { + return queryMixin.innerJoin(target); + } + + @Override + public

Q innerJoin(EntityPath

target, Path

alias) { + return queryMixin.innerJoin(target, alias); + } + + @Override + public

Q innerJoin(MapExpression target) { + return queryMixin.innerJoin(target); + } + + @Override + public

Q innerJoin(MapExpression target, Path

alias) { + return queryMixin.innerJoin(target, alias); + } + + @Override + public

Q join(CollectionExpression target) { + return queryMixin.join(target); + } + + @Override + public

Q join(CollectionExpression target, Path

alias) { + return queryMixin.join(target, alias); + } + + @Override + public

Q join(EntityPath

target) { + return queryMixin.join(target); + } + + @Override + public

Q join(EntityPath

target, Path

alias) { + return queryMixin.join(target, alias); + } + + @Override + public

Q join(MapExpression target) { + return queryMixin.join(target); + } + + @Override + public

Q join(MapExpression target, Path

alias) { + return queryMixin.join(target, alias); + } + + @Override + public

Q leftJoin(CollectionExpression target) { + return queryMixin.leftJoin(target); + } + + @Override + public

Q leftJoin(CollectionExpression target, Path

alias) { + return queryMixin.leftJoin(target, alias); + } + + @Override + public

Q leftJoin(EntityPath

target) { + return queryMixin.leftJoin(target); + } + + @Override + public

Q leftJoin(EntityPath

target, Path

alias) { + return queryMixin.leftJoin(target, alias); + } + + @Override + public

Q leftJoin(MapExpression target) { + return queryMixin.leftJoin(target); + } + + @Override + public

Q leftJoin(MapExpression target, Path

alias) { + return queryMixin.leftJoin(target, alias); + } + + @Override + public

Q rightJoin(CollectionExpression target) { + return queryMixin.rightJoin(target); + } + + @Override + public

Q rightJoin(CollectionExpression target, Path

alias) { + return queryMixin.rightJoin(target, alias); + } + + @Override + public

Q rightJoin(EntityPath

target) { + return queryMixin.rightJoin(target); + } + + @Override + public

Q rightJoin(EntityPath

target, Path

alias) { + return queryMixin.rightJoin(target, alias); + } + + @Override + public

Q rightJoin(MapExpression target) { + return queryMixin.rightJoin(target); + } + + @Override + public

Q rightJoin(MapExpression target, Path

alias) { + return queryMixin.rightJoin(target, alias); + } + + public Q on(Predicate condition) { + return queryMixin.on(condition); + } + + @Override + public Q on(Predicate... conditions) { + return queryMixin.on(conditions); + } + + @Override + public String toString() { + var serializer = serialize(false, false); + return serializer.toString().trim(); + } + + @Override + public abstract Q clone(); +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPAQueryMixin.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPAQueryMixin.java new file mode 100644 index 0000000000..dfd433297d --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPAQueryMixin.java @@ -0,0 +1,240 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.DefaultQueryMetadata; +import com.querydsl.core.JoinFlag; +import com.querydsl.core.QueryMetadata; +import com.querydsl.core.support.Context; +import com.querydsl.core.support.PathsExtractor; +import com.querydsl.core.support.QueryMixin; +import com.querydsl.core.support.ReplaceVisitor; +import com.querydsl.core.types.CollectionExpression; +import com.querydsl.core.types.ConstantImpl; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.ExpressionUtils; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.PathType; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.SubQueryExpression; +import com.querydsl.core.types.dsl.CollectionPathBase; +import jakarta.persistence.Entity; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.jetbrains.annotations.Nullable; + +/** + * {@code JPAQueryMixin} extends {@link QueryMixin} to support JPQL join construction + * + * @author tiwe + * @param + */ +public class JPAQueryMixin extends QueryMixin { + + private final Set> paths = new HashSet<>(); + + private final Map, Path> aliases = new HashMap<>(); + + private final JPAMapAccessVisitor mapAccessVisitor; + + private final JPAListAccessVisitor listAccessVisitor; + + private final JPACollectionAnyVisitor collectionAnyVisitor; + + private final ReplaceVisitor replaceVisitor = + new ReplaceVisitor<>() { + @Override + public Expression visit(Path expr, Void context) { + return convertPathForOrder(expr); + } + + @Override + public Expression visit(SubQueryExpression expr, @Nullable Void context) { + // don't shorten paths inside subquery expressions + return expr; + } + }; + + public static final JoinFlag FETCH = new JoinFlag("fetch "); + + public JPAQueryMixin() { + this(null, new DefaultQueryMetadata()); + } + + public JPAQueryMixin(QueryMetadata metadata) { + this(null, metadata); + } + + public JPAQueryMixin(T self, QueryMetadata metadata) { + super(self, metadata); + mapAccessVisitor = new JPAMapAccessVisitor(metadata, aliases); + listAccessVisitor = new JPAListAccessVisitor(metadata, aliases); + collectionAnyVisitor = new JPACollectionAnyVisitor(); + } + + public T fetchJoin() { + addJoinFlag(FETCH); + return getSelf(); + } + + @Override + protected Expression createAlias(Expression expr, Path alias) { + aliases.put(expr, alias); + return super.createAlias(expr, alias); + } + + static boolean isEntityPath(Path path) { + if (path instanceof CollectionPathBase) { + return isEntityPath((Path) ((CollectionPathBase) path).any()); + } else { + return path instanceof EntityPath || path.getType().isAnnotationPresent(Entity.class); + } + } + + @SuppressWarnings("unchecked") + static Class getElementTypeOrType(Path path) { + if (path instanceof CollectionExpression) { + return ((CollectionExpression) path).getParameter(0); + } else { + return (Class) path.getType(); + } + } + + @SuppressWarnings("unchecked") + private Path shorten(Path path, List> paths) { + var metadata = path.getMetadata(); + if (metadata.isRoot() || paths.contains(path)) { + return path; + } else if (aliases.containsKey(path)) { + return (Path) aliases.get(path); + } else if (metadata.getPathType() == PathType.COLLECTION_ANY) { + return (Path) shorten(metadata.getParent(), paths); + } else if (!isEntityPath(path)) { + Path parent = shorten(metadata.getParent(), paths); + if (parent.equals(metadata.getParent())) { + return path; + } else { + return ExpressionUtils.path( + path.getType(), + new PathMetadata(parent, metadata.getElement(), metadata.getPathType())); + } + } else if (metadata.getParent().getMetadata().isRoot()) { + Class type = getElementTypeOrType(path); + Path newPath = ExpressionUtils.path(type, ExpressionUtils.createRootVariable(path)); + leftJoin(path, newPath); + return newPath; + } else { + Class type = getElementTypeOrType(path); + Path parent = shorten(metadata.getParent(), paths); + Path oldPath = + ExpressionUtils.path( + path.getType(), + new PathMetadata(parent, metadata.getElement(), metadata.getPathType())); + Path newPath = ExpressionUtils.path(type, ExpressionUtils.createRootVariable(oldPath)); + aliases.put(path, newPath); + leftJoin(oldPath, newPath); + return newPath; + } + } + + private Path convertPathForOrder(Path path) { + var metadata = path.getMetadata(); + // at least three levels + if (metadata.getParent() != null && !metadata.getParent().getMetadata().isRoot()) { + Set> exprs = new HashSet<>(); + var md = getMetadata(); + exprs.addAll(md.getGroupBy()); + if (md.getProjection() != null) { + exprs.add(md.getProjection()); + } + if (md.getWhere() != null) { + exprs.add(md.getWhere()); + } + if (md.getHaving() != null) { + exprs.add(md.getHaving()); + } + List> paths = new ArrayList<>(); + // extract paths + PathsExtractor.DEFAULT.visit(exprs, paths); + + if (!paths.contains(path) && !paths.contains(metadata.getParent())) { + Path shortened = shorten(metadata.getParent(), paths); + return ExpressionUtils.path( + path.getType(), + new PathMetadata(shortened, metadata.getElement(), metadata.getPathType())); + } else { + return path; + } + } else { + return path; + } + } + + @SuppressWarnings("unchecked") + @Override + public Expression convert(Expression expr, Role role) { + expr = (Expression) expr.accept(mapAccessVisitor, null); + expr = (Expression) expr.accept(listAccessVisitor, null); + if (role == Role.ORDER_BY) { + if (expr instanceof Path) { + expr = convertPathForOrder((Path) expr); + } else { + expr = (Expression) expr.accept(replaceVisitor, null); + } + } + return Conversions.convert(super.convert(expr, role)); + } + + @Override + protected Predicate convert(Predicate predicate, Role role) { + if (predicate != null) { + predicate = (Predicate) ExpressionUtils.extract(predicate); + } + if (predicate != null) { + predicate = (Predicate) predicate.accept(mapAccessVisitor, null); + predicate = (Predicate) predicate.accept(listAccessVisitor, null); + } + if (predicate != null) { + // transform any usage + predicate = (Predicate) predicate.accept(collectionAnyVisitor, new Context()); + return predicate; + } else { + return null; + } + } + + @SuppressWarnings("unchecked") + private void addCondition(Context context, int i, Path path, boolean where) { + paths.add(path); + EntityPath alias = context.replacements.get(i); + leftJoin((Expression) path.getMetadata().getParent(), context.replacements.get(i)); + Expression index = ExpressionUtils.operation(Integer.class, JPQLOps.INDEX, alias); + var element = path.getMetadata().getElement(); + if (!(element instanceof Expression)) { + element = ConstantImpl.create(element); + } + var condition = ExpressionUtils.eq(index, (Expression) element); + if (where) { + super.where(condition); + } else { + super.having(condition); + } + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPASubQuery.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPASubQuery.java new file mode 100644 index 0000000000..082702f999 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPASubQuery.java @@ -0,0 +1,79 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.DefaultQueryMetadata; +import com.querydsl.core.NonUniqueResultException; +import com.querydsl.core.QueryMetadata; +import com.querydsl.core.Tuple; +import com.querydsl.core.types.Expression; +import io.smallrye.mutiny.Uni; +import java.util.List; + +class JPASubQuery extends JPAQueryBase> implements JPQLSubQuery { + + JPASubQuery() { + super(new DefaultQueryMetadata(), JPQLTemplates.DEFAULT); + } + + JPASubQuery(QueryMetadata metadata) { + super(metadata, JPQLTemplates.DEFAULT); + } + + @Override + protected JPQLSerializer createSerializer() { + return new JPQLSerializer(getTemplates(), null); + } + + @Override + public JPASubQuery clone() { + return new JPASubQuery<>(getMetadata().clone()); + } + + @Override + public JPASubQuery select(Expression expr) { + queryMixin.setProjection(expr); + @SuppressWarnings("unchecked") // This is the new type + var newType = (JPASubQuery) this; + return newType; + } + + @Override + public JPASubQuery select(Expression... exprs) { + queryMixin.setProjection(exprs); + @SuppressWarnings("unchecked") // This is the new type + var newType = (JPASubQuery) this; + return newType; + } + + @Override + public Uni fetchOne() throws NonUniqueResultException { + throw new UnsupportedOperationException(); + } + + @Override + public Uni fetchCount() { + throw new UnsupportedOperationException(); + } + + @Override + public Uni> fetch() { + throw new UnsupportedOperationException(); + } + + @Override + public Uni fetchFirst() { + throw new UnsupportedOperationException(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLOps.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLOps.java new file mode 100644 index 0000000000..4abda59d02 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLOps.java @@ -0,0 +1,43 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.types.Operator; + +/** + * {@code JPQLOps} provides JPQL specific operators + * + * @author tiwe + */ +public enum JPQLOps implements Operator { + TREAT(Object.class), + INDEX(Integer.class), + TYPE(String.class), + CAST(Object.class), + MEMBER_OF(Boolean.class), + NOT_MEMBER_OF(Boolean.class), + KEY(Object.class), + VALUE(Object.class); + + private final Class type; + + JPQLOps(Class type) { + this.type = type; + } + + @Override + public Class getType() { + return type; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLQuery.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLQuery.java new file mode 100644 index 0000000000..f0b0422155 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLQuery.java @@ -0,0 +1,317 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.Query; +import com.querydsl.core.Tuple; +import com.querydsl.core.dml.mutiny.MutinyFetchableQuery; +import com.querydsl.core.support.ExtendedSubQuery; +import com.querydsl.core.types.CollectionExpression; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.MapExpression; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.Predicate; + +/** + * Query interface for JPQL queries + * + * @param result type + * @author tiwe + */ +public interface JPQLQuery + extends MutinyFetchableQuery>, Query>, ExtendedSubQuery { + + /** + * Add sources to this query + * + * @param sources sources + * @return the current object + */ + JPQLQuery from(EntityPath... sources); + + /** + * Add a query source + * + * @param target collection + * @param alias alias + * @param

+ * @return the current object + */ +

JPQLQuery from(CollectionExpression target, Path

alias); + + /** + * Create a inner join with the given target. Use fetchJoin() to add the fetchJoin parameter to + * this join. + * + * @param

+ * @param target target + * @return the current object + */ +

JPQLQuery innerJoin(EntityPath

target); + + /** + * Create a inner join with the given target and alias. + * + * @param

+ * @param target target + * @param alias alias + * @return the current object + */ +

JPQLQuery innerJoin(EntityPath

target, Path

alias); + + /** + * Create a inner join with the given target. Use fetchJoin() to add the fetchJoin parameter to + * this join. + * + * @param

+ * @param target target + * @return the current object + */ +

JPQLQuery innerJoin(CollectionExpression target); + + /** + * Create a inner join with the given target and alias. + * + * @param

+ * @param target target + * @param alias alias + * @return the current object + */ +

JPQLQuery innerJoin(CollectionExpression target, Path

alias); + + /** + * Create a inner join with the given target. Use fetchJoin() to add the fetchJoin parameter to + * this join. + * + * @param

+ * @param target target + * @return the current object + */ +

JPQLQuery innerJoin(MapExpression target); + + /** + * Create a inner join with the given target and alias. + * + * @param

+ * @param target target + * @param alias alias + * @return the current object + */ +

JPQLQuery innerJoin(MapExpression target, Path

alias); + + /** + * Create a join with the given target. Use fetchJoin() to add the fetchJoin parameter to this + * join. + * + * @param

+ * @param target target + * @return the current object + */ +

JPQLQuery join(EntityPath

target); + + /** + * Create a join with the given target and alias. + * + * @param

+ * @param target target + * @param alias alias + * @return the current object + */ +

JPQLQuery join(EntityPath

target, Path

alias); + + /** + * Create a join with the given target. Use fetchJoin() to add the fetchJoin parameter to this + * join. + * + * @param

+ * @param target target + * @return the current object + */ +

JPQLQuery join(CollectionExpression target); + + /** + * Create a join with the given target Use fetchJoin() to add the fetchJoin parameter to this join + * + * @param

+ * @param target target + * @param alias alias + * @return the current object + */ +

JPQLQuery join(CollectionExpression target, Path

alias); + + /** + * Create a join with the given target. Use fetchJoin() to add the fetchJoin parameter to this + * join. + * + * @param

+ * @param target target + * @return the current object + */ +

JPQLQuery join(MapExpression target); + + /** + * Create a join with the given target and alias. + * + * @param

+ * @param target target + * @param alias alias + * @return the current object + */ +

JPQLQuery join(MapExpression target, Path

alias); + + /** + * Create a left join with the given target. Use fetchJoin() to add the fetchJoin parameter to + * this join. + * + * @param

+ * @param target target + * @return the current object + */ +

JPQLQuery leftJoin(EntityPath

target); + + /** + * Create a left join with the given target and alias. + * + * @param

+ * @param target target + * @param alias alias + * @return the current object + */ +

JPQLQuery leftJoin(EntityPath

target, Path

alias); + + /** + * Create a left join with the given target. Use fetchJoin() to add the fetchJoin parameter to + * this join. + * + * @param

+ * @param target target + * @return the current object + */ +

JPQLQuery leftJoin(CollectionExpression target); + + /** + * Create a left join with the given target and alias. + * + * @param

+ * @param target target + * @param alias alias + * @return the current object + */ +

JPQLQuery leftJoin(CollectionExpression target, Path

alias); + + /** + * Create a left join with the given target. Use fetchJoin() to add the fetchJoin parameter to + * this join. + * + * @param

+ * @param target target + * @return the current object + */ +

JPQLQuery leftJoin(MapExpression target); + + /** + * Create a left join with the given target and alias. + * + * @param

+ * @param target target + * @param alias alias + * @return the current object + */ +

JPQLQuery leftJoin(MapExpression target, Path

alias); + + /** + * Create a right join with the given target. Use fetchJoin() to add the fetchJoin parameter to + * this join. + * + * @param

+ * @param target target + * @return the current object + */ +

JPQLQuery rightJoin(EntityPath

target); + + /** + * Create a right join with the given target and alias. + * + * @param

+ * @param target target + * @param alias alias + * @return the current object + */ +

JPQLQuery rightJoin(EntityPath

target, Path

alias); + + /** + * Create a right join with the given target. Use fetchJoin() to add the fetchJoin parameter to + * this join. + * + * @param

+ * @param target target + * @return the current object + */ +

JPQLQuery rightJoin(CollectionExpression target); + + /** + * Create a right join with the given target and alias. + * + * @param

+ * @param target target + * @param alias alias + * @return the current object + */ +

JPQLQuery rightJoin(CollectionExpression target, Path

alias); + + /** + * Create a right join with the given target. Use fetchJoin() to add the fetchJoin parameter to + * this join. + * + * @param

+ * @param target target + * @return the current object + */ +

JPQLQuery rightJoin(MapExpression target); + + /** + * Create a right join with the given target and alias. + * + * @param

+ * @param target target + * @param alias alias + * @return the current object + */ +

JPQLQuery rightJoin(MapExpression target, Path

alias); + + /** + * Add join conditions to the last added join + * + * @param condition join conditions + * @return the current object + */ + JPQLQuery on(Predicate... condition); + + /** + * Add the "fetchJoin" flag to the last defined join + * + *

Mind that collection joins might result in duplicate rows and that "inner join fetchJoin" + * will restrict your result set. + * + * @return the current object + */ + JPQLQuery fetchJoin(); + + @Override + JPQLQuery select(Expression expr); + + @Override + JPQLQuery select(Expression... exprs); +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLQueryFactory.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLQueryFactory.java new file mode 100644 index 0000000000..900562d392 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLQueryFactory.java @@ -0,0 +1,127 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.QueryFactory; +import com.querydsl.core.Tuple; +import com.querydsl.core.dml.mutiny.MutinyDeleteClause; +import com.querydsl.core.dml.mutiny.MutinyInsertClause; +import com.querydsl.core.dml.mutiny.MutinyUpdateClause; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.Expression; + +/** + * Common interface for JPA related QueryFactory implementations + * + * @author tiwe + */ +public interface JPQLQueryFactory extends QueryFactory> { + + /** + * Create a new DELETE clause + * + * @param path entity to delete from + * @return delete clause + */ + MutinyDeleteClause delete(EntityPath path); + + /** + * Create a new JPQLQuery instance with the given projection + * + * @param expr projection + * @param + * @return select(expr) + */ + JPQLQuery select(Expression expr); + + /** + * Create a new JPQLQuery instance with the given projection + * + * @param exprs projection + * @return select(exprs) + */ + JPQLQuery select(Expression... exprs); + + /** + * Create a new JPQLQuery instance with the given projection + * + * @param expr projection + * @param + * @return select(distinct expr) + */ + JPQLQuery selectDistinct(Expression expr); + + /** + * Create a new JPQLQuery instance with the given projection + * + * @param exprs projection + * @return select(distinct exprs) + */ + JPQLQuery selectDistinct(Expression... exprs); + + /** + * Create a new JPQLQuery instance with the projection one + * + * @return select(1) + */ + JPQLQuery selectOne(); + + /** + * Create a new JPQLQuery instance with the projection zero + * + * @return select(0) + */ + JPQLQuery selectZero(); + + /** + * Create a new JPQLQuery instance with the given source and projection + * + * @param from projection and source + * @param + * @return select(from).from(from) + */ + JPQLQuery selectFrom(EntityPath from); + + /** + * Create a new Query with the given source + * + * @param from from + * @return from(from) + */ + JPQLQuery from(EntityPath from); + + /** + * Create a new Query with the given source + * + * @param from from + * @return from(from) + */ + JPQLQuery from(EntityPath... from); + + /** + * Create a new UPDATE clause + * + * @param path entity to update + * @return update clause + */ + MutinyUpdateClause update(EntityPath path); + + /** + * Create a new INSERT clause + * + * @param path entity to insert to + * @return insert clause + */ + MutinyInsertClause insert(EntityPath path); +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLSerializer.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLSerializer.java new file mode 100644 index 0000000000..f50c34b648 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLSerializer.java @@ -0,0 +1,639 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.JoinExpression; +import com.querydsl.core.JoinType; +import com.querydsl.core.QueryMetadata; +import com.querydsl.core.support.SerializerBase; +import com.querydsl.core.types.CollectionExpression; +import com.querydsl.core.types.Constant; +import com.querydsl.core.types.ConstantImpl; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.ExpressionUtils; +import com.querydsl.core.types.FactoryExpression; +import com.querydsl.core.types.MapExpression; +import com.querydsl.core.types.Operation; +import com.querydsl.core.types.Operator; +import com.querydsl.core.types.Ops; +import com.querydsl.core.types.Order; +import com.querydsl.core.types.OrderSpecifier; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathType; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.SubQueryExpression; +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.core.util.MathUtils; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityManager; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.SingularAttribute; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.EnumMap; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.jetbrains.annotations.Nullable; + +/** + * {@code JPQLSerializer} serializes Querydsl expressions into JPQL syntax. + * + * @author tiwe + */ +public class JPQLSerializer extends SerializerBase { + + private static final Set NUMERIC = + Collections.unmodifiableSet( + EnumSet.of( + Ops.ADD, Ops.SUB, Ops.MULT, Ops.DIV, Ops.LT, Ops.LOE, Ops.GT, Ops.GOE, Ops.BETWEEN)); + + private static final Set CASE_OPS = + Collections.unmodifiableSet(EnumSet.of(Ops.CASE_ELSE)); + + private static final String COMMA = ", "; + + private static final String DELETE = "delete from "; + + private static final String FROM = "from "; + + private static final String GROUP_BY = "\ngroup by "; + + private static final String HAVING = "\nhaving "; + + private static final String ORDER_BY = "\norder by "; + + private static final String SELECT = "select "; + + private static final String SELECT_COUNT = "select count("; + + private static final String SELECT_COUNT_DISTINCT = "select count(distinct "; + + private static final String SELECT_DISTINCT = "select distinct "; + + private static final String SET = "\nset "; + + private static final String UPDATE = "update "; + + private static final String INSERT = "insert into "; + + private static final String VALUES = "\nvalues "; + + private static final String WHERE = "\nwhere "; + + private static final String WITH = " with "; + + private static final String ON = " on "; + + private static final Map joinTypes = new EnumMap<>(JoinType.class); + + private final JPQLTemplates templates; + + private final EntityManager entityManager; + + private boolean inProjection = false; + + private boolean inCaseOperation = false; + + static { + joinTypes.put(JoinType.DEFAULT, COMMA); + joinTypes.put(JoinType.FULLJOIN, "\n full join "); + joinTypes.put(JoinType.INNERJOIN, "\n inner join "); + joinTypes.put(JoinType.JOIN, "\n inner join "); + joinTypes.put(JoinType.LEFTJOIN, "\n left join "); + joinTypes.put(JoinType.RIGHTJOIN, "\n right join "); + } + + private boolean wrapElements = false; + + public JPQLSerializer(JPQLTemplates templates) { + this(templates, null); + } + + public JPQLSerializer(JPQLTemplates templates, EntityManager em) { + super(templates); + this.templates = templates; + this.entityManager = em; + } + + private String getEntityName(Class clazz) { + final var entityAnnotation = clazz.getAnnotation(Entity.class); + if (entityAnnotation != null && entityAnnotation.name().length() > 0) { + return entityAnnotation.name(); + } else if (clazz.getPackage() != null && clazz.getPackage().getName().length() > 0) { + var pn = clazz.getPackage().getName(); + return clazz.getName().substring(pn.length() + 1); + } else { + return clazz.getName(); + } + } + + private void handleJoinTarget(JoinExpression je) { + // type specifier + if (je.getTarget() instanceof EntityPath) { + final EntityPath pe = (EntityPath) je.getTarget(); + if (pe.getMetadata().isRoot()) { + append(getEntityName(pe.getType())); + append(" "); + } + handle(je.getTarget()); + } else if (je.getTarget() instanceof Operation) { + Operation op = (Operation) je.getTarget(); + if (op.getOperator() == Ops.ALIAS) { + var treat = false; + if (Collection.class.isAssignableFrom(op.getArg(0).getType())) { + if (op.getArg(0) instanceof CollectionExpression) { + Class par = ((CollectionExpression) op.getArg(0)).getParameter(0); + treat = !par.equals(op.getArg(1).getType()); + } + } else if (Map.class.isAssignableFrom(op.getArg(0).getType())) { + if (op.getArg(0) instanceof MapExpression) { + Class par = ((MapExpression) op.getArg(0)).getParameter(1); + treat = !par.equals(op.getArg(1).getType()); + } + } else { + treat = !op.getArg(0).getType().equals(op.getArg(1).getType()); + } + if (treat) { + Expression entityName = ConstantImpl.create(getEntityName(op.getArg(1).getType())); + Expression t = + ExpressionUtils.operation(op.getType(), JPQLOps.TREAT, op.getArg(0), entityName); + op = ExpressionUtils.operation(op.getType(), Ops.ALIAS, t, op.getArg(1)); + } + } + handle(op); + } else { + handle(je.getTarget()); + } + } + + public void serialize(QueryMetadata metadata, boolean forCountRow, @Nullable String projection) { + final Expression select = metadata.getProjection(); + final List joins = metadata.getJoins(); + final Predicate where = metadata.getWhere(); + final List> groupBy = metadata.getGroupBy(); + final Predicate having = metadata.getHaving(); + final List> orderBy = metadata.getOrderBy(); + + // select + var inProjectionOrig = inProjection; + inProjection = true; + if (projection != null) { + append(SELECT).append(projection).append("\n"); + + } else if (forCountRow) { + if (!groupBy.isEmpty()) { + append(SELECT_COUNT_DISTINCT); + handle(", ", groupBy); + } else { + if (!metadata.isDistinct()) { + append(SELECT_COUNT); + } else { + append(SELECT_COUNT_DISTINCT); + } + if (select != null) { + if (select instanceof FactoryExpression) { + handle(joins.get(0).getTarget()); + } else { + // TODO : make sure this works + handle(select); + } + } else { + handle(joins.get(0).getTarget()); + } + } + append(")\n"); + + } else if (select != null || !joins.isEmpty()) { + if (!metadata.isDistinct()) { + append(SELECT); + } else { + append(SELECT_DISTINCT); + } + if (select != null) { + handle(select); + } else { + handle(joins.get(0).getTarget()); + } + append("\n"); + } + inProjection = inProjectionOrig; + + // from + if (!joins.isEmpty()) { + append(FROM); + serializeSources(forCountRow, joins); + } + + // where + if (where != null) { + append(WHERE).handle(where); + } + + // group by + if (!groupBy.isEmpty() && !forCountRow) { + append(GROUP_BY).handle(COMMA, groupBy); + } + + // having + if (having != null) { + append(HAVING).handle(having); + } + + // order by + if (!orderBy.isEmpty() && !forCountRow) { + append(ORDER_BY); + var first = true; + for (final OrderSpecifier os : orderBy) { + if (!first) { + append(COMMA); + } + handle(os.getTarget()); + append(os.getOrder() == Order.ASC ? " asc" : " desc"); + if (os.getNullHandling() == OrderSpecifier.NullHandling.NullsFirst) { + append(" nulls first"); + } else if (os.getNullHandling() == OrderSpecifier.NullHandling.NullsLast) { + append(" nulls last"); + } + first = false; + } + } + } + + public void serializeForDelete(QueryMetadata md) { + append(DELETE); + handleJoinTarget(md.getJoins().get(0)); + if (md.getWhere() != null) { + append(WHERE).handle(md.getWhere()); + } + } + + private static String relativePathString(Expression root, Path path) { + var pathString = new StringBuilder(path.getMetadata().getName().length()); + while (path.getMetadata().getParent() != null && !path.equals(root)) { + if (pathString.length() > 0) { + pathString.insert(0, '.'); + } + pathString.insert(0, path.getMetadata().getName()); + path = path.getMetadata().getParent(); + } + return pathString.toString(); + } + + public void serializeForInsert( + QueryMetadata md, + Collection> columns, + List values, + SubQueryExpression query, + Map, Expression> inserts) { + append(INSERT); + final var root = md.getJoins().get(0); + append(getEntityName(root.getTarget().getType())); + append(" ("); + var first = true; + for (Path path : columns) { + if (!first) { + append(", "); + } + + append(relativePathString(root.getTarget(), path)); + first = false; + } + append(")\n"); + + if (values != null && values.size() > 0) { + append(VALUES); + append(" ("); + first = true; + for (Object value : values) { + if (!first) { + append(", "); + } + handle(value); + first = false; + } + append(")"); + } else if (inserts != null && inserts.entrySet().size() > 0) { + first = true; + for (Map.Entry, Expression> entry : inserts.entrySet()) { + if (!first) { + append(", "); + } + handle(entry.getKey()); + append(" = "); + handle(entry.getValue()); + first = false; + } + } else { + serialize(query.getMetadata(), false, null); + } + } + + public void serializeForUpdate(QueryMetadata md, Map, Expression> updates) { + append(UPDATE); + handleJoinTarget(md.getJoins().get(0)); + append(SET); + var first = true; + for (Map.Entry, Expression> entry : updates.entrySet()) { + if (!first) { + append(", "); + } + handle(entry.getKey()); + append(" = "); + handle(entry.getValue()); + first = false; + } + if (md.getWhere() != null) { + append(WHERE).handle(md.getWhere()); + } + } + + private void serializeSources(boolean forCountRow, List joins) { + for (var i = 0; i < joins.size(); i++) { + final var je = joins.get(i); + if (i > 0) { + append(joinTypes.get(je.getType())); + } + if (je.hasFlag(JPAQueryMixin.FETCH) && !forCountRow) { + handle(JPAQueryMixin.FETCH); + } + handleJoinTarget(je); + if (je.getCondition() != null) { + append(templates.isWithForOn() ? WITH : ON); + handle(je.getCondition()); + } + } + } + + @Override + public void visitConstant(Object constant) { + if (inCaseOperation && templates.isCaseWithLiterals()) { + if (constant instanceof Collection collection) { + append("("); + var first = true; + for (Object o : collection) { + if (!first) { + append(", "); + } + visitLiteral(o); + first = false; + } + append(")"); + } else { + visitLiteral(constant); + } + } else { + var wrap = templates.wrapConstant(constant); + if (wrap) { + append("("); + } + super.visitConstant(constant); + if (wrap) { + append(")"); + } + } + } + + public void visitLiteral(Object constant) { + append(templates.asLiteral(constant)); + } + + @Override + protected void serializeConstant(int parameterIndex, String constantLabel) { + append("?"); + append(Integer.toString(parameterIndex)); + } + + @Override + public Void visit(SubQueryExpression query, Void context) { + append("("); + serialize(query.getMetadata(), false, null); + append(")"); + return null; + } + + @Override + public Void visit(Path expr, Void context) { + // only wrap a PathCollection, if it the pathType is PROPERTY + var wrap = + wrapElements + && (Collection.class.isAssignableFrom(expr.getType()) + || Map.class.isAssignableFrom(expr.getType())) + && expr.getMetadata().getPathType().equals(PathType.PROPERTY); + if (wrap) { + append("elements("); + } + super.visit(expr, context); + if (wrap) { + append(")"); + } + return null; + } + + @Override + @SuppressWarnings("unchecked") + protected void visitOperation( + Class type, Operator operator, List> args) { + var oldInCaseOperation = inCaseOperation; + inCaseOperation = CASE_OPS.contains(operator); + var oldWrapElements = wrapElements; + wrapElements = templates.wrapElements(operator); + + if (operator == Ops.EQ + && args.get(1) instanceof Operation + && ((Operation) args.get(1)).getOperator() == Ops.QuantOps.ANY) { + args = Arrays.>asList(args.get(0), ((Operation) args.get(1)).getArg(0)); + visitOperation(type, Ops.IN, args); + + } else if (operator == Ops.NE + && args.get(1) instanceof Operation + && ((Operation) args.get(1)).getOperator() == Ops.QuantOps.ANY) { + args = Arrays.>asList(args.get(0), ((Operation) args.get(1)).getArg(0)); + visitOperation(type, Ops.NOT_IN, args); + + } else if (operator == Ops.IN || operator == Ops.NOT_IN) { + if (args.get(1) instanceof Path) { + visitAnyInPath(type, operator, args); + } else if (args.get(0) instanceof Path && args.get(1) instanceof Constant) { + visitPathInCollection(type, operator, args); + } else { + super.visitOperation(type, operator, args); + } + + } else if (operator == Ops.NUMCAST) { + visitNumCast(args); + + } else if (operator == Ops.EXISTS && args.get(0) instanceof SubQueryExpression) { + final var subQuery = (SubQueryExpression) args.get(0); + append("exists ("); + serialize(subQuery.getMetadata(), false, templates.getExistsProjection()); + append(")"); + + } else if (operator == Ops.MATCHES || operator == Ops.MATCHES_IC) { + super.visitOperation( + type, + Ops.LIKE, + Arrays.asList( + args.get(0), ExpressionUtils.regexToLike((Expression) args.get(1)))); + + } else if (operator == Ops.LIKE && args.get(1) instanceof Constant) { + final var escape = String.valueOf(templates.getEscapeChar()); + final var escaped = args.get(1).toString().replace(escape, escape + escape); + super.visitOperation( + String.class, Ops.LIKE, Arrays.asList(args.get(0), ConstantImpl.create(escaped))); + + } else if (NUMERIC.contains(operator)) { + super.visitOperation(type, operator, normalizeNumericArgs(args)); + + } else if (operator == Ops.ALIAS) { + if (args.get(1) instanceof Path && !((Path) args.get(1)).getMetadata().isRoot()) { + Path path = (Path) args.get(1); + args = + Arrays.asList( + args.get(0), ExpressionUtils.path(path.getType(), path.getMetadata().getName())); + } + super.visitOperation(type, operator, args); + + } else { + try { + super.visitOperation(type, operator, args); + } catch (IllegalArgumentException e) { + if (operator.getClass().getName().endsWith("SQLOps")) { + throw new IllegalArgumentException( + String.format( + """ + SQL Expressions like %s are not supported in JPQL - the query language for JPA.\ + SQLExpressions.* can only be used in JPQL queries when these functions\ + are registered as custom function in your ORM.%n To fix this issue, you\ + have three options:%n 1) If you do want to use advanced, dialect\ + specific, SQL functions within JPQL, make sure to make these functions\ + available to your ORM through custom functions and register these with\ + your JPATemplates instance.%n 2) Use JPASQLQuery instead. This allows\ + you to generate a pure SQL query based on your JPA metamodel.%n 3)\ + Consider using the Blaze-Persistence QueryDSL integration.\ + Blaze-Persistence is an extension on top of JPA that makes various SQL\ + specific functions like window functions available to JPQL.""", + operator.name()), + e); + } else { + throw e; + } + } + } + + inCaseOperation = oldInCaseOperation; + wrapElements = oldWrapElements; + } + + private void visitNumCast(List> args) { + @SuppressWarnings("unchecked") // this is the second argument's type + var rightArg = (Constant>) args.get(1); + + final Class targetType = rightArg.getConstant(); + final var typeName = templates.getTypeForCast(targetType); + visitOperation( + targetType, JPQLOps.CAST, Arrays.asList(args.get(0), ConstantImpl.create(typeName))); + } + + private void visitPathInCollection( + Class type, Operator operator, List> args) { + Path lhs = (Path) args.get(0); + @SuppressWarnings("unchecked") + Constant> rhs = (Constant>) args.get(1); + if (rhs.getConstant().isEmpty()) { + operator = operator == Ops.IN ? Ops.EQ : Ops.NE; + args = Arrays.>asList(Expressions.ONE, Expressions.TWO); + } else if (entityManager != null + && !templates.isPathInEntitiesSupported() + && args.get(0).getType().isAnnotationPresent(Entity.class)) { + final var metamodel = entityManager.getMetamodel(); + final var util = entityManager.getEntityManagerFactory().getPersistenceUnitUtil(); + final EntityType entityType = metamodel.entity(args.get(0).getType()); + if (entityType.hasSingleIdAttribute()) { + SingularAttribute id = getIdProperty(entityType); + // turn lhs into id path + lhs = ExpressionUtils.path(id.getJavaType(), lhs, id.getName()); + // turn rhs into id collection + Set ids = new HashSet<>(); + for (Object entity : rhs.getConstant()) { + ids.add(util.getIdentifier(entity)); + } + rhs = ConstantImpl.create(ids); + args = Arrays.asList(lhs, rhs); + } + } + + super.visitOperation(type, operator, args); + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + private SingularAttribute getIdProperty(EntityType entity) { + final Set singularAttributes = entity.getSingularAttributes(); + for (final SingularAttribute singularAttribute : singularAttributes) { + if (singularAttribute.isId()) { + return singularAttribute; + } + } + return null; + } + + private void visitAnyInPath( + Class type, Operator operator, List> args) { + super.visitOperation( + type, operator == Ops.IN ? JPQLOps.MEMBER_OF : JPQLOps.NOT_MEMBER_OF, args); + } + + @SuppressWarnings("unchecked") + private List> normalizeNumericArgs(List> args) { + // we do not yet let it produce these types + // we verify the types with isAssignableFrom() + @SuppressWarnings("unchecked") + List> potentialArgs = + (List>) args; + var hasConstants = false; + Class numType = null; + for (Expression arg : potentialArgs) { + if (Number.class.isAssignableFrom(arg.getType())) { + if (arg instanceof Constant) { + hasConstants = true; + } else { + numType = arg.getType(); + } + } + } + if (hasConstants && numType != null) { + // now we do let the potentialArgs help us + final List> newArgs = new ArrayList<>(args.size()); + for (final Expression arg : potentialArgs) { + if (arg instanceof Constant + && Number.class.isAssignableFrom(arg.getType()) + && !arg.getType().equals(numType)) { + final Number number = ((Constant) arg).getConstant(); + newArgs.add(ConstantImpl.create(MathUtils.cast(number, numType))); + } else { + newArgs.add(arg); + } + } + return newArgs; + } else { + // the types are all non-constants, or not Number expressions + return potentialArgs; + } + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLSubQuery.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLSubQuery.java new file mode 100644 index 0000000000..e382e27d02 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLSubQuery.java @@ -0,0 +1,246 @@ +package com.querydsl.jpa; + +import com.querydsl.core.QueryMetadata; +import com.querydsl.core.QueryModifiers; +import com.querydsl.core.Tuple; +import com.querydsl.core.types.CollectionExpression; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.MapExpression; +import com.querydsl.core.types.OrderSpecifier; +import com.querydsl.core.types.ParamExpression; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.SubQueryExpression; +import com.querydsl.core.types.Visitor; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.core.types.dsl.BooleanOperation; +import java.util.Collection; + +public interface JPQLSubQuery extends SubQueryExpression { + + JPQLSubQuery clone(); + + JPQLSubQuery select(Expression expr); + + JPQLSubQuery select(Expression... exprs); + + JPQLSubQuery fetchJoin(); + + JPQLSubQuery from(EntityPath arg); + + JPQLSubQuery from(EntityPath... args); + +

JPQLSubQuery from(CollectionExpression target, Path

alias); + +

JPQLSubQuery innerJoin(CollectionExpression target); + +

JPQLSubQuery innerJoin(CollectionExpression target, Path

alias); + +

JPQLSubQuery innerJoin(EntityPath

target); + +

JPQLSubQuery innerJoin(EntityPath

target, Path

alias); + +

JPQLSubQuery innerJoin(MapExpression target); + +

JPQLSubQuery innerJoin(MapExpression target, Path

alias); + +

JPQLSubQuery join(CollectionExpression target); + +

JPQLSubQuery join(CollectionExpression target, Path

alias); + +

JPQLSubQuery join(EntityPath

target); + +

JPQLSubQuery join(EntityPath

target, Path

alias); + +

JPQLSubQuery join(MapExpression target); + +

JPQLSubQuery join(MapExpression target, Path

alias); + +

JPQLSubQuery leftJoin(CollectionExpression target); + +

JPQLSubQuery leftJoin(CollectionExpression target, Path

alias); + +

JPQLSubQuery leftJoin(EntityPath

target); + +

JPQLSubQuery leftJoin(EntityPath

target, Path

alias); + +

JPQLSubQuery leftJoin(MapExpression target); + +

JPQLSubQuery leftJoin(MapExpression target, Path

alias); + +

JPQLSubQuery rightJoin(CollectionExpression target); + +

JPQLSubQuery rightJoin(CollectionExpression target, Path

alias); + +

JPQLSubQuery rightJoin(EntityPath

target); + +

JPQLSubQuery rightJoin(EntityPath

target, Path

alias); + +

JPQLSubQuery rightJoin(MapExpression target); + +

JPQLSubQuery rightJoin(MapExpression target, Path

alias); + + JPQLSubQuery on(Predicate condition); + + JPQLSubQuery on(Predicate... conditions); + + BooleanExpression contains(Expression right); + + BooleanExpression contains(T constant); + + BooleanExpression exists(); + + BooleanExpression eq(Expression expr); + + BooleanExpression eq(T constant); + + BooleanExpression ne(Expression expr); + + BooleanExpression ne(T constant); + + BooleanExpression notExists(); + + BooleanExpression lt(Expression expr); + + BooleanExpression lt(T constant); + + BooleanExpression gt(Expression expr); + + BooleanExpression gt(T constant); + + BooleanExpression loe(Expression expr); + + BooleanExpression loe(T constant); + + BooleanExpression goe(Expression expr); + + BooleanExpression goe(T constant); + + BooleanOperation isNull(); + + BooleanOperation isNotNull(); + + @Override + QueryMetadata getMetadata(); + + @Override + R accept(Visitor v, C context); + + @Override + Class getType(); + + BooleanExpression in(Collection right); + + BooleanExpression in(T... right); + + /** + * Set the Query to return distinct results + * + * @return the current object + */ + JPQLSubQuery distinct(); + + /** + * Add a single grouping expression + * + * @param e group by expression + * @return the current object + */ + JPQLSubQuery groupBy(Expression e); + + /** + * Add grouping/aggregation expressions + * + * @param o group by expressions + * @return the current object + */ + JPQLSubQuery groupBy(Expression... o); + + /** + * Add a single filter for aggregation + * + * @param e having condition + * @return the current object + */ + JPQLSubQuery having(Predicate e); + + /** + * Add filters for aggregation + * + * @param o having conditions + * @return the current object + */ + JPQLSubQuery having(Predicate... o); + + /** + * Add a single order expression + * + * @param o order + * @return the current object + */ + JPQLSubQuery orderBy(OrderSpecifier o); + + /** + * Add order expressions + * + * @param o order + * @return the current object + */ + JPQLSubQuery orderBy(OrderSpecifier... o); + + /** + * Add the given filter condition + * + *

Skips null arguments + * + * @param o filter conditions to be added + * @return the current object + */ + JPQLSubQuery where(Predicate o); + + /** + * Add the given filter conditions + * + *

Skips null arguments + * + * @param o filter conditions to be added + * @return the current object + */ + JPQLSubQuery where(Predicate... o); + + /** + * Defines the limit / max results for the query results + * + * @param limit max rows + * @return the current object + */ + JPQLSubQuery limit(long limit); + + /** + * Defines the offset for the query results + * + * @param offset row offset + * @return the current object + */ + JPQLSubQuery offset(long offset); + + /** + * Defines both limit and offset of the query results, use {@link QueryModifiers#EMPTY} to apply + * no paging. + * + * @param modifiers query modifiers + * @return the current object + */ + JPQLSubQuery restrict(QueryModifiers modifiers); + + /** + * Set the given parameter to the given value + * + * @param

+ * @param param param + * @param value binding + * @return the current object + */ +

JPQLSubQuery set(ParamExpression

param, P value); +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLTemplates.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLTemplates.java new file mode 100644 index 0000000000..dbb89a0ff5 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/JPQLTemplates.java @@ -0,0 +1,239 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.types.Operator; +import com.querydsl.core.types.Ops; +import com.querydsl.core.types.PathType; +import com.querydsl.core.types.Templates; +import java.util.Collections; +import java.util.EnumSet; +import java.util.Set; +import org.jetbrains.annotations.Nullable; + +/** + * {@code JPQLTemplates} extends {@link Templates} to provide operator patterns for JPQL + * serialization + * + * @author tiwe + * @see HQLTemplates + * @see EclipseLinkTemplates + */ +public class JPQLTemplates extends Templates { + + public static final char DEFAULT_ESCAPE = '!'; + + protected static final Set OTHER_LIKE_CASES = + Collections.unmodifiableSet( + EnumSet.of( + Ops.MATCHES, + Ops.MATCHES_IC, + Ops.ENDS_WITH, + Ops.ENDS_WITH_IC, + Ops.LIKE_IC, + Ops.LIKE_ESCAPE_IC, + Ops.STARTS_WITH, + Ops.STARTS_WITH_IC, + Ops.STRING_CONTAINS, + Ops.STRING_CONTAINS_IC)); + + public static final JPQLTemplates DEFAULT = new JPQLTemplates(); + + private final QueryHandler queryHandler; + + protected JPQLTemplates() { + this(DEFAULT_ESCAPE, DefaultQueryHandler.DEFAULT); + } + + protected JPQLTemplates(char escape) { + this(escape, DefaultQueryHandler.DEFAULT); + } + + protected JPQLTemplates(char escape, QueryHandler queryHandler) { + super(escape); + this.queryHandler = queryHandler; + + setPrecedence( + Precedence.COMPARISON, Ops.EQ, Ops.NE, Ops.EQ_IGNORE_CASE, Ops.BETWEEN, Ops.COL_IS_EMPTY); + + // other like cases + setPrecedence(Precedence.COMPARISON, OTHER_LIKE_CASES); + + add(Ops.CASE, "case {0} end"); + add(Ops.CASE_WHEN, "when {0} then {1} {2}", 0); + add(Ops.CASE_ELSE, "else {0}", 0); + + // CHECKSTYLE:OFF + // boolean + add(Ops.AND, "{0} and {1}"); + add(Ops.NOT, "not {0}", Precedence.NOT); + add(Ops.OR, "{0} or {1}"); + add(Ops.XNOR, "{0} xnor {1}"); + add(Ops.XOR, "{0} xor {1}"); + + // comparison + add(Ops.BETWEEN, "{0} between {1} and {2}"); + + // numeric + add(Ops.MathOps.SQRT, "sqrt({0})"); + add(Ops.MOD, "mod({0},{1})", -1); + + // various + add(Ops.NE, "{0} <> {1}"); + add(Ops.IS_NULL, "{0} is null"); + add(Ops.IS_NOT_NULL, "{0} is not null"); + add(JPQLOps.CAST, "cast({0} as {1s})"); + add(Ops.NUMCAST, "cast({0} as {1s})"); + + // collection + add(JPQLOps.MEMBER_OF, "{0} member of {1}", Precedence.COMPARISON); + add(JPQLOps.NOT_MEMBER_OF, "{0} not member of {1}", Precedence.COMPARISON); + + add(Ops.IN, "{0} in {1}"); + add(Ops.NOT_IN, "{0} not in {1}"); + add(Ops.COL_IS_EMPTY, "{0} is empty"); + add(Ops.COL_SIZE, "size({0})"); + add(Ops.ARRAY_SIZE, "size({0})"); + + // string + add(Ops.LIKE, "{0} like {1} escape '" + escape + "'"); + add(Ops.CONCAT, "concat({0},{1})", -1); + add(Ops.MATCHES, "{0} like {1} escape '" + escape + "'"); // TODO : support real regexes + add(Ops.MATCHES_IC, "{0} like {1} escape '" + escape + "'"); // TODO : support real regexes + add(Ops.LOWER, "lower({0})"); + add(Ops.SUBSTR_1ARG, "substring({0},{1+'1's})"); + add(Ops.SUBSTR_2ARGS, "substring({0},{1+'1's},{2-1s})"); + add(Ops.TRIM, "trim({0})"); + add(Ops.UPPER, "upper({0})"); + add(Ops.EQ_IGNORE_CASE, "{0l} = {1l}"); + add(Ops.CHAR_AT, "cast(substring({0},{1+'1's},1) as char)", Precedence.ARITH_LOW); + add(Ops.STRING_IS_EMPTY, "length({0}) = 0"); + + add(Ops.STRING_CONTAINS, "{0} like {%1%} escape '" + escape + "'"); + add(Ops.STRING_CONTAINS_IC, "{0l} like {%%1%%} escape '" + escape + "'"); + add(Ops.ENDS_WITH, "{0} like {%1} escape '" + escape + "'"); + add(Ops.ENDS_WITH_IC, "{0l} like {%%1} escape '" + escape + "'"); + add(Ops.STARTS_WITH, "{0} like {1%} escape '" + escape + "'"); + add(Ops.STARTS_WITH_IC, "{0l} like {1%%} escape '" + escape + "'"); + add(Ops.INDEX_OF, "locate({1},{0})-1", Precedence.ARITH_LOW); + add(Ops.INDEX_OF_2ARGS, "locate({1},{0},{2+'1's})-1", Precedence.ARITH_LOW); + + // date time + add(Ops.DateTimeOps.SYSDATE, "sysdate"); + add(Ops.DateTimeOps.CURRENT_DATE, "current_date"); + add(Ops.DateTimeOps.CURRENT_TIME, "current_time"); + add(Ops.DateTimeOps.CURRENT_TIMESTAMP, "current_timestamp"); + + add(Ops.DateTimeOps.MILLISECOND, "0"); // NOT supported in HQL + add(Ops.DateTimeOps.SECOND, "second({0})"); + add(Ops.DateTimeOps.MINUTE, "minute({0})"); + add(Ops.DateTimeOps.HOUR, "hour({0})"); + add(Ops.DateTimeOps.DAY_OF_MONTH, "day({0})"); + add(Ops.DateTimeOps.MONTH, "month({0})"); + add(Ops.DateTimeOps.YEAR, "year({0})"); + + add(Ops.DateTimeOps.YEAR_MONTH, "year({0}) * 100 + month({0})", Precedence.ARITH_LOW); + add(Ops.DateTimeOps.YEAR_WEEK, "year({0}) * 100 + week({0})", Precedence.ARITH_LOW); + + // path types + add(PathType.PROPERTY, "{0}.{1s}"); + add(PathType.VARIABLE, "{0s}"); + add(PathType.TREATED_PATH, "treat({0} as {1s})"); + + // case for eq + add(Ops.CASE_EQ, "case {1} end"); + add(Ops.CASE_EQ_WHEN, "when {0} = {1} then {2} {3}", 0); + add(Ops.CASE_EQ_ELSE, "else {0}", 0); + + add(Ops.INSTANCE_OF, "type({0}) = {1}"); + add(JPQLOps.TYPE, "type({0})"); + add(JPQLOps.INDEX, "index({0})"); + add(JPQLOps.TREAT, "treat({0} as {1s})"); + add(JPQLOps.KEY, "key({0})"); + add(JPQLOps.VALUE, "value({0})"); + + // CHECKSTYLE:ON + } + + public boolean wrapElements(Operator operator) { + return false; + } + + public String getTypeForCast(Class cl) { + return cl.getSimpleName().toLowerCase(); + } + + @Deprecated // kept for backwards compatibility + public boolean isEnumInPathSupported() { + return true; + } + + public boolean isPathInEntitiesSupported() { + return true; + } + + @Nullable + public String getExistsProjection() { + return null; + } + + public boolean wrapConstant(Object constant) { + // related : https://hibernate.onjira.com/browse/HHH-6913 + return false; + } + + public boolean isWithForOn() { + return false; + } + + public QueryHandler getQueryHandler() { + return queryHandler; + } + + public boolean isCaseWithLiterals() { + return false; + } + + public String asLiteral(Object constant) { + if (constant instanceof Boolean) { + return constant.toString(); + } else if (constant instanceof Number) { + return constant.toString(); + } else if (constant instanceof String) { + return "'" + escapeLiteral(constant.toString()) + "'"; + } else if (constant instanceof Enum enum1) { + return constant.getClass().getName() + "." + enum1.name(); + } else { + return "'" + constant.toString() + "'"; + } + } + + private String escapeLiteral(String str) { + var builder = new StringBuilder(); + for (char ch : str.toCharArray()) { + if (ch == '\n') { + builder.append("\\n"); + continue; + } else if (ch == '\r') { + builder.append("\\r"); + continue; + } else if (ch == '\'') { + builder.append("''"); + continue; + } + builder.append(ch); + } + return builder.toString(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/OpenJPATemplates.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/OpenJPATemplates.java new file mode 100644 index 0000000000..1f95fbc65f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/OpenJPATemplates.java @@ -0,0 +1,38 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.types.Ops; +import com.querydsl.core.types.PathType; + +/** + * {@code OpenJPATemplates} extends {@link JPQLTemplates} with OpenJPA specific extensions + * + * @author tiwe + */ +public class OpenJPATemplates extends JPQLTemplates { + + public static final OpenJPATemplates DEFAULT = new OpenJPATemplates(); + + public OpenJPATemplates() { + this(DEFAULT_ESCAPE); + add(PathType.VARIABLE, "{0s}_"); + add(Ops.ALIAS, "{0} {1}"); + add(Ops.NEGATE, "-1 * {0}", 7); + } + + public OpenJPATemplates(char escape) { + super(escape); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/QueryHandler.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/QueryHandler.java new file mode 100644 index 0000000000..2c2e087110 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/QueryHandler.java @@ -0,0 +1,85 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.CloseableIterator; +import com.querydsl.core.types.FactoryExpression; +import jakarta.persistence.Query; +import java.util.stream.Stream; +import org.jetbrains.annotations.Nullable; + +/** + * {@code QueryHandle}r provides injection of provider specific functionality into the query logic + * + * @author tiwe + */ +public interface QueryHandler { + + /** + * Return whether native queries should be created as typed queries + * + * @return whether native queries should be created as typed queries + */ + boolean createNativeQueryTyped(); + + /** + * Iterate the results with the optional projection + * + * @param query query + * @return iterator + */ + CloseableIterator iterate(Query query, @Nullable FactoryExpression projection); + + /** + * Stream the results with the optional projection + * + * @param query query + * @return stream + */ + Stream stream(Query query, @Nullable FactoryExpression projection); + + /** + * Add the given scalar to the given native query + * + * @param query query + * @param alias alias + * @param type type + */ + void addScalar(Query query, String alias, Class type); + + /** + * Add the given entity to the given native query + * + * @param query query + * @param alias alias + * @param type type + */ + void addEntity(Query query, String alias, Class type); + + /** + * Transform the results of the given query using the given factory expression + * + * @param query query + * @param projection projection + * @return true, if query as been modified + */ + boolean transform(Query query, FactoryExpression projection); + + /** + * Return whether entity projections need to be wrapped + * + * @return whether entity projections need to be wrapped + */ + boolean wrapEntityProjections(); +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/ScrollableResultsIterator.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/ScrollableResultsIterator.java new file mode 100644 index 0000000000..4be986252d --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/ScrollableResultsIterator.java @@ -0,0 +1,56 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in + * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.CloseableIterator; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; + +/** + * {@code ScrollableResultsIterator} is a {@link CloseableIterator} adapter for ScrollableResults + * + * @author tiwe + * @param + */ +public class ScrollableResultsIterator implements CloseableIterator { + + private final Iterator results; + + public ScrollableResultsIterator(List results) { + this.results = results.iterator(); + } + + @SuppressWarnings("unchecked") + @Override + public boolean hasNext() { + return results.hasNext(); + } + + @Override + public T next() { + if (results != null) { + return results.next(); + } else { + throw new NoSuchElementException(); + } + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + @Override + public void close() { + // do nothing + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/TransformingIterator.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/TransformingIterator.java new file mode 100644 index 0000000000..9db5f0ff5a --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/TransformingIterator.java @@ -0,0 +1,84 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.CloseableIterator; +import com.querydsl.core.types.FactoryExpression; +import java.io.Closeable; +import java.io.IOException; +import java.util.Iterator; + +/** + * {@code TransformingIterator} is a CloseableIterator adapter that transforms via a {@link + * FactoryExpression} instance + * + * @author tiwe + * @param + */ +public class TransformingIterator implements CloseableIterator { + + private final Iterator iterator; + + private final Closeable closeable; + + private final FactoryExpression projection; + + public TransformingIterator(Iterator iterator, FactoryExpression projection) { + this.iterator = iterator; + this.projection = projection; + this.closeable = iterator instanceof Closeable c ? c : null; + } + + public TransformingIterator( + Iterator iterator, Closeable closeable, FactoryExpression projection) { + this.iterator = iterator; + this.projection = projection; + this.closeable = closeable; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @SuppressWarnings("unchecked") + @Override + public T next() { + Object result = iterator.next(); + if (result != null) { + if (!result.getClass().isArray()) { + result = new Object[] {result}; + } + return (T) projection.newInstance((Object[]) result); + } else { + return null; + } + } + + @Override + public void remove() { + iterator.remove(); + } + + @Override + public void close() { + if (closeable != null) { + try { + closeable.close(); + } catch (IOException e) { + throw new RuntimeException(e.getMessage(), e); + } + } + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/AbstractHibernateQuery.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/AbstractHibernateQuery.java new file mode 100644 index 0000000000..6c637cdb25 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/AbstractHibernateQuery.java @@ -0,0 +1,327 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.hibernate; + +import com.querydsl.core.DefaultQueryMetadata; +import com.querydsl.core.QueryException; +import com.querydsl.core.QueryMetadata; +import com.querydsl.core.QueryModifiers; +import com.querydsl.core.types.Path; +import com.querydsl.jpa.HQLTemplates; +import com.querydsl.jpa.JPAQueryBase; +import com.querydsl.jpa.JPQLSerializer; +import com.querydsl.jpa.JPQLTemplates; +import io.smallrye.mutiny.Uni; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.hibernate.FlushMode; +import org.hibernate.LockMode; +import org.hibernate.reactive.mutiny.Mutiny; +import org.hibernate.reactive.mutiny.Mutiny.SelectionQuery; +import org.jetbrains.annotations.Nullable; + +/** + * Abstract base class for Hibernate API based implementations of the JPQL interface + * + * @param result type + * @param concrete subtype + * @author tiwe + */ +public abstract class AbstractHibernateQuery> + extends JPAQueryBase { + + private static final Logger logger = Logger.getLogger(HibernateQuery.class.getName()); + + @Nullable protected Boolean cacheable, readOnly; + @Nullable protected String cacheRegion, comment; + + protected int fetchSize = 0; + + protected final Map, LockMode> lockModes = new HashMap<>(); + + @Nullable protected FlushMode flushMode; + + private final SessionHolder session; + + protected int timeout = 0; + + public AbstractHibernateQuery(Mutiny.Session session) { + this(new DefaultSessionHolder(session), HQLTemplates.DEFAULT, new DefaultQueryMetadata()); + } + + public AbstractHibernateQuery( + SessionHolder session, JPQLTemplates patterns, QueryMetadata metadata) { + super(metadata, patterns); + this.session = session; + } + + /** + * Expose the original Hibernate query for the given projection + * + * @return query + */ + public Mutiny.SelectionQuery createQuery() { + return (SelectionQuery) + createQuery(getMetadata().getModifiers(), false, getMetadata().getProjection().getType()); + } + + private Mutiny.SelectionQuery createQuery( + @Nullable QueryModifiers modifiers, boolean forCount, Class resultType) { + var serializer = serialize(forCount); + var queryString = serializer.toString(); + logQuery(queryString); + var query = session.createQuery(queryString, resultType); + HibernateUtil.setConstants(query, serializer.getConstants(), getMetadata().getParams()); + if (fetchSize > 0) { + query.setMaxResults(fetchSize); + } + // FIXME if (timeout > 0) { + // query.setTimeout(timeout); + // } + if (cacheable != null) { + query.setCacheable(cacheable); + } + if (cacheRegion != null) { + query.setCacheRegion(cacheRegion); + } + if (comment != null) { + query.setComment(comment); + } + if (readOnly != null) { + query.setReadOnly(readOnly); + } + for (Map.Entry, LockMode> entry : lockModes.entrySet()) { + query.setLockMode(entry.getKey().toString(), entry.getValue()); + } + if (flushMode != null) { + query.setFlushMode(flushMode); + } + + if (modifiers != null && modifiers.isRestricting()) { + Integer limit = modifiers.getLimitAsInteger(); + Integer offset = modifiers.getOffsetAsInteger(); + if (limit != null) { + query.setMaxResults(limit); + } + if (offset != null) { + query.setFirstResult(offset); + } + } + + // set transformer, if necessary + // FIXME Expression projection = getMetadata().getProjection(); + // if (!forCount && projection instanceof FactoryExpression) { + // query.setResultTransformer( + // new FactoryExpressionTransformer((FactoryExpression) projection)); + // } + return query; + } + + @Override + public Uni> fetch() { + return createQuery().getResultList(); + } + + @Override + public final Uni fetchFirst() { + return createQuery().setMaxResults(1).getSingleResultOrNull(); + } + + @Override + public Uni fetchOne() { + return createQuery().getSingleResult(); + } + + @Override + public Uni fetchCount() { + var query = createQuery(); + var rv = query.getResultCount(); + if (rv != null) { + return rv; + } else { + throw new QueryException("Query returned null"); + } + } + + // + // @Override + // public QueryResults fetchResults() { + // try { + // var countQuery = createQuery(null, true); + // long total = (Long) countQuery.uniqueResult(); + // + // if (total > 0) { + // var modifiers = getMetadata().getModifiers(); + // var query = createQuery(modifiers, false); + // @SuppressWarnings("unchecked") + // List list = query.list(); + // return new QueryResults<>(list, modifiers, total); + // } else { + // return QueryResults.emptyResults(); + // } + // } finally { + // reset(); + // } + // } + + protected void logQuery(String queryString) { + if (logger.isLoggable(Level.FINE)) { + var normalizedQuery = queryString.replace('\n', ' '); + logger.fine(normalizedQuery); + } + } + + /** + * Enable caching of this query result set. + * + * @param cacheable Should the query results be cacheable? + */ + @SuppressWarnings("unchecked") + public Q setCacheable(boolean cacheable) { + this.cacheable = cacheable; + return (Q) this; + } + + /** + * Set the name of the cache region. + * + * @param cacheRegion the name of a query cache region, or {@code null} for the default query + * cache + */ + @SuppressWarnings("unchecked") + public Q setCacheRegion(String cacheRegion) { + this.cacheRegion = cacheRegion; + return (Q) this; + } + + /** + * Add a comment to the generated SQL. + * + * @param comment comment + * @return the current object + */ + @SuppressWarnings("unchecked") + public Q setComment(String comment) { + this.comment = comment; + return (Q) this; + } + + /** + * Set a fetchJoin size for the underlying JDBC query. + * + * @param fetchSize the fetchJoin size + * @return the current object + */ + @SuppressWarnings("unchecked") + public Q setFetchSize(int fetchSize) { + this.fetchSize = fetchSize; + return (Q) this; + } + + /** + * Set the lock mode for the given path. + * + * @return the current object + */ + @SuppressWarnings("unchecked") + public Q setLockMode(Path path, LockMode lockMode) { + lockModes.put(path, lockMode); + return (Q) this; + } + + /** + * Override the current session flush mode, just for this query. + * + * @return the current object + */ + @SuppressWarnings("unchecked") + public Q setFlushMode(FlushMode flushMode) { + this.flushMode = flushMode; + return (Q) this; + } + + /** + * Entities retrieved by this query will be loaded in a read-only mode where Hibernate will never + * dirty-check them or make changes persistent. + * + * @return the current object + */ + @SuppressWarnings("unchecked") + public Q setReadOnly(boolean readOnly) { + this.readOnly = readOnly; + return (Q) this; + } + + /** + * Set a timeout for the underlying JDBC query. + * + * @param timeout the timeout in seconds + * @return the current object + */ + @SuppressWarnings("unchecked") + public Q setTimeout(int timeout) { + this.timeout = timeout; + return (Q) this; + } + + @Override + protected JPQLSerializer createSerializer() { + return new JPQLSerializer(getTemplates()); + } + + protected void clone(Q query) { + cacheable = query.cacheable; + cacheRegion = query.cacheRegion; + fetchSize = query.fetchSize; + flushMode = query.flushMode; + lockModes.putAll(query.lockModes); + readOnly = query.readOnly; + timeout = query.timeout; + } + + protected abstract Q clone(SessionHolder sessionHolder); + + /** + * Clone the state of this query to a new instance with the given Session + * + * @param session session + * @return cloned query + */ + public Q clone(Mutiny.Session session) { + return this.clone(new DefaultSessionHolder(session)); + } + + /** + * Clone the state of this query to a new instance with the given StatelessSession + * + * @param session session + * @return cloned query + */ + public Q clone(Mutiny.StatelessSession session) { + return this.clone(new StatelessSessionHolder(session)); + } + + /** + * Clone the state of this query to a new instance + * + * @return closed query + */ + @Override + public Q clone() { + return this.clone(this.session); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/DefaultSessionHolder.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/DefaultSessionHolder.java new file mode 100644 index 0000000000..19b1c1de51 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/DefaultSessionHolder.java @@ -0,0 +1,46 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.hibernate; + +import org.hibernate.reactive.mutiny.Mutiny; +import org.hibernate.reactive.mutiny.Mutiny.MutationQuery; + +/** + * {@code DefaultSessionHolder} is the default implementation of the {@link SessionHolder} interface + * + * @author tiwe + */ +public class DefaultSessionHolder implements SessionHolder { + + private final Mutiny.Session session; + + public DefaultSessionHolder(Mutiny.Session session) { + this.session = session; + } + + @Override + public Mutiny.SelectionQuery createQuery(String queryString, Class resultType) { + return session.createQuery(queryString, resultType); + } + + @Override + public MutationQuery createMutationQuery(String queryString) { + return session.createMutationQuery(queryString); + } + + @Override + public Mutiny.Query createSQLQuery(String queryString) { + return session.createNativeQuery(queryString); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/HibernateDeleteClause.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/HibernateDeleteClause.java new file mode 100644 index 0000000000..da32803444 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/HibernateDeleteClause.java @@ -0,0 +1,86 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.hibernate; + +import com.querydsl.core.JoinType; +import com.querydsl.core.dml.mutiny.MutinyDeleteClause; +import com.querydsl.core.support.QueryMixin; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.Predicate; +import com.querydsl.jpa.HQLTemplates; +import com.querydsl.jpa.JPAQueryMixin; +import com.querydsl.jpa.JPQLSerializer; +import com.querydsl.jpa.JPQLTemplates; +import io.smallrye.mutiny.Uni; +import org.hibernate.reactive.mutiny.Mutiny; + +/** + * DeleteClause implementation for Hibernate + * + * @author tiwe + */ +public class HibernateDeleteClause implements MutinyDeleteClause { + + private final QueryMixin queryMixin = new JPAQueryMixin(); + + private final SessionHolder session; + + private final JPQLTemplates templates; + + public HibernateDeleteClause(Mutiny.Session session, EntityPath entity) { + this(new DefaultSessionHolder(session), entity, HQLTemplates.DEFAULT); + } + + public HibernateDeleteClause(Mutiny.StatelessSession session, EntityPath entity) { + this(new StatelessSessionHolder(session), entity, HQLTemplates.DEFAULT); + } + + public HibernateDeleteClause( + Mutiny.Session session, EntityPath entity, JPQLTemplates templates) { + this(new DefaultSessionHolder(session), entity, templates); + } + + public HibernateDeleteClause( + SessionHolder session, EntityPath entity, JPQLTemplates templates) { + this.session = session; + this.templates = templates; + queryMixin.addJoin(JoinType.DEFAULT, entity); + } + + @Override + public Uni execute() { + var serializer = new JPQLSerializer(templates, null); + serializer.serializeForDelete(queryMixin.getMetadata()); + + var query = session.createMutationQuery(serializer.toString()); + HibernateUtil.setConstants( + query, serializer.getConstants(), queryMixin.getMetadata().getParams()); + return query.executeUpdate(); + } + + @Override + public HibernateDeleteClause where(Predicate... o) { + for (Predicate p : o) { + queryMixin.where(p); + } + return this; + } + + @Override + public String toString() { + var serializer = new JPQLSerializer(templates, null); + serializer.serializeForDelete(queryMixin.getMetadata()); + return serializer.toString(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/HibernateInsertClause.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/HibernateInsertClause.java new file mode 100644 index 0000000000..328314d324 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/HibernateInsertClause.java @@ -0,0 +1,168 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.hibernate; + +import com.querydsl.core.JoinType; +import com.querydsl.core.dml.mutiny.MutinyInsertClause; +import com.querydsl.core.support.QueryMixin; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.SubQueryExpression; +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.jpa.HQLTemplates; +import com.querydsl.jpa.JPAQueryMixin; +import com.querydsl.jpa.JPQLSerializer; +import com.querydsl.jpa.JPQLTemplates; +import io.smallrye.mutiny.Uni; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import org.hibernate.LockMode; +import org.hibernate.reactive.mutiny.Mutiny; + +/** + * UpdateClause implementation for Hibernate + * + * @author tiwe + */ +public class HibernateInsertClause implements MutinyInsertClause { + + private final QueryMixin queryMixin = new JPAQueryMixin(); + + private final Map, Expression> inserts = new LinkedHashMap<>(); + + private final List> columns = new ArrayList<>(); + + private final List values = new ArrayList<>(); + + private SubQueryExpression subQuery; + + private final SessionHolder session; + + private final JPQLTemplates templates; + + private final Map, LockMode> lockModes = new HashMap<>(); + + public HibernateInsertClause(Mutiny.Session session, EntityPath entity) { + this(new DefaultSessionHolder(session), entity, HQLTemplates.DEFAULT); + } + + public HibernateInsertClause(Mutiny.StatelessSession session, EntityPath entity) { + this(new StatelessSessionHolder(session), entity, HQLTemplates.DEFAULT); + } + + public HibernateInsertClause( + Mutiny.Session session, EntityPath entity, JPQLTemplates templates) { + this(new DefaultSessionHolder(session), entity, templates); + } + + public HibernateInsertClause( + SessionHolder session, EntityPath entity, JPQLTemplates templates) { + this.session = session; + this.templates = templates; + queryMixin.addJoin(JoinType.DEFAULT, entity); + } + + @Override + public Uni execute() { + var serializer = new JPQLSerializer(templates, null); + serializer.serializeForInsert( + queryMixin.getMetadata(), + inserts.isEmpty() ? columns : inserts.keySet(), + values, + subQuery, + inserts); + + var query = session.createMutationQuery(serializer.toString()); + HibernateUtil.setConstants( + query, serializer.getConstants(), queryMixin.getMetadata().getParams()); + return query.executeUpdate(); + } + + @Override + public HibernateInsertClause columns(Path... columns) { + this.columns.addAll(Arrays.asList(columns)); + return this; + } + + @Override + public HibernateInsertClause select(SubQueryExpression sq) { + subQuery = sq; + return this; + } + + /** + * Set the lock mode for the given path. + * + * @return the current object + */ + @SuppressWarnings("unchecked") + public HibernateInsertClause setLockMode(Path path, LockMode lockMode) { + lockModes.put(path, lockMode); + return this; + } + + @Override + public String toString() { + var serializer = new JPQLSerializer(templates, null); + serializer.serializeForInsert( + queryMixin.getMetadata(), + inserts.isEmpty() ? columns : inserts.keySet(), + values, + subQuery, + inserts); + return serializer.toString(); + } + + @Override + public boolean isEmpty() { + return columns.isEmpty(); + } + + @Override + public HibernateInsertClause set(Path path, T value) { + if (value != null) { + inserts.put(path, Expressions.constant(value)); + } else { + setNull(path); + } + return this; + } + + @Override + public HibernateInsertClause set(Path path, Expression expression) { + if (expression != null) { + inserts.put(path, expression); + } else { + setNull(path); + } + return this; + } + + @Override + public HibernateInsertClause setNull(Path path) { + inserts.put(path, Expressions.nullExpression(path)); + return this; + } + + @Override + public HibernateInsertClause values(Object... v) { + this.values.addAll(Arrays.asList(v)); + return this; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/HibernateQuery.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/HibernateQuery.java new file mode 100644 index 0000000000..08c9f051f9 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/HibernateQuery.java @@ -0,0 +1,119 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.hibernate; + +import com.querydsl.core.DefaultQueryMetadata; +import com.querydsl.core.QueryMetadata; +import com.querydsl.core.Tuple; +import com.querydsl.core.types.Expression; +import com.querydsl.jpa.HQLTemplates; +import com.querydsl.jpa.JPQLQuery; +import com.querydsl.jpa.JPQLTemplates; +import org.hibernate.reactive.mutiny.Mutiny; + +/** + * {@code HibernateQuery} is the default implementation of the JPQLQuery interface for Hibernate + * + * @param result type + * @author tiwe + */ +public class HibernateQuery extends AbstractHibernateQuery> + implements JPQLQuery { + + /** Creates a detached query The query can be attached via the clone method */ + public HibernateQuery() { + super(NoSessionHolder.DEFAULT, HQLTemplates.DEFAULT, new DefaultQueryMetadata()); + } + + /** + * Creates a new Session bound query + * + * @param session session + */ + public HibernateQuery(Mutiny.Session session) { + super(new DefaultSessionHolder(session), HQLTemplates.DEFAULT, new DefaultQueryMetadata()); + } + + /** + * Creates a new Session bound query + * + * @param session session + */ + public HibernateQuery(Mutiny.Session session, QueryMetadata metadata) { + super(new DefaultSessionHolder(session), HQLTemplates.DEFAULT, metadata); + } + + /** + * Creates a new Session bound query + * + * @param session session + * @param templates templates + */ + public HibernateQuery(Mutiny.Session session, JPQLTemplates templates) { + super(new DefaultSessionHolder(session), templates, new DefaultQueryMetadata()); + } + + /** + * Creates a new Stateless session bound query + * + * @param session session + */ + public HibernateQuery(Mutiny.StatelessSession session) { + super(new StatelessSessionHolder(session), HQLTemplates.DEFAULT, new DefaultQueryMetadata()); + } + + /** + * Creates a new Session bound query + * + * @param session session + * @param templates templates + */ + public HibernateQuery(SessionHolder session, JPQLTemplates templates) { + super(session, templates, new DefaultQueryMetadata()); + } + + /** + * Creates a new Session bound query + * + * @param session session + * @param templates templates + * @param metadata query metadata + */ + public HibernateQuery(SessionHolder session, JPQLTemplates templates, QueryMetadata metadata) { + super(session, templates, metadata); + } + + @Override + protected HibernateQuery clone(SessionHolder sessionHolder) { + var q = new HibernateQuery(sessionHolder, getTemplates(), getMetadata().clone()); + q.clone(this); + return q; + } + + @Override + public HibernateQuery select(Expression expr) { + queryMixin.setProjection(expr); + @SuppressWarnings("unchecked") // This is the new type + var newType = (HibernateQuery) this; + return newType; + } + + @Override + public HibernateQuery select(Expression... exprs) { + queryMixin.setProjection(exprs); + @SuppressWarnings("unchecked") // This is the new type + var newType = (HibernateQuery) this; + return newType; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/HibernateUpdateClause.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/HibernateUpdateClause.java new file mode 100644 index 0000000000..70c5aa1037 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/HibernateUpdateClause.java @@ -0,0 +1,138 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.hibernate; + +import com.querydsl.core.JoinType; +import com.querydsl.core.dml.mutiny.MutinyUpdateClause; +import com.querydsl.core.support.QueryMixin; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.jpa.HQLTemplates; +import com.querydsl.jpa.JPAQueryMixin; +import com.querydsl.jpa.JPQLSerializer; +import com.querydsl.jpa.JPQLTemplates; +import io.smallrye.mutiny.Uni; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import org.hibernate.reactive.mutiny.Mutiny; + +/** + * UpdateClause implementation for Hibernate + * + * @author tiwe + */ +public class HibernateUpdateClause implements MutinyUpdateClause { + + private final QueryMixin queryMixin = new JPAQueryMixin(); + + private final Map, Expression> updates = new LinkedHashMap<>(); + + private final SessionHolder session; + + private final JPQLTemplates templates; + + public HibernateUpdateClause(Mutiny.Session session, EntityPath entity) { + this(new DefaultSessionHolder(session), entity, HQLTemplates.DEFAULT); + } + + public HibernateUpdateClause(Mutiny.StatelessSession session, EntityPath entity) { + this(new StatelessSessionHolder(session), entity, HQLTemplates.DEFAULT); + } + + public HibernateUpdateClause( + Mutiny.Session session, EntityPath entity, JPQLTemplates templates) { + this(new DefaultSessionHolder(session), entity, templates); + } + + public HibernateUpdateClause( + SessionHolder session, EntityPath entity, JPQLTemplates templates) { + this.session = session; + this.templates = templates; + queryMixin.addJoin(JoinType.DEFAULT, entity); + } + + @Override + public Uni execute() { + var serializer = new JPQLSerializer(templates, null); + serializer.serializeForUpdate(queryMixin.getMetadata(), updates); + + var query = session.createMutationQuery(serializer.toString()); + HibernateUtil.setConstants( + query, serializer.getConstants(), queryMixin.getMetadata().getParams()); + return query.executeUpdate(); + } + + @Override + public HibernateUpdateClause set(Path path, T value) { + if (value != null) { + updates.put(path, Expressions.constant(value)); + } else { + setNull(path); + } + return this; + } + + @Override + public HibernateUpdateClause set(Path path, Expression expression) { + if (expression != null) { + updates.put(path, expression); + } else { + setNull(path); + } + return this; + } + + @Override + public HibernateUpdateClause setNull(Path path) { + updates.put(path, Expressions.nullExpression(path)); + return this; + } + + @SuppressWarnings("unchecked") + @Override + public HibernateUpdateClause set(List> paths, List values) { + for (var i = 0; i < paths.size(); i++) { + if (values.get(i) != null) { + updates.put(paths.get(i), Expressions.constant(values.get(i))); + } else { + updates.put(paths.get(i), Expressions.nullExpression(paths.get(i))); + } + } + return this; + } + + @Override + public HibernateUpdateClause where(Predicate... o) { + for (Predicate p : o) { + queryMixin.where(p); + } + return this; + } + + @Override + public String toString() { + var serializer = new JPQLSerializer(templates, null); + serializer.serializeForUpdate(queryMixin.getMetadata(), updates); + return serializer.toString(); + } + + @Override + public boolean isEmpty() { + return updates.isEmpty(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/HibernateUtil.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/HibernateUtil.java new file mode 100644 index 0000000000..4c4ab6c397 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/HibernateUtil.java @@ -0,0 +1,110 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.hibernate; + +import com.querydsl.core.types.ParamExpression; +import com.querydsl.core.types.ParamNotSetException; +import com.querydsl.core.types.dsl.Param; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.hibernate.reactive.mutiny.Mutiny.AbstractQuery; +import org.hibernate.type.BasicTypeReference; +import org.hibernate.type.StandardBasicTypes; + +/** + * {@code HibernateUtil} provides static utility methods for Hibernate + * + * @author tiwe + */ +public final class HibernateUtil { + + private static final Set> BUILT_IN = + Collections.unmodifiableSet( + new HashSet<>( + Arrays.asList( + Boolean.class, + Byte.class, + Character.class, + Double.class, + Float.class, + Integer.class, + Long.class, + Short.class, + String.class, + BigDecimal.class, + byte[].class, + Byte[].class, + java.util.Date.class, + java.util.Calendar.class, + java.sql.Date.class, + java.sql.Time.class, + java.sql.Timestamp.class, + java.util.Locale.class, + java.util.TimeZone.class, + java.util.Currency.class, + Class.class, + java.io.Serializable.class, + java.sql.Blob.class, + java.sql.Clob.class))); + + private static final Map, BasicTypeReference> TYPES; + + static { + Map, BasicTypeReference> builder = new HashMap<>(); + builder.put(Byte.class, StandardBasicTypes.BYTE); + builder.put(Short.class, StandardBasicTypes.SHORT); + builder.put(Integer.class, StandardBasicTypes.INTEGER); + builder.put(Long.class, StandardBasicTypes.LONG); + builder.put(BigInteger.class, StandardBasicTypes.BIG_INTEGER); + builder.put(Double.class, StandardBasicTypes.DOUBLE); + builder.put(Float.class, StandardBasicTypes.FLOAT); + builder.put(BigDecimal.class, StandardBasicTypes.BIG_DECIMAL); + builder.put(String.class, StandardBasicTypes.STRING); + builder.put(Character.class, StandardBasicTypes.CHARACTER); + builder.put(Date.class, StandardBasicTypes.DATE); + builder.put(Boolean.class, StandardBasicTypes.BOOLEAN); + TYPES = Collections.unmodifiableMap(builder); + } + + private HibernateUtil() {} + + public static void setConstants( + AbstractQuery query, List constants, Map, Object> params) { + for (var i = 0; i < constants.size(); i++) { + var val = constants.get(i); + + if (val instanceof Param) { + Param param = (Param) val; + val = params.get(val); + if (val == null) { + throw new ParamNotSetException(param); + } + } + + query.setParameter(i + 1, val); + } + } + + public static BasicTypeReference getType(Class clazz) { + return TYPES.get(clazz); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/MutinyQueryFactory.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/MutinyQueryFactory.java new file mode 100644 index 0000000000..c2999b7e09 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/MutinyQueryFactory.java @@ -0,0 +1,123 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.hibernate; + +import com.querydsl.core.types.EntityPath; +import com.querydsl.jpa.HQLTemplates; +import com.querydsl.jpa.JPQLTemplates; +import io.smallrye.mutiny.Uni; +import java.util.function.BiFunction; +import java.util.function.Function; +import org.hibernate.reactive.mutiny.Mutiny; +import org.hibernate.reactive.mutiny.Mutiny.Session; + +/** + * Factory class for query and DML clause creation + * + * @author tiwe + */ +public class MutinyQueryFactory { + + private final JPQLTemplates templates; + + private final Mutiny.SessionFactory sessionFactory; + + public MutinyQueryFactory(Mutiny.SessionFactory sessionFactory) { + this(HQLTemplates.DEFAULT, sessionFactory); + } + + public MutinyQueryFactory(JPQLTemplates templates, final Mutiny.SessionFactory sessionFactory) { + this.sessionFactory = sessionFactory; + this.templates = templates; + } + + HibernateDeleteClause delete(Session session, EntityPath path) { + return new HibernateDeleteClause(session, path, templates); + } + + HibernateUpdateClause update(Session session, EntityPath path) { + return new HibernateUpdateClause(session, path, templates); + } + + HibernateInsertClause insert(Session session, EntityPath path) { + return new HibernateInsertClause(session, path, templates); + } + + HibernateQuery query(Session session) { + return new HibernateQuery(session, templates); + } + + public Uni withQuery(Function, Uni> work) { + return sessionFactory.withSession(session -> work.apply(query(session))); + } + + public Uni withQuery(BiFunction, MutinySessionContext, Uni> work) { + return sessionFactory.withSession( + session -> work.apply(query(session), new MutinySessionContext(session))); + } + + public Uni withSelectFrom(EntityPath path, Function, Uni> work) { + return sessionFactory.withSession( + session -> work.apply(query(session).select(path).from(path))); + } + + public Uni withSelectFrom( + EntityPath path, BiFunction, MutinySessionContext, Uni> work) { + return sessionFactory.withSession( + session -> + work.apply(query(session).select(path).from(path), new MutinySessionContext(session))); + } + + public Uni withInsert( + EntityPath path, Function> work) { + return sessionFactory.withTransaction( + (session, transaction) -> work.apply(insert(session, path))); + } + + public Uni withInsert( + EntityPath path, + BiFunction> work) { + return sessionFactory.withTransaction( + (session, transaction) -> + work.apply(insert(session, path), new MutinyTransactionContext(session, transaction))); + } + + public Uni withUpdate( + EntityPath path, Function> work) { + return sessionFactory.withTransaction( + (session, transaction) -> work.apply(update(session, path))); + } + + public Uni withUpdate( + EntityPath path, + BiFunction> work) { + return sessionFactory.withTransaction( + (session, transaction) -> + work.apply(update(session, path), new MutinyTransactionContext(session, transaction))); + } + + public Uni withDelete( + EntityPath path, Function> work) { + return sessionFactory.withTransaction( + (session, transaction) -> work.apply(delete(session, path))); + } + + public Uni withDelete( + EntityPath path, + BiFunction> work) { + return sessionFactory.withTransaction( + (session, transaction) -> + work.apply(delete(session, path), new MutinyTransactionContext(session, transaction))); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/MutinySessionContext.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/MutinySessionContext.java new file mode 100644 index 0000000000..14798b343f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/MutinySessionContext.java @@ -0,0 +1,5 @@ +package com.querydsl.jpa.hibernate; + +import org.hibernate.reactive.mutiny.Mutiny; + +public record MutinySessionContext(Mutiny.Session session) {} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/MutinyTransactionContext.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/MutinyTransactionContext.java new file mode 100644 index 0000000000..0d181856bd --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/MutinyTransactionContext.java @@ -0,0 +1,5 @@ +package com.querydsl.jpa.hibernate; + +import org.hibernate.reactive.mutiny.Mutiny; + +public record MutinyTransactionContext(Mutiny.Session session, Mutiny.Transaction transaction) {} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/NoSessionHolder.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/NoSessionHolder.java new file mode 100644 index 0000000000..b54f9b7fea --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/NoSessionHolder.java @@ -0,0 +1,44 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.hibernate; + +import org.hibernate.reactive.mutiny.Mutiny; +import org.hibernate.reactive.mutiny.Mutiny.MutationQuery; + +/** + * {@code NoSessionHolder} is a session holder for detached {@link HibernateQuery} usage + * + * @author tiwe + */ +public final class NoSessionHolder implements SessionHolder { + + public static final SessionHolder DEFAULT = new NoSessionHolder(); + + private NoSessionHolder() {} + + @Override + public Mutiny.Query createSQLQuery(String queryString) { + throw new UnsupportedOperationException("No session in detached Query available"); + } + + @Override + public Mutiny.SelectionQuery createQuery(String queryString, Class resultType) { + throw new UnsupportedOperationException("No session in detached Query available"); + } + + @Override + public MutationQuery createMutationQuery(String queryString) { + throw new UnsupportedOperationException("No session in detached Query available"); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/SessionHolder.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/SessionHolder.java new file mode 100644 index 0000000000..7db5e4c065 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/SessionHolder.java @@ -0,0 +1,43 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.hibernate; + +import org.hibernate.reactive.mutiny.Mutiny; +import org.hibernate.reactive.mutiny.Mutiny.MutationQuery; + +/** + * Abstraction for different Hibernate Session signatures + * + * @author tiwe + */ +public interface SessionHolder { + + /** + * Create a JPQL query for the given query string + * + * @param queryString JPQL query string + * @return query + */ + Mutiny.SelectionQuery createQuery(String queryString, Class resultType); + + /** + * Create an SQL query for the given query string + * + * @param queryString JPQL query string + * @return query + */ + Mutiny.Query createSQLQuery(String queryString); + + MutationQuery createMutationQuery(String queryString); +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/StatelessSessionHolder.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/StatelessSessionHolder.java new file mode 100644 index 0000000000..7a43a1a843 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/StatelessSessionHolder.java @@ -0,0 +1,48 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.hibernate; + +import org.hibernate.reactive.mutiny.Mutiny; +import org.hibernate.reactive.mutiny.Mutiny.MutationQuery; + +/** + * SessionHolder implementation using StatelessSession + * + * @author tiwe + */ +public class StatelessSessionHolder implements SessionHolder { + + private final Mutiny.StatelessSession session; + + public StatelessSessionHolder(Mutiny.StatelessSession session) { + this.session = session; + } + + @Override + @Deprecated + public Mutiny.Query createSQLQuery(String queryString) { + return session.createNativeQuery(queryString); + } + + @Override + @Deprecated + public Mutiny.SelectionQuery createQuery(String queryString, Class resultType) { + return session.createQuery(queryString, resultType); + } + + @Override + public MutationQuery createMutationQuery(String queryString) { + return session.createMutationQuery(queryString); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/package-info.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/package-info.java new file mode 100644 index 0000000000..a160da8a3c --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/hibernate/package-info.java @@ -0,0 +1,16 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** JPQL for Hibernate */ +package com.querydsl.jpa.hibernate; diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/package-info.java b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/package-info.java new file mode 100644 index 0000000000..7e926535fa --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/main/java/com/querydsl/jpa/package-info.java @@ -0,0 +1,16 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** JPA support */ +package com.querydsl.jpa; diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/PackagelessEntityTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/PackagelessEntityTest.java new file mode 100644 index 0000000000..dfcfd9e82e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/PackagelessEntityTest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import static com.querydsl.jpa.JPAExpressions.select; +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.types.dsl.PathBuilder; +import org.junit.Test; + +public class PackagelessEntityTest { + + @SuppressWarnings("unchecked") + @Test + public void packageLess_path() { + PathBuilder builder = + new PathBuilder(PackagelessEntityTest.class, "entity"); + var query = select(builder).from(builder); + assertThat(query).hasToString("select entity\nfrom PackagelessEntityTest entity"); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/AbstractJPATest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/AbstractJPATest.java new file mode 100644 index 0000000000..6f22696422 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/AbstractJPATest.java @@ -0,0 +1,2268 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.core.Target.DERBY; +import static com.querydsl.core.Target.HSQLDB; +import static com.querydsl.core.Target.MYSQL; +import static com.querydsl.core.Target.ORACLE; +import static com.querydsl.core.Target.POSTGRESQL; +import static com.querydsl.core.Target.SQLSERVER; +import static com.querydsl.core.Target.TERADATA; +import static com.querydsl.jpa.JPAExpressions.select; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.within; + +import com.mysema.commons.lang.Pair; +import com.querydsl.core.Fetchable; +import com.querydsl.core.FilterFactory; +import com.querydsl.core.MatchingFiltersFactory; +import com.querydsl.core.ProjectionsFactory; +import com.querydsl.core.QueryExecution; +import com.querydsl.core.QuerydslModule; +import com.querydsl.core.Target; +import com.querydsl.core.Tuple; +import com.querydsl.core.group.Group; +import com.querydsl.core.group.GroupBy; +import com.querydsl.core.group.MockTuple; +import com.querydsl.core.group.QPair; +import com.querydsl.core.testutil.ExcludeIn; +import com.querydsl.core.types.ArrayConstructorExpression; +import com.querydsl.core.types.Concatenation; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.ExpressionUtils; +import com.querydsl.core.types.ParamNotSetException; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.Projections; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.core.types.dsl.CaseBuilder; +import com.querydsl.core.types.dsl.EnumPath; +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.core.types.dsl.ListExpression; +import com.querydsl.core.types.dsl.ListPath; +import com.querydsl.core.types.dsl.NumberExpression; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.Param; +import com.querydsl.core.types.dsl.SimpleExpression; +import com.querydsl.core.types.dsl.SimplePath; +import com.querydsl.core.types.dsl.StringExpression; +import com.querydsl.jpa.domain.Animal; +import com.querydsl.jpa.domain.Author; +import com.querydsl.jpa.domain.Book; +import com.querydsl.jpa.domain.Cat; +import com.querydsl.jpa.domain.Color; +import com.querydsl.jpa.domain.Company; +import com.querydsl.jpa.domain.Company.Rating; +import com.querydsl.jpa.domain.DomesticCat; +import com.querydsl.jpa.domain.DoubleProjection; +import com.querydsl.jpa.domain.Employee; +import com.querydsl.jpa.domain.Entity1; +import com.querydsl.jpa.domain.Entity2; +import com.querydsl.jpa.domain.Foo; +import com.querydsl.jpa.domain.JobFunction; +import com.querydsl.jpa.domain.Numeric; +import com.querydsl.jpa.domain.QAnimal; +import com.querydsl.jpa.domain.QAuthor; +import com.querydsl.jpa.domain.QBook; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.domain.QCompany; +import com.querydsl.jpa.domain.QDomesticCat; +import com.querydsl.jpa.domain.QDoubleProjection; +import com.querydsl.jpa.domain.QEmployee; +import com.querydsl.jpa.domain.QEntity1; +import com.querydsl.jpa.domain.QFamily; +import com.querydsl.jpa.domain.QFoo; +import com.querydsl.jpa.domain.QHuman; +import com.querydsl.jpa.domain.QMammal; +import com.querydsl.jpa.domain.QNumeric; +import com.querydsl.jpa.domain.QShow; +import com.querydsl.jpa.domain.QSimpleTypes; +import com.querydsl.jpa.domain.QUser; +import com.querydsl.jpa.domain.QWorld; +import com.querydsl.jpa.domain.Show; +import com.querydsl.jpa.domain4.QBookMark; +import com.querydsl.jpa.domain4.QBookVersion; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.UUID; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +/** + * @author tiwe + */ +public abstract class AbstractJPATest { + + private static final Expression[] NO_EXPRESSIONS = new Expression[0]; + + private static final QCompany company = QCompany.company; + + private static final QAnimal animal = QAnimal.animal; + + private static final QCat cat = QCat.cat; + + private static final QCat otherCat = new QCat("otherCat"); + + private static final BooleanExpression cond1 = cat.name.length().gt(0); + + private static final BooleanExpression cond2 = otherCat.name.length().gt(0); + + private static final Predicate condition = + ExpressionUtils.and( + (Predicate) ExpressionUtils.extract(cond1), (Predicate) ExpressionUtils.extract(cond2)); + + private static final Date birthDate; + + private static final java.sql.Date date; + + private static final java.sql.Time time; + + private final List savedCats = new ArrayList<>(); + + static { + var cal = Calendar.getInstance(); + cal.set(2000, 1, 2, 3, 4); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + birthDate = cal.getTime(); + date = new java.sql.Date(cal.getTimeInMillis()); + time = new java.sql.Time(cal.getTimeInMillis()); + } + + protected Target getTarget() { + return Mode.target.get(); + } + + protected abstract JPQLQuery query(); + + protected abstract JPQLQuery testQuery(); + + protected abstract void save(Object entity); + + @Before + public void setUp() { + if (query().from(cat).fetchCount() > 0) { + savedCats.addAll(query().from(cat).orderBy(cat.id.asc()).select(cat).fetch()); + return; + } + + Cat prev = null; + for (Cat cat : + Arrays.asList( + new Cat("Bob123", 1, 1.0), + new Cat("Ruth123", 2, 2.0), + new Cat("Felix123", 3, 3.0), + new Cat("Allen123", 4, 4.0), + new Cat("Mary_123", 5, 5.0))) { + if (prev != null) { + cat.addKitten(prev); + } + cat.setBirthdate(birthDate); + cat.setDateField(date); + cat.setTimeField(time); + cat.setColor(Color.BLACK); + cat.setMate(prev); + save(cat); + savedCats.add(cat); + prev = cat; + } + + var animal = new Animal(10); + animal.setBodyWeight(10.5); + save(animal); + + var cat = new Cat("Some", 6, 6.0); + cat.setBirthdate(birthDate); + save(cat); + savedCats.add(cat); + + var show = new Show(1); + show.acts = new HashMap<>(); + show.acts.put("a", "A"); + show.acts.put("b", "B"); + save(show); + + var company = new Company(); + company.name = "1234567890123456789012345678901234567890"; // 40 + company.id = 1; + company.ratingOrdinal = Company.Rating.A; + company.ratingString = Company.Rating.AA; + save(company); + + var employee = new Employee(); + employee.id = 1; + employee.lastName = "Smith"; + employee.jobFunctions.add(JobFunction.CODER); + save(employee); + + var employee2 = new Employee(); + employee2.id = 2; + employee2.lastName = "Doe"; + employee2.jobFunctions.add(JobFunction.CODER); + employee2.jobFunctions.add(JobFunction.CONSULTANT); + employee2.jobFunctions.add(JobFunction.CONTROLLER); + save(employee2); + + save(new Entity1(1)); + save(new Entity1(2)); + save(new Entity2(3)); + + var foo = new Foo(); + foo.id = 1; + foo.names = Arrays.asList("a", "b"); + foo.bar = "München"; + save(foo); + + var numeric = new Numeric(); + numeric.setValue(BigDecimal.valueOf(26.9)); + save(numeric); + } + + @Test + @ExcludeIn(ORACLE) + public void add_bigDecimal() { + var entity = new QSimpleTypes("entity1"); + var entity2 = new QSimpleTypes("entity2"); + var bigd1 = entity.bigDecimal; + var bigd2 = entity2.bigDecimal; + + assertThat( + query() + .from(entity, entity2) + .where(bigd1.add(bigd2).loe(new BigDecimal("1.00"))) + .select(entity) + .fetch()) + .isEqualTo(Collections.emptyList()); + } + + @Test + public void aggregates_list_max() { + assertThat(query().from(cat).select(cat.id.max()).fetchFirst()).isEqualTo(Integer.valueOf(6)); + } + + @Test + public void aggregates_list_min() { + assertThat(query().from(cat).select(cat.id.min()).fetchFirst()).isEqualTo(Integer.valueOf(1)); + } + + @Test + public void aggregates_uniqueResult_max() { + assertThat(query().from(cat).select(cat.id.max()).fetchFirst()).isEqualTo(Integer.valueOf(6)); + } + + @Test + public void aggregates_uniqueResult_min() { + assertThat(query().from(cat).select(cat.id.min()).fetchFirst()).isEqualTo(Integer.valueOf(1)); + } + + @Test + public void alias() { + assertThat(query().from(cat).select(cat.id.as(cat.id)).fetch()).hasSize(6); + } + + @Test + public void any_and_gt() { + assertThat( + query() + .from(cat) + .where(cat.kittens.any().name.eq("Ruth123"), cat.kittens.any().bodyWeight.gt(10.0)) + .fetchCount()) + .isEqualTo(0); + } + + @Test + public void any_and_lt() { + assertThat( + query() + .from(cat) + .where(cat.kittens.any().name.eq("Ruth123"), cat.kittens.any().bodyWeight.lt(10.0)) + .fetchCount()) + .isEqualTo(1); + } + + @Test + public void any_in_order() { + assertThat(query().from(cat).orderBy(cat.kittens.any().name.asc()).select(cat).fetch()) + .isNotEmpty(); + } + + @Test + public void any_in_projection() { + assertThat(query().from(cat).select(cat.kittens.any()).fetch()).isNotEmpty(); + } + + @Test + public void any_in_projection2() { + assertThat(query().from(cat).select(cat.kittens.any().name).fetch()).isNotEmpty(); + } + + @Test + public void any_in_projection3() { + assertThat( + query().from(cat).select(cat.kittens.any().name, cat.kittens.any().bodyWeight).fetch()) + .isNotEmpty(); + } + + @Test + public void any_in1() { + // select cat from Cat cat where exists ( + // select cat_kittens from Cat cat_kittens where cat_kittens member of cat.kittens and + // cat_kittens in ?1) + assertThat(query().from(cat).where(cat.kittens.any().in(savedCats)).select(cat).fetch()) + .isNotEmpty(); + } + + @Test + public void any_in11() { + List ids = new ArrayList<>(); + for (Cat cat : savedCats) { + ids.add(cat.getId()); + } + assertThat(query().from(cat).where(cat.kittens.any().id.in(ids)).select(cat).fetch()) + .isNotEmpty(); + } + + @Test + public void any_in2() { + assertThat( + query() + .from(cat) + .where( + cat.kittens.any().in(savedCats), + cat.kittens.any().in(savedCats.subList(0, 1)).not()) + .select(cat) + .fetch()) + .isNotEmpty(); + } + + @Test + @NoBatooJPA + public void any_in3() { + var employee = QEmployee.employee; + assertThat( + query() + .from(employee) + .where(employee.jobFunctions.any().in(JobFunction.CODER, JobFunction.CONSULTANT)) + .select(employee) + .fetch()) + .isNotEmpty(); + } + + @Test + public void any_simple() { + assertThat(query().from(cat).where(cat.kittens.any().name.eq("Ruth123")).fetchCount()) + .isEqualTo(1); + } + + @Test + public void any_any() { + assertThat( + query() + .from(cat) + .where(cat.kittens.any().kittens.any().name.eq("Ruth123")) + .fetchCount()) + .isEqualTo(1); + } + + @Test + public void arrayProjection() { + var results = + query() + .from(cat) + .select(new ArrayConstructorExpression<>(String[].class, cat.name)) + .fetch(); + assertThat(results).isNotEmpty(); + for (String[] result : results) { + assertThat(result[0]).isNotNull(); + } + } + + @Test + public void as() { + assertThat(query().from(QAnimal.animal.as(QCat.class)).fetchCount() > 0).isTrue(); + } + + @Test + public void between() { + assertThat( + query() + .from(cat) + .where(cat.id.between(2, 5)) + .orderBy(cat.id.asc()) + .select(cat.id) + .fetch()) + .isEqualTo(Arrays.asList(2, 3, 4, 5)); + } + + @Test + @NoBatooJPA + public void case1() { + assertThat( + query() + .from(cat) + .orderBy(cat.id.asc()) + .select(cat.name.when("Bob123").then(1).otherwise(2)) + .fetch()) + .isEqualTo(Arrays.asList(1, 2, 2, 2, 2, 2)); + } + + @Test + @NoBatooJPA + public void case1_long() { + assertThat( + query() + .from(cat) + .orderBy(cat.id.asc()) + .select(cat.name.when("Bob123").then(1L).otherwise(2L)) + .fetch()) + .isEqualTo(Arrays.asList(1L, 2L, 2L, 2L, 2L, 2L)); + var rv = query().from(cat).select(cat.name.when("Bob").then(1).otherwise(2)).fetch(); + assertInstancesOf(Integer.class, rv); + } + + @Test + @NoEclipseLink + @NoHibernate // https://hibernate.atlassian.net/browse/HHH-8653 + public void case1_date() { + var rv = + query() + .from(cat) + .select( + cat.name.when("Bob").then(LocalDate.now()).otherwise(LocalDate.now().plusDays(1))) + .fetch(); + assertInstancesOf(LocalDate.class, rv); + } + + @Test + @NoHibernate // https://hibernate.atlassian.net/browse/HHH-8653 + @NoEclipseLink({MYSQL, POSTGRESQL}) + public void case1_date2() { + var rv = + query() + .from(cat) + .select(cat.name.when("Bob").then(new java.sql.Date(0)).otherwise(new java.sql.Date(0))) + .fetch(); + assertInstancesOf(java.sql.Date.class, rv); + } + + @Test + @NoEclipseLink + @NoHibernate // https://hibernate.atlassian.net/browse/HHH-8653 + public void case1_time() { + var rv = + query() + .from(cat) + .select( + cat.name.when("Bob").then(LocalTime.now()).otherwise(LocalTime.now().plusHours(1))) + .fetch(); + assertInstancesOf(LocalTime.class, rv); + } + + @Test + @NoHibernate // https://hibernate.atlassian.net/browse/HHH-8653 + @NoEclipseLink({MYSQL, POSTGRESQL}) + public void case1_time2() { + var rv = + query() + .from(cat) + .select(cat.name.when("Bob").then(new java.sql.Time(0)).otherwise(new java.sql.Time(0))) + .fetch(); + assertInstancesOf(java.sql.Time.class, rv); + } + + @Test + @NoEclipseLink + @NoHibernate // https://hibernate.atlassian.net/browse/HHH-8653 + public void case1_timestamp() { + var rv = + query() + .from(cat) + .select( + cat.name + .when("Bob") + .then(ZonedDateTime.now()) + .otherwise(ZonedDateTime.now().plusHours(1))) + .fetch(); + assertInstancesOf(ZonedDateTime.class, rv); + } + + @Test + @NoHibernate // https://hibernate.atlassian.net/browse/HHH-8653 + @NoEclipseLink({MYSQL, POSTGRESQL}) + public void case1_timestamp2() { + var rv = + query() + .from(cat) + .select( + cat.name + .when("Bob") + .then(new java.sql.Timestamp(0)) + .otherwise(new java.sql.Timestamp(0))) + .fetch(); + assertInstancesOf(java.sql.Timestamp.class, rv); + } + + @Test + public void case2() { + assertThat( + query() + .from(cat) + .select( + Expressions.cases() + .when(cat.toes.eq(2)) + .then(cat.id.multiply(2)) + .when(cat.toes.eq(3)) + .then(cat.id.multiply(3)) + .otherwise(4)) + .fetch()) + .isEqualTo(Arrays.asList(4, 4, 4, 4, 4, 4)); + } + + @Test + public void case3() { + assertThat( + query() + .from(cat) + .select( + Expressions.cases() + .when(cat.toes.in(2, 3)) + .then(cat.id.multiply(cat.toes)) + .otherwise(4)) + .fetch()) + .isEqualTo(Arrays.asList(4, 4, 4, 4, 4, 4)); + } + + @Test + @ExcludeIn(MYSQL) // doesn't work in Eclipselink + public void case4() { + NumberExpression numExpression = + cat.bodyWeight.floatValue().divide(otherCat.bodyWeight.floatValue()).multiply(100); + var numExpression2 = cat.id.when(0).then(0.0F).otherwise(numExpression); + assertThat( + query() + .from(cat, otherCat) + .where(cat.id.eq(otherCat.id.add(1))) + .orderBy(cat.id.asc(), otherCat.id.asc()) + .select(numExpression2.intValue()) + .fetch()) + .isEqualTo(Arrays.asList(200, 150, 133, 125, 120)); + } + + @Test + public void case5() { + assertThat( + query() + .from(cat) + .orderBy(cat.id.asc()) + .select(cat.mate.when(savedCats.getFirst()).then(0).otherwise(1)) + .fetch()) + .isEqualTo(Arrays.asList(1, 0, 1, 1, 1, 1)); + } + + private static void assertInstancesOf(Class clazz, Iterable rows) { + for (T row : rows) { + assertThat(row.getClass()).as(row.toString()).isEqualTo(clazz); + } + } + + @Test + public void caseBuilder() { + var cat2 = new QCat("cat2"); + var casex = + new CaseBuilder() + .when(cat.weight.isNull().and(cat.weight.isNull())) + .then(0) + .when(cat.weight.isNull()) + .then(cat2.weight) + .when(cat2.weight.isNull()) + .then(cat.weight) + .otherwise(cat.weight.add(cat2.weight)); + + query().from(cat, cat2).orderBy(casex.asc()).select(cat.id, cat2.id).fetch(); + query().from(cat, cat2).orderBy(casex.desc()).select(cat.id, cat2.id).fetch(); + } + + @Test + public void cast() { + var cats = query().from(cat).select(cat).fetch(); + var weights = query().from(cat).select(cat.bodyWeight.castToNum(Integer.class)).fetch(); + for (var i = 0; i < cats.size(); i++) { + assertThat(weights.get(i)).isEqualTo(Integer.valueOf((int) (cats.get(i).getBodyWeight()))); + } + } + + @Test + @ExcludeIn(SQLSERVER) + public void cast_toString() { + for (Tuple tuple : query().from(cat).select(cat.breed, cat.breed.stringValue()).fetch()) { + assertThat(tuple.get(cat.breed.stringValue())).isEqualTo(tuple.get(cat.breed).toString()); + } + } + + @Test + @ExcludeIn(SQLSERVER) + public void cast_toString_append() { + for (Tuple tuple : + query().from(cat).select(cat.breed, cat.breed.stringValue().append("test")).fetch()) { + assertThat(tuple.get(cat.breed.stringValue().append("test"))) + .isEqualTo(tuple.get(cat.breed).toString() + "test"); + } + } + + @Test + public void collection_predicates() { + var path = cat.kittens; + // path.eq(savedCats), + // path.in(savedCats), + // path.isNotNull(), + // path.isNull(), + // path.ne(savedCats), + // path.notIn(savedCats) + // path.when(other) + List predicates = Collections.emptyList(); + for (Predicate pred : predicates) { + System.err.println(pred); + query().from(cat).where(pred).select(cat).fetch(); + } + } + + @Test + public void collection_projections() { + var path = cat.kittens; + // path.fetchCount(), + // path.countDistinct() + List> projections = Collections.emptyList(); + for (Expression proj : projections) { + System.err.println(proj); + query().from(cat).select(proj).fetch(); + } + } + + @Test + public void constant() { + // select cat.id, ?1 as const from Cat cat + var cats = query().from(cat).select(cat).fetch(); + Path path = Expressions.stringPath("const"); + var tuples = query().from(cat).select(cat.id, Expressions.constantAs("abc", path)).fetch(); + for (var i = 0; i < cats.size(); i++) { + assertThat(tuples.get(i).get(cat.id)).isEqualTo(Integer.valueOf(cats.get(i).getId())); + assertThat(tuples.get(i).get(path)).isEqualTo("abc"); + } + } + + @Test + public void constant2() { + assertThat(query().from(cat).select(cat.id, Expressions.constant("name")).fetch()).isNotEmpty(); + } + + @Test + public void constructorProjection() { + var projections = + query().from(cat).select(Projections.constructor(Projection.class, cat.name, cat)).fetch(); + assertThat(projections).isNotEmpty(); + for (Projection projection : projections) { + assertThat(projection).isNotNull(); + } + } + + @Test + public void constructorProjection2() { + var projections = query().from(cat).select(new QProjection(cat.name, cat)).fetch(); + assertThat(projections).isNotEmpty(); + for (Projection projection : projections) { + assertThat(projection).isNotNull(); + } + } + + @Test + public void constructorProjection3() { + var projections = query().from(cat).select(new QProjection(cat.id, Expressions.FALSE)).fetch(); + assertThat(projections).isNotEmpty(); + for (Projection projection : projections) { + assertThat(projection).isNotNull(); + } + } + + @Test + public void contains_ic() { + var foo = QFoo.foo; + assertThat(query().from(foo).where(foo.bar.containsIgnoreCase("München")).fetchCount()) + .isEqualTo(1); + } + + @Test + public void contains1() { + assertThat(query().from(cat).where(cat.name.contains("eli")).fetchCount()).isEqualTo(1); + } + + @Test + public void contains2() { + assertThat(query().from(cat).where(cat.kittens.contains(savedCats.getFirst())).fetchCount()) + .isEqualTo(1L); + } + + @Test + public void contains3() { + assertThat(query().from(cat).where(cat.name.contains("_")).fetchCount()).isEqualTo(1L); + } + + @Test + public void contains4() { + var employee = QEmployee.employee; + assertThat( + query() + .from(employee) + .where( + employee.jobFunctions.contains(JobFunction.CODER), + employee.jobFunctions.contains(JobFunction.CONSULTANT), + employee.jobFunctions.size().eq(2)) + .select(employee) + .fetch()) + .isEqualTo(Collections.emptyList()); + } + + @Test + public void count() { + var show = QShow.show; + assertThat(query().from(show).fetchCount() > 0).isTrue(); + } + + @Test + public void count_distinct() { + var cat = QCat.cat; + query().from(cat).groupBy(cat.id).select(cat.id, cat.breed.countDistinct()).fetch(); + } + + @Test + @NoBatooJPA + @NoHibernate + public void count_distinct2() { + var cat = QCat.cat; + query() + .from(cat) + .groupBy(cat.id) + .select(cat.id, cat.birthdate.dayOfMonth().countDistinct()) + .fetch(); + } + + @Test + @NoEclipseLink + @ExcludeIn(SQLSERVER) + public void distinct_orderBy() { + var cat = QCat.cat; + var result = + query() + .select(cat.id, cat.mate.id) + .distinct() + .from(cat) + .orderBy(cat.mate.id.asc().nullsFirst(), cat.id.asc().nullsFirst()) + .fetch(); + assertThat(result) + .containsExactly( + new MockTuple(new Object[] {1, null}), + new MockTuple(new Object[] {6, null}), + new MockTuple(new Object[] {2, 1}), + new MockTuple(new Object[] {3, 2}), + new MockTuple(new Object[] {4, 3}), + new MockTuple(new Object[] {5, 4})); + } + + @Test + @NoHibernate + @ExcludeIn(MYSQL) + public void distinct_orderBy2() { + var cat = QCat.cat; + var result = + query() + .select(cat.id, cat.mate.id) + .distinct() + .from(cat) + .orderBy(cat.mate.id.asc().nullsFirst()) + .fetch(); + assertThat(result) + .containsExactly( + new MockTuple(new Object[] {2, 1}), + new MockTuple(new Object[] {3, 2}), + new MockTuple(new Object[] {4, 3}), + new MockTuple(new Object[] {5, 4})); + } + + @Test + @NoEclipseLink(HSQLDB) + public void count_distinct3() { + var kitten = new QCat("kitten"); + assertThat( + query() + .from(cat) + .leftJoin(cat.kittens, kitten) + .select(kitten.countDistinct()) + .fetchOne() + .intValue()) + .isEqualTo(4); + assertThat( + query() + .from(cat) + .leftJoin(cat.kittens, kitten) + .select(kitten.countDistinct()) + .fetchCount()) + .isEqualTo(6); + } + + @Test + public void distinctResults() { + System.out.println("-- fetch results"); + var res = query().from(cat).limit(2).select(cat.birthdate).fetchResults(); + assertThat(res.getResults()).hasSize(2); + assertThat(res.getTotal()).isEqualTo(6L); + System.out.println(); + + System.out.println("-- fetch distinct results"); + res = query().from(cat).limit(2).distinct().select(cat.birthdate).fetchResults(); + assertThat(res.getResults()).hasSize(1); + assertThat(res.getTotal()).isEqualTo(1L); + System.out.println(); + + System.out.println("-- fetch distinct"); + assertThat(query().from(cat).distinct().select(cat.birthdate).fetch()).hasSize(1); + } + + @Test + public void date() { + assertThat(query().from(cat).select(cat.birthdate.year()).fetchFirst().intValue()) + .isEqualTo(2000); + assertThat(query().from(cat).select(cat.birthdate.yearMonth()).fetchFirst().intValue()) + .isEqualTo(200002); + assertThat(query().from(cat).select(cat.birthdate.month()).fetchFirst().intValue()) + .isEqualTo(2); + assertThat(query().from(cat).select(cat.birthdate.dayOfMonth()).fetchFirst().intValue()) + .isEqualTo(2); + assertThat(query().from(cat).select(cat.birthdate.hour()).fetchFirst().intValue()).isEqualTo(3); + assertThat(query().from(cat).select(cat.birthdate.minute()).fetchFirst().intValue()) + .isEqualTo(4); + assertThat(query().from(cat).select(cat.birthdate.second()).fetchFirst().intValue()) + .isEqualTo(0); + } + + @Test + @NoEclipseLink({DERBY, HSQLDB}) + @NoHibernate({DERBY, POSTGRESQL, SQLSERVER}) + public void date_yearWeek() { + int value = query().from(cat).select(cat.birthdate.yearWeek()).fetchFirst(); + assertThat(value == 200006 || value == 200005).isTrue(); + } + + @Test + @NoEclipseLink({DERBY, HSQLDB}) + @NoHibernate({DERBY, POSTGRESQL, SQLSERVER}) + public void date_week() { + int value = query().from(cat).select(cat.birthdate.week()).fetchFirst(); + assertThat(value == 6 || value == 5).isTrue(); + } + + @Test + @ExcludeIn(ORACLE) + public void divide() { + var entity = new QSimpleTypes("entity1"); + var entity2 = new QSimpleTypes("entity2"); + + assertThat( + query() + .from(entity, entity2) + .where(entity.ddouble.divide(entity2.ddouble).loe(2.0)) + .select(entity) + .fetch()) + .isEqualTo(Collections.emptyList()); + + assertThat( + query() + .from(entity, entity2) + .where(entity.ddouble.divide(entity2.iint).loe(2.0)) + .select(entity) + .fetch()) + .isEqualTo(Collections.emptyList()); + + assertThat( + query() + .from(entity, entity2) + .where(entity.iint.divide(entity2.ddouble).loe(2.0)) + .select(entity) + .fetch()) + .isEqualTo(Collections.emptyList()); + + assertThat( + query() + .from(entity, entity2) + .where(entity.iint.divide(entity2.iint).loe(2)) + .select(entity) + .fetch()) + .isEqualTo(Collections.emptyList()); + } + + @Test + @ExcludeIn(ORACLE) + public void divide_bigDecimal() { + var entity = new QSimpleTypes("entity1"); + var entity2 = new QSimpleTypes("entity2"); + var bigd1 = entity.bigDecimal; + var bigd2 = entity2.bigDecimal; + + assertThat( + query() + .from(entity, entity2) + .where(bigd1.divide(bigd2).loe(new BigDecimal("1.00"))) + .select(entity) + .fetch()) + .isEqualTo(Collections.emptyList()); + + assertThat( + query() + .from(entity, entity2) + .where(entity.ddouble.divide(bigd2).loe(new BigDecimal("1.00"))) + .select(entity) + .fetch()) + .isEqualTo(Collections.emptyList()); + + assertThat( + query() + .from(entity, entity2) + .where(bigd1.divide(entity.ddouble).loe(new BigDecimal("1.00"))) + .select(entity) + .fetch()) + .isEqualTo(Collections.emptyList()); + } + + @Test + public void endsWith() { + assertThat(query().from(cat).where(cat.name.endsWith("h123")).fetchCount()).isEqualTo(1); + } + + @Test + public void endsWith_ignoreCase() { + assertThat(query().from(cat).where(cat.name.endsWithIgnoreCase("H123")).fetchCount()) + .isEqualTo(1); + } + + @Test + public void endsWith2() { + assertThat(query().from(cat).where(cat.name.endsWith("X")).fetchCount()).isEqualTo(0); + } + + @Test + public void endsWith3() { + assertThat(query().from(cat).where(cat.name.endsWith("_123")).fetchCount()).isEqualTo(1); + } + + @Test + @NoBatooJPA + public void enum_eq() { + assertThat(query().from(company).where(company.ratingOrdinal.eq(Rating.A)).fetchCount()) + .isEqualTo(1); + assertThat(query().from(company).where(company.ratingString.eq(Rating.AA)).fetchCount()) + .isEqualTo(1); + } + + @Test + @NoBatooJPA + public void enum_in() { + assertThat( + query().from(company).where(company.ratingOrdinal.in(Rating.A, Rating.AA)).fetchCount()) + .isEqualTo(1); + assertThat( + query().from(company).where(company.ratingString.in(Rating.A, Rating.AA)).fetchCount()) + .isEqualTo(1); + } + + @Test + @NoBatooJPA + public void enum_in2() { + var employee = QEmployee.employee; + + JPQLQuery query = query(); + query + .from(employee) + .where(employee.lastName.eq("Smith"), employee.jobFunctions.contains(JobFunction.CODER)); + assertThat(query.fetchCount()).isEqualTo(1L); + } + + @Test + @ExcludeIn(SQLSERVER) + public void enum_startsWith() { + assertThat( + query() + .from(company) + .where(company.ratingString.stringValue().startsWith("A")) + .fetchCount()) + .isEqualTo(1); + } + + @Test + @NoEclipseLink(HSQLDB) + public void factoryExpressions() { + var cat = QCat.cat; + var cat2 = new QCat("cat2"); + var kitten = new QCat("kitten"); + JPQLQuery query = + query() + .from(cat) + .leftJoin(cat.mate, cat2) + .leftJoin(cat2.kittens, kitten) + .select(Projections.tuple(cat.id, new QFamily(cat, cat2, kitten).skipNulls())); + assertThat(query.fetch()).hasSize(6); + assertThat(query.limit(1).fetchOne()).isNotNull(); + } + + @Test + @NoEclipseLink + @NoOpenJPA + @NoBatooJPA + public void fetch() { + var mammal = QMammal.mammal; + var human = new QHuman("mammal"); + query().from(mammal).leftJoin(human.hairs).fetchJoin().select(mammal).fetch(); + } + + @Test + @NoEclipseLink + @NoOpenJPA + @NoBatooJPA + public void fetch2() { + var world = QWorld.world; + var mammal = QMammal.mammal; + var human = new QHuman("mammal"); + query() + .from(world) + .leftJoin(world.mammals, mammal) + .fetchJoin() + .leftJoin(human.hairs) + .fetchJoin() + .select(world) + .fetch(); + } + + @Test + @ExcludeIn({MYSQL, DERBY}) + @NoBatooJPA + public void groupBy() { + var author = QAuthor.author; + var book = QBook.book; + + for (var i = 0; i < 10; i++) { + var a = new Author(); + a.setName(String.valueOf(i)); + save(a); + for (var j = 0; j < 2; j++) { + var b = new Book(); + b.setTitle(String.valueOf(i) + " " + String.valueOf(j)); + b.setAuthor(a); + save(b); + } + } + + Map>> map = + query() + .from(author) + .join(author.books, book) + .transform( + GroupBy.groupBy(author.id).as(GroupBy.list(QPair.create(book.id, book.title)))); + + for (Entry>> entry : map.entrySet()) { + System.out.println("author = " + entry.getKey()); + + for (Pair pair : entry.getValue()) { + System.out.println(" book = " + pair.getFirst() + "," + pair.getSecond()); + } + } + } + + @Test + public void groupBy2() { + // select cat0_.name as col_0_0_, cat0_.breed as col_1_0_, sum(cat0_.bodyWeight) as + // col_2_0_ + // from animal_ cat0_ where cat0_.DTYPE in ('C', 'DC') and cat0_.bodyWeight>? + // group by cat0_.name, cat0_.breed + query() + .from(cat) + .where(cat.bodyWeight.gt(0)) + .groupBy(cat.name, cat.breed) + .select(cat.name, cat.breed, cat.bodyWeight.sumDouble()) + .fetch(); + } + + @Test + @NoEclipseLink + public void groupBy_yearMonth() { + query() + .from(cat) + .groupBy(cat.birthdate.yearMonth()) + .orderBy(cat.birthdate.yearMonth().asc()) + .select(cat.id.count()) + .fetch(); + } + + @Test + @Ignore // FIXME + public void groupBy_count() { + var ids = query().from(cat).groupBy(cat.id).select(cat.id).fetch(); + var count = query().from(cat).groupBy(cat.id).fetchCount(); + var results = query().from(cat).groupBy(cat.id).limit(1).select(cat.id).fetchResults(); + + var catCount = query().from(cat).fetchCount(); + assertThat(ids).hasSize((int) catCount); + assertThat(count).isEqualTo(catCount); + assertThat(results.getResults()).hasSize((int) catCount); + assertThat(results.getTotal()).isEqualTo(catCount); + } + + @Test + @Ignore // FIXME + public void groupBy_distinct_count() { + var ids = query().from(cat).groupBy(cat.id).distinct().select(Expressions.ONE).fetch(); + var results = + query() + .from(cat) + .groupBy(cat.id) + .limit(1) + .distinct() + .select(Expressions.ONE) + .fetchResults(); + + assertThat(ids).hasSize(1); + assertThat(results.getResults()).hasSize(1); + assertThat(results.getTotal()).isEqualTo(1); + } + + @Test + @NoHibernate // https://hibernate.atlassian.net/browse/HHH-1902 + public void groupBy_select() { + // select length(my_column) as column_size from my_table group by column_size + NumberPath length = Expressions.numberPath(Integer.class, "len"); + assertThat( + query() + .select(cat.name.length().as(length)) + .from(cat) + .orderBy(length.asc()) + .groupBy(length) + .fetch()) + .isEqualTo(Arrays.asList(4, 6, 7, 8)); + } + + @Test + public void groupBy_results() { + var results = query().from(cat).groupBy(cat.id).select(cat.id).fetchResults(); + assertThat(results.getTotal()).isEqualTo(6); + assertThat(results.getResults()).hasSize(6); + } + + @Test + public void groupBy_results2() { + var results = query().from(cat).groupBy(cat.birthdate).select(cat.id.max()).fetchResults(); + assertThat(results.getTotal()).isEqualTo(1); + assertThat(results.getResults()).hasSize(1); + } + + @Test + public void in() { + assertThat(query().from(cat).where(cat.name.in("Bob123", "Ruth123", "Felix123")).fetchCount()) + .isEqualTo(3L); + assertThat(query().from(cat).where(cat.id.in(Arrays.asList(1, 2, 3))).fetchCount()) + .isEqualTo(3L); + assertThat(query().from(cat).where(cat.name.in(Arrays.asList("A", "B", "C"))).fetchCount()) + .isEqualTo(0L); + } + + @Test + public void in2() { + assertThat(query().from(cat).where(cat.id.in(1, 2, 3)).fetchCount()).isEqualTo(3L); + assertThat(query().from(cat).where(cat.name.in("A", "B", "C")).fetchCount()).isEqualTo(0L); + } + + @Test + public void in3() { + assertThat(query().from(cat).where(cat.name.in("A,B,C".split(","))).fetchCount()).isEqualTo(0); + } + + @Test + public void in4() { + // $.parameterRelease.id.eq(releaseId).and($.parameterGroups.any().id.in(filter.getGroups())); + assertThat( + query() + .from(cat) + .where(cat.id.eq(1), cat.kittens.any().id.in(1, 2, 3)) + .select(cat) + .fetch()) + .isEqualTo(Collections.emptyList()); + } + + @Test + public void in5() { + assertThat(query().from(cat).where(cat.mate.in(savedCats)).fetchCount()).isEqualTo(4L); + } + + @Test + @Ignore + public void in6() { + // query().from(cat).where(cat.kittens.in(savedCats)).fetchCount(); + } + + @Test + public void in7() { + assertThat(query().from(cat).where(cat.kittens.any().in(savedCats)).fetchCount()).isEqualTo(4L); + } + + @Test + public void in_empty() { + assertThat(query().from(cat).where(cat.name.in(Collections.emptyList())).fetchCount()) + .isEqualTo(0); + } + + @Test + @NoOpenJPA + public void indexOf() { + assertThat( + query() + .from(cat) + .where(cat.name.eq("Bob123")) + .select(cat.name.indexOf("B")) + .fetchFirst()) + .isEqualTo(Integer.valueOf(0)); + } + + @Test + @NoOpenJPA + public void indexOf2() { + assertThat( + query() + .from(cat) + .where(cat.name.eq("Bob123")) + .select(cat.name.indexOf("o")) + .fetchFirst()) + .isEqualTo(Integer.valueOf(1)); + } + + @Test + public void instanceOf_cat() { + assertThat(query().from(cat).where(cat.instanceOf(Cat.class)).fetchCount()).isEqualTo(6L); + } + + @Test + public void instanceOf_domesticCat() { + assertThat(query().from(cat).where(cat.instanceOf(DomesticCat.class)).fetchCount()) + .isEqualTo(0L); + } + + @Test + public void instanceOf_entity1() { + var entity1 = QEntity1.entity1; + assertThat(query().from(entity1).where(entity1.instanceOf(Entity1.class)).fetchCount()) + .isEqualTo(2L); + } + + @Test + public void instanceOf_entity2() { + var entity1 = QEntity1.entity1; + assertThat(query().from(entity1).where(entity1.instanceOf(Entity2.class)).fetchCount()) + .isEqualTo(1L); + } + + @Test + @NoHibernate // https://hibernate.atlassian.net/browse/HHH-6686 + public void isEmpty_elementCollection() { + var employee = QEmployee.employee; + assertThat(query().from(employee).where(employee.jobFunctions.isEmpty()).fetchCount()) + .isEqualTo(0); + } + + @Test + public void isEmpty_relation() { + assertThat(query().from(cat).where(cat.kittensSet.isEmpty()).fetchCount()).isEqualTo(6L); + } + + @Test + @NoEclipseLink + @ExcludeIn({ORACLE, TERADATA}) + public void joinEmbeddable() { + var bookVersion = QBookVersion.bookVersion; + var bookMark = QBookMark.bookMark; + + assertThat( + query() + .from(bookVersion) + .join(bookVersion.definition.bookMarks, bookMark) + .where( + bookVersion.definition.bookMarks.size().eq(1), + bookMark.page.eq(2357L).or(bookMark.page.eq(2356L))) + .select(bookVersion) + .fetch()) + .isEqualTo(Collections.emptyList()); + } + + @Test + public void length() { + assertThat(query().from(cat).where(cat.name.length().gt(0)).fetchCount()).isEqualTo(6); + } + + @Test + public void like() { + assertThat(query().from(cat).where(cat.name.like("!")).fetchCount()).isEqualTo(0); + assertThat(query().from(cat).where(cat.name.like("\\")).fetchCount()).isEqualTo(0); + } + + @Test + public void limit() { + List names1 = Arrays.asList("Allen123", "Bob123"); + assertThat(query().from(cat).orderBy(cat.name.asc()).limit(2).select(cat.name).fetch()) + .isEqualTo(names1); + } + + @Test + public void limit_and_offset() { + List names3 = Arrays.asList("Felix123", "Mary_123"); + assertThat( + query().from(cat).orderBy(cat.name.asc()).limit(2).offset(2).select(cat.name).fetch()) + .isEqualTo(names3); + } + + @Test + public void limit2() { + assertThat(query().from(cat).orderBy(cat.name.asc()).limit(1).select(cat.name).fetch()) + .isEqualTo(Collections.singletonList("Allen123")); + } + + @Test + public void limit3() { + assertThat(query().from(cat).limit(Long.MAX_VALUE).select(cat).fetch()).hasSize(6); + } + + @Test + public void list_elementCollection_of_enum() { + var employee = QEmployee.employee; + // QJobFunction jobFunction = QJobFunction.jobFunction; + EnumPath jobFunction = Expressions.enumPath(JobFunction.class, "jf"); + + var jobFunctions = + query() + .from(employee) + .innerJoin(employee.jobFunctions, jobFunction) + .select(jobFunction) + .fetch(); + assertThat(jobFunctions).hasSize(4); + } + + @Test + @NoBatooJPA + public void list_elementCollection_of_string() { + var foo = QFoo.foo; + var str = Expressions.stringPath("str"); + + var strings = query().from(foo).innerJoin(foo.names, str).select(str).fetch(); + assertThat(strings).hasSize(2); + assertThat(strings).contains("a"); + assertThat(strings).contains("b"); + } + + @Test + @NoEclipseLink(HSQLDB) + public void list_order_get() { + var cat = QCat.cat; + assertThat(query().from(cat).orderBy(cat.kittens.get(0).name.asc()).fetch()).hasSize(6); + } + + @Test + @NoEclipseLink(HSQLDB) + public void list_order_get2() { + var cat = QCat.cat; + assertThat(query().from(cat).orderBy(cat.mate.kittens.get(0).name.asc()).fetch()).hasSize(6); + } + + @Test + public void map_get() { + var show = QShow.show; + assertThat(query().from(show).select(show.acts.get("a")).fetch()) + .isEqualTo(Collections.singletonList("A")); + } + + @Test + @NoHibernate + public void map_get2() { + var show = QShow.show; + assertThat(query().from(show).where(show.acts.get("a").eq("A")).fetchCount()).isEqualTo(1); + } + + @Test + @NoEclipseLink + public void map_order_get() { + var show = QShow.show; + assertThat(query().from(show).orderBy(show.parent.acts.get("A").asc()).fetch()).hasSize(1); + } + + @Test + @NoEclipseLink + public void map_order_get2() { + var show = QShow.show; + var parent = new QShow("parent"); + assertThat( + query() + .from(show) + .leftJoin(show.parent, parent) + .orderBy(parent.acts.get("A").asc()) + .fetch()) + .hasSize(1); + } + + @Test + public void map_containsKey() { + var show = QShow.show; + assertThat(query().from(show).where(show.acts.containsKey("a")).fetchCount()).isEqualTo(1L); + } + + @Test + public void map_containsKey2() { + var show = QShow.show; + assertThat(query().from(show).where(show.acts.containsKey("b")).fetchCount()).isEqualTo(1L); + } + + @Test + public void map_containsKey3() { + var show = QShow.show; + assertThat(query().from(show).where(show.acts.containsKey("c")).fetchCount()).isEqualTo(0L); + } + + @Test + public void map_containsValue() { + var show = QShow.show; + assertThat(query().from(show).where(show.acts.containsValue("A")).fetchCount()).isEqualTo(1L); + } + + @Test + public void map_containsValue2() { + var show = QShow.show; + assertThat(query().from(show).where(show.acts.containsValue("B")).fetchCount()).isEqualTo(1L); + } + + @Test + public void map_containsValue3() { + var show = QShow.show; + assertThat(query().from(show).where(show.acts.containsValue("C")).fetchCount()).isEqualTo(0L); + } + + @Test + public void map_contains() { + var show = QShow.show; + assertThat(query().from(show).where(show.acts.contains("a", "A")).fetchCount()).isEqualTo(1L); + assertThat(query().from(show).where(show.acts.contains("X", "X")).fetchCount()).isEqualTo(0L); + } + + @Test + public void map_groupBy() { + var show = QShow.show; + assertThat( + query().from(show).select(show.acts.get("X")).groupBy(show.acts.get("a")).fetchCount()) + .isEqualTo(1); + } + + @Test + @Ignore + public void map_join() { + // select m.text from Show s join s.acts a where key(a) = 'B' + var show = QShow.show; + var act = Expressions.stringPath("act"); + assertThat(query().from(show).join(show.acts, act).select(act).fetch()) + .isEqualTo(Collections.emptyList()); + } + + @Test + public void max() { + assertThat(query().from(cat).select(cat.bodyWeight.max()).fetchFirst()) + .isCloseTo(6.0, within(0.0001)); + } + + @Test + public void min() { + assertThat(query().from(cat).select(cat.bodyWeight.min()).fetchFirst()) + .isCloseTo(1.0, within(0.0001)); + } + + @Test + @ExcludeIn(ORACLE) + public void multiply() { + var entity = new QSimpleTypes("entity1"); + var entity2 = new QSimpleTypes("entity2"); + + assertThat( + query() + .from(entity, entity2) + .where(entity.ddouble.multiply(entity2.ddouble).loe(2.0)) + .select(entity) + .fetch()) + .isEqualTo(Collections.emptyList()); + } + + @Test + @ExcludeIn(ORACLE) + public void multiply_bigDecimal() { + var entity = new QSimpleTypes("entity1"); + var entity2 = new QSimpleTypes("entity2"); + var bigd1 = entity.bigDecimal; + var bigd2 = entity2.bigDecimal; + + assertThat( + query() + .from(entity, entity2) + .where(bigd1.multiply(bigd2).loe(new BigDecimal("1.00"))) + .select(entity) + .fetch()) + .isEqualTo(Collections.emptyList()); + } + + @Test + public void nestedProjection() { + var concat = new Concatenation(cat.name, cat.name); + var tuples = query().from(cat).select(cat.name, concat).fetch(); + assertThat(tuples).isNotEmpty(); + for (Tuple tuple : tuples) { + assertThat(tuple.get(cat.name) + tuple.get(cat.name)).isEqualTo(tuple.get(concat)); + } + } + + @Test + public void not_in() { + var all = query().from(cat).fetchCount(); + assertThat( + query().from(cat).where(cat.name.notIn("Bob123", "Ruth123", "Felix123")).fetchCount()) + .isEqualTo(all - 3L); + + assertThat(query().from(cat).where(cat.id.notIn(1, 2, 3)).fetchCount()).isEqualTo(3L); + assertThat(query().from(cat).where(cat.name.notIn("A", "B", "C")).fetchCount()).isEqualTo(6L); + } + + @Test + @NoBatooJPA + public void not_in_empty() { + var count = query().from(cat).fetchCount(); + assertThat( + query().from(cat).where(cat.name.notIn(Collections.emptyList())).fetchCount()) + .isEqualTo(count); + } + + @Test + public void null_as_uniqueResult() { + assertThat( + query() + .from(cat) + .where(cat.name.eq(UUID.randomUUID().toString())) + .select(cat) + .fetchFirst()) + .isNull(); + } + + @Test + @NoEclipseLink + public void numeric() { + var numeric = QNumeric.numeric; + BigDecimal singleResult = query().from(numeric).select(numeric.value).fetchFirst(); + assertThat(singleResult.doubleValue()).isCloseTo(26.9, within(0.001)); + } + + @Test + @NoOpenJPA + @NoBatooJPA // FIXME + public void offset1() { + List names2 = Arrays.asList("Bob123", "Felix123", "Mary_123", "Ruth123", "Some"); + assertThat(query().from(cat).orderBy(cat.name.asc()).offset(1).select(cat.name).fetch()) + .isEqualTo(names2); + } + + @Test + @NoOpenJPA + @NoBatooJPA // FIXME + public void offset2() { + List names2 = Arrays.asList("Felix123", "Mary_123", "Ruth123", "Some"); + assertThat(query().from(cat).orderBy(cat.name.asc()).offset(2).select(cat.name).fetch()) + .isEqualTo(names2); + } + + @Test + public void one_to_one() { + var employee = QEmployee.employee; + var user = QUser.user; + + JPQLQuery query = query(); + query.from(employee); + query.innerJoin(employee.user, user); + query.select(employee).fetch(); + } + + @Test + public void order() { + NumberPath weight = Expressions.numberPath(Double.class, "weight"); + assertThat(query().from(cat).orderBy(weight.asc()).select(cat.bodyWeight.as(weight)).fetch()) + .isEqualTo(Arrays.asList(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)); + } + + @Test + public void order_by_count() { + NumberPath count = Expressions.numberPath(Long.class, "c"); + query() + .from(cat) + .groupBy(cat.id) + .orderBy(count.asc()) + .select(cat.id, cat.id.count().as(count)) + .fetch(); + } + + @Test + public void order_stringValue() { + var count = (int) query().from(cat).fetchCount(); + assertThat(query().from(cat).orderBy(cat.id.stringValue().asc()).select(cat).fetch()) + .hasSize(count); + } + + @Test + @NoBatooJPA // can't be parsed + public void order_stringValue_to_integer() { + var count = (int) query().from(cat).fetchCount(); + assertThat( + query() + .from(cat) + .orderBy(cat.id.stringValue().castToNum(Integer.class).asc()) + .select(cat) + .fetch()) + .hasSize(count); + } + + @Test + @NoBatooJPA // can't be parsed + public void order_stringValue_toLong() { + var count = (int) query().from(cat).fetchCount(); + assertThat( + query() + .from(cat) + .orderBy(cat.id.stringValue().castToNum(Long.class).asc()) + .select(cat) + .fetch()) + .hasSize(count); + } + + @Test + @NoBatooJPA // can't be parsed + public void order_stringValue_toBigInteger() { + var count = (int) query().from(cat).fetchCount(); + assertThat( + query() + .from(cat) + .orderBy(cat.id.stringValue().castToNum(BigInteger.class).asc()) + .select(cat) + .fetch()) + .hasSize(count); + } + + @Test + @NoBatooJPA + @ExcludeIn(SQLSERVER) + public void order_nullsFirst() { + assertThat( + query() + .from(cat) + .orderBy(cat.dateField.asc().nullsFirst()) + .select(cat.dateField) + .fetchFirst()) + .isNull(); + } + + @Test + @NoBatooJPA + @ExcludeIn(SQLSERVER) + public void order_nullsLast() { + assertThat( + query() + .from(cat) + .orderBy(cat.dateField.asc().nullsLast()) + .select(cat.dateField) + .fetchFirst()) + .isNotNull(); + } + + @Test + public void params() { + var name = new Param<>(String.class, "name"); + assertThat( + query() + .from(cat) + .where(cat.name.eq(name)) + .set(name, "Bob123") + .select(cat.name) + .fetchFirst()) + .isEqualTo("Bob123"); + } + + @Test + public void params_anon() { + var name = new Param<>(String.class); + assertThat( + query() + .from(cat) + .where(cat.name.eq(name)) + .set(name, "Bob123") + .select(cat.name) + .fetchFirst()) + .isEqualTo("Bob123"); + } + + @Test(expected = ParamNotSetException.class) + public void params_not_set() { + var name = new Param<>(String.class, "name"); + assertThat(query().from(cat).where(cat.name.eq(name)).select(cat.name).fetchFirst()) + .isEqualTo("Bob123"); + } + + @Test + public void precedence() { + var str = cat.name; + Predicate where = + str.like("Bob%").and(str.like("%ob123")).or(str.like("Ruth%").and(str.like("%uth123"))); + assertThat(query().from(cat).where(where).fetchCount()).isEqualTo(2L); + } + + @Test + public void precedence2() { + var str = cat.name; + Predicate where = + str.like("Bob%").and(str.like("%ob123").or(str.like("Ruth%"))).and(str.like("%uth123")); + assertThat(query().from(cat).where(where).fetchCount()).isEqualTo(0L); + } + + @Test + public void precedence3() { + Predicate where = + cat.name.eq("Bob123").and(cat.id.eq(1)).or(cat.name.eq("Ruth123").and(cat.id.eq(2))); + assertThat(query().from(cat).where(where).fetchCount()).isEqualTo(2L); + } + + @Test + public void factoryExpression_in_groupBy() { + Expression catBean = Projections.bean(Cat.class, cat.id, cat.name); + assertThat(query().from(cat).groupBy(catBean).select(catBean).fetch()).isNotEmpty(); + } + + @Test + @Ignore + public void size() { + // NOT SUPPORTED + query().from(cat).select(cat, cat.kittens.size()).fetch(); + } + + @Test + public void startsWith() { + assertThat(query().from(cat).where(cat.name.startsWith("R")).fetchCount()).isEqualTo(1); + } + + @Test + public void startsWith_ignoreCase() { + assertThat(query().from(cat).where(cat.name.startsWithIgnoreCase("r")).fetchCount()) + .isEqualTo(1); + } + + @Test + public void startsWith2() { + assertThat(query().from(cat).where(cat.name.startsWith("X")).fetchCount()).isEqualTo(0); + } + + @Test + public void startsWith3() { + assertThat(query().from(cat).where(cat.name.startsWith("Mary_")).fetchCount()).isEqualTo(1); + } + + @Test + @ExcludeIn({MYSQL, SQLSERVER, TERADATA}) + @NoOpenJPA + public void stringOperations() { + // NOTE : locate in MYSQL is case-insensitive + assertThat(query().from(cat).where(cat.name.startsWith("r")).fetchCount()).isEqualTo(0); + assertThat(query().from(cat).where(cat.name.endsWith("H123")).fetchCount()).isEqualTo(0); + assertThat( + query() + .from(cat) + .where(cat.name.eq("Bob123")) + .select(cat.name.indexOf("b")) + .fetchFirst()) + .isEqualTo(Integer.valueOf(2)); + } + + @Test + public void subQuery() { + var show = QShow.show; + var show2 = new QShow("show2"); + assertThat( + query() + .from(show) + .where(select(show2.count()).from(show2).where(show2.id.ne(show.id)).gt(0L)) + .fetchCount()) + .isEqualTo(0); + } + + @Test + public void subQuery2() { + var cat = QCat.cat; + var other = new QCat("other"); + assertThat( + query() + .from(cat) + .where(cat.name.in(select(other.name).from(other).groupBy(other.name))) + .orderBy(cat.id.asc()) + .select(cat) + .fetch()) + .isEqualTo(savedCats); + } + + @Test + public void subQuery3() { + var cat = QCat.cat; + var other = new QCat("other"); + assertThat( + query() + .from(cat) + .where( + cat.name.eq( + select(other.name).from(other).where(other.name.indexOf("B").eq(0)))) + .select(cat) + .fetch()) + .isEqualTo(savedCats.subList(0, 1)); + } + + @Test + public void subQuery4() { + var cat = QCat.cat; + var other = new QCat("other"); + query() + .from(cat) + .select(cat.name, select(other.count()).from(other).where(other.name.eq(cat.name))) + .fetch(); + } + + @Test + public void subQuery5() { + var employee = QEmployee.employee; + var employee2 = new QEmployee("e2"); + assertThat( + query() + .from(employee) + .where(select(employee2.id.count()).from(employee2).gt(1L)) + .fetchCount()) + .isEqualTo(2); + } + + @Test + public void substring() { + for (String str : query().from(cat).select(cat.name.substring(1, 2)).fetch()) { + assertThat(str).hasSize(1); + } + } + + @Test + @NoBatooJPA + @ExcludeIn({ORACLE, SQLSERVER, HSQLDB}) + public void substring2() { + var company = QCompany.company; + StringExpression name = company.name; + Integer companyId = query().from(company).select(company.id).fetchFirst(); + JPQLQuery query = query().from(company).where(company.id.eq(companyId)); + String str = query.select(company.name).fetchFirst(); + + assertThat(query.select(name.length().subtract(11)).fetchFirst()) + .isEqualTo(Integer.valueOf(29)); + + assertThat(query.select(name.substring(0, 7)).fetchFirst()).isEqualTo(str.substring(0, 7)); + + assertThat(query.select(name.substring(15)).fetchFirst()).isEqualTo(str.substring(15)); + + assertThat(query.select(name.substring(name.length())).fetchFirst()) + .isEqualTo(str.substring(str.length())); + + assertThat(query.select(name.substring(name.length().subtract(11))).fetchFirst()) + .isEqualTo(str.substring(str.length() - 11)); + } + + @Test + @Ignore // FIXME + @ExcludeIn(DERBY) + public void substring_from_right() { + assertThat( + query() + .from(cat) + .where(cat.name.substring(-1, 1).eq(cat.name.substring(-2, 1))) + .select(cat) + .fetch()) + .isEqualTo(Collections.emptyList()); + } + + @Test + @ExcludeIn({HSQLDB, DERBY}) + public void substring_from_right2() { + assertThat( + query() + .from(cat) + .where( + cat.name + .substring(cat.name.length().subtract(1), cat.name.length()) + .eq( + cat.name.substring( + cat.name.length().subtract(2), cat.name.length().subtract(1)))) + .select(cat) + .fetch()) + .isEqualTo(Collections.emptyList()); + } + + @Test + @ExcludeIn(ORACLE) + public void subtract_bigDecimal() { + var entity = new QSimpleTypes("entity1"); + var entity2 = new QSimpleTypes("entity2"); + var bigd1 = entity.bigDecimal; + var bigd2 = entity2.bigDecimal; + + assertThat( + query() + .from(entity, entity2) + .where(bigd1.subtract(bigd2).loe(new BigDecimal("1.00"))) + .select(entity) + .fetch()) + .isEqualTo(Collections.emptyList()); + } + + @Test + @Ignore + public void sum() { + // NOT SUPPORTED + query().from(cat).select(cat.kittens.size().sumLong()).fetch(); + } + + @Test + @Ignore + public void sum_2() { + // NOT SUPPORTED + query().from(cat).where(cat.kittens.size().sumLong().gt(0)).select(cat).fetch(); + } + + @Test + public void sum_3() { + assertThat(query().from(cat).select(cat.bodyWeight.sumDouble()).fetchFirst()) + .isCloseTo(21.0, within(0.0001)); + } + + @Test + public void sum_3_projected() { + double val = query().from(cat).select(cat.bodyWeight.sumDouble()).fetchFirst(); + DoubleProjection projection = + query().from(cat).select(new QDoubleProjection(cat.bodyWeight.sumDouble())).fetchFirst(); + assertThat(projection.val).isCloseTo(val, within(0.001)); + } + + @Test + public void sum_4() { + Double dbl = query().from(cat).select(cat.bodyWeight.sumDouble().negate()).fetchFirst(); + assertThat(dbl).isNotNull(); + } + + @Test + public void sum_5() { + var show = QShow.show; + Long lng = query().from(show).select(show.id.sumLong()).fetchFirst(); + assertThat(lng).isNotNull(); + } + + @Test + public void sum_of_integer() { + var cat2 = new QCat("cat2"); + assertThat( + query() + .from(cat) + .where(select(cat2.breed.sumLong()).from(cat2).where(cat2.eq(cat.mate)).gt(0L)) + .select(cat) + .fetch()) + .isEqualTo(Collections.emptyList()); + } + + @Test + public void sum_of_float() { + var cat2 = new QCat("cat2"); + query() + .from(cat) + .where(select(cat2.floatProperty.sumDouble()).from(cat2).where(cat2.eq(cat.mate)).gt(0.0d)) + .select(cat) + .fetch(); + } + + @Test + public void sum_of_double() { + var cat2 = new QCat("cat2"); + query() + .from(cat) + .where(select(cat2.bodyWeight.sumDouble()).from(cat2).where(cat2.eq(cat.mate)).gt(0.0)) + .select(cat) + .fetch(); + } + + @Test + public void sum_as_double_projected() { + double val = query().from(cat).select(cat.floatProperty.sumDouble()).fetchFirst(); + DoubleProjection projection = + query().from(cat).select(new QDoubleProjection(cat.floatProperty.sumDouble())).fetchFirst(); + assertThat(projection.val).isCloseTo(val, within(0.001)); + } + + @Test + public void sum_as_double2() { + double val = query().from(cat).select(cat.floatProperty.sumDouble().negate()).fetchFirst(); + assertThat(val < 0).isTrue(); + } + + @Test + public void sum_coalesce() { + long val = query().from(cat).select(cat.weight.sumLong().coalesce(0L)).fetchFirst(); + assertThat(val).isEqualTo(0); + } + + @Test + public void sum_noRows_double() { + assertThat( + query() + .from(cat) + .where(cat.name.eq(UUID.randomUUID().toString())) + .select(cat.bodyWeight.sumDouble()) + .fetchFirst()) + .isNull(); + } + + @Test + public void sum_noRows_float() { + assertThat( + query() + .from(cat) + .where(cat.name.eq(UUID.randomUUID().toString())) + .select(cat.floatProperty.sumDouble()) + .fetchFirst()) + .isNull(); + } + + @Test + @NoEclipseLink + @NoOpenJPA + @NoBatooJPA + @ExcludeIn({ORACLE, SQLSERVER, DERBY}) + public void test() { + var kitten = savedCats.getFirst(); + var noKitten = savedCats.getLast(); + + ProjectionsFactory projections = + new ProjectionsFactory(QuerydslModule.JPA, getTarget()) { + @Override + public > Collection> list( + ListPath expr, ListExpression other, A knownElement) { + // NOTE : expr.get(0) is only supported in the where clause + return Collections.>singleton(expr.size()); + } + }; + + final EntityPath[] sources = {cat, otherCat}; + final Predicate[] conditions = {condition}; + final Expression[] projection = {cat.name, otherCat.name}; + + QueryExecution standardTest = + new QueryExecution( + projections, + new FilterFactory(projections, QuerydslModule.JPA, getTarget()), + new MatchingFiltersFactory(QuerydslModule.JPA, getTarget())) { + + @Override + protected Fetchable createQuery() { + // NOTE : EclipseLink needs extra conditions cond1 and code2 + return testQuery().from(sources).where(conditions); + } + + @Override + protected Fetchable createQuery(Predicate filter) { + // NOTE : EclipseLink needs extra conditions cond1 and code2 + return testQuery().from(sources).where(condition, filter).select(projection); + } + }; + + // standardTest.runArrayTests(cat.kittensArray, otherCat.kittensArray, kitten, noKitten); + standardTest.runBooleanTests(cat.name.isNull(), otherCat.kittens.isEmpty()); + standardTest.runCollectionTests(cat.kittens, otherCat.kittens, kitten, noKitten); + standardTest.runDateTests(cat.dateField, otherCat.dateField, date); + standardTest.runDateTimeTests(cat.birthdate, otherCat.birthdate, birthDate); + standardTest.runListTests(cat.kittens, otherCat.kittens, kitten, noKitten); + // standardTest.mapTests(cat.kittensByName, otherCat.kittensByName, "Kitty", kitten); + + // int + standardTest.runNumericCasts(cat.id, otherCat.id, 1); + standardTest.runNumericTests(cat.id, otherCat.id, 1); + + // double + standardTest.runNumericCasts(cat.bodyWeight, otherCat.bodyWeight, 1.0); + standardTest.runNumericTests(cat.bodyWeight, otherCat.bodyWeight, 1.0); + + standardTest.runStringTests(cat.name, otherCat.name, kitten.getName()); + standardTest.runTimeTests(cat.timeField, otherCat.timeField, time); + + standardTest.report(); + } + + @Test + public void tupleProjection() { + var tuples = query().from(cat).select(cat.name, cat).fetch(); + assertThat(tuples).isNotEmpty(); + for (Tuple tuple : tuples) { + assertThat(tuple.get(cat.name)).isNotNull(); + assertThat(tuple.get(cat)).isNotNull(); + } + } + + @Test + public void tupleProjection_as_queryResults() { + var tuples = query().from(cat).limit(1).select(cat.name, cat).fetchResults(); + assertThat(tuples.getResults()).hasSize(1); + assertThat(tuples.getTotal() > 0).isTrue(); + } + + @Test + @ExcludeIn(DERBY) + public void transform_groupBy() { + var kitten = new QCat("kitten"); + Map result = + query() + .from(cat) + .innerJoin(cat.kittens, kitten) + .transform( + GroupBy.groupBy(cat.id) + .as( + Projections.constructor( + Cat.class, + cat.name, + cat.id, + GroupBy.list( + Projections.constructor(Cat.class, kitten.name, kitten.id))))); + + for (Cat entry : result.values()) { + assertThat(entry.getKittens()).hasSize(1); + } + } + + @Test + @ExcludeIn(DERBY) + public void transform_groupBy2() { + var kitten = new QCat("kitten"); + Map, Group> result = + query() + .from(cat) + .innerJoin(cat.kittens, kitten) + .transform(GroupBy.groupBy(cat.id, kitten.id).as(cat, kitten)); + + assertThat(result).isNotEmpty(); + for (Tuple row : query().from(cat).innerJoin(cat.kittens, kitten).select(cat, kitten).fetch()) { + assertThat(result.get(Arrays.asList(row.get(cat).getId(), row.get(kitten).getId()))) + .isNotNull(); + } + } + + @Test + @ExcludeIn(DERBY) + public void transform_groupBy_alias() { + var kitten = new QCat("kitten"); + SimplePath k = Expressions.path(Cat.class, "k"); + Map result = + query() + .from(cat) + .innerJoin(cat.kittens, kitten) + .transform( + GroupBy.groupBy(cat.id) + .as( + cat.name, + cat.id, + GroupBy.list( + Projections.constructor(Cat.class, kitten.name, kitten.id).as(k)))); + + for (Group entry : result.values()) { + assertThat(entry.getOne(cat.id)).isNotNull(); + assertThat(entry.getOne(cat.name)).isNotNull(); + assertThat(entry.getList(k)).isNotEmpty(); + } + } + + @Test + @NoBatooJPA + public void treat() { + var domesticCat = QDomesticCat.domesticCat; + assertThat( + query() + .from(cat) + .innerJoin(cat.mate, domesticCat._super) + .where(domesticCat.name.eq("Bobby")) + .fetchCount()) + .isEqualTo(0); + } + + @Test + @Ignore + public void type() { + assertThat( + query() + .from(animal) + .orderBy(animal.id.asc()) + .select(JPAExpressions.type(animal)) + .fetch()) + .isEqualTo(Arrays.asList("C", "C", "C", "C", "C", "C", "A")); + } + + @Test + @NoOpenJPA + public void type_order() { + assertThat( + query() + .from(animal) + .orderBy(JPAExpressions.type(animal).asc(), animal.id.asc()) + .select(animal.id) + .fetch()) + .isEqualTo(Arrays.asList(10, 1, 2, 3, 4, 5, 6)); + } + + @Test + @ExcludeIn({DERBY, ORACLE}) + public void byte_array() { + var simpleTypes = QSimpleTypes.simpleTypes; + assertThat( + query() + .from(simpleTypes) + .where(simpleTypes.byteArray.eq(new byte[] {0, 1})) + .select(simpleTypes) + .fetch()) + .isEqualTo(Collections.emptyList()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/AbstractQueryTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/AbstractQueryTest.java new file mode 100644 index 0000000000..c355037334 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/AbstractQueryTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.types.Expression; + +public abstract class AbstractQueryTest { + + protected QueryHelper query() { + return new QueryHelper(HQLTemplates.DEFAULT); + } + + protected static void assertToString(String expected, Expression expr) { + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT, null); + assertThat(serializer.handle(expr).toString().replace("\n", " ")).isEqualTo(expected); + } + + protected static void assertMatches(String expected, Expression expr) { + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT, null); + var str = serializer.handle(expr).toString().replace("\n", " "); + assertThat(str.matches(expected)).as(expected + "\n!=\n" + str).isTrue(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/AbstractSQLTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/AbstractSQLTest.java new file mode 100644 index 0000000000..396ff78b63 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/AbstractSQLTest.java @@ -0,0 +1,457 @@ +package com.querydsl.jpa; + +import static com.querydsl.sql.SQLExpressions.select; +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.Target; +import com.querydsl.core.Tuple; +import com.querydsl.core.testutil.ExcludeIn; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.Projections; +import com.querydsl.core.types.SubQueryExpression; +import com.querydsl.core.types.dsl.DateExpression; +import com.querydsl.core.types.dsl.Wildcard; +import com.querydsl.jpa.domain.Cat; +import com.querydsl.jpa.domain.Color; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.domain.sql.SAnimal_; +import com.querydsl.jpa.domain.sql.SCompany_; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.Collections; +import java.util.UUID; +import org.junit.Ignore; +import org.junit.Test; + +public abstract class AbstractSQLTest { + + protected static final SAnimal_ cat = new SAnimal_("cat"); + + protected abstract AbstractSQLQuery query(); + + public static class CatDTO { + + Cat cat; + + public CatDTO(Cat cat) { + this.cat = cat; + } + } + + @Test + public void count() { + assertThat(query().from(cat).where(cat.dtype.eq("C")).fetchCount()).isEqualTo(6L); + } + + @Test + public void count_via_unique() { + assertThat(query().from(cat).where(cat.dtype.eq("C")).select(cat.id.count()).fetchFirst()) + .isEqualTo(Long.valueOf(6)); + } + + @Test + public void countDistinct() { + assertThat(query().from(cat).where(cat.dtype.eq("C")).distinct().fetchCount()).isEqualTo(6L); + } + + @Test + public void enum_binding() { + var cats = query().from(cat).select(Projections.bean(Cat.class, QCat.cat.color)).fetch(); + assertThat(cats).isNotEmpty(); + + for (Cat cat : cats) { + assertThat(cat.getColor()).isEqualTo(Color.BLACK); + } + } + + @Test + @Ignore + public void entityProjections() { + var cats = + query() + .from(cat) + .orderBy(cat.name.asc()) + .select(Projections.constructor(Cat.class, cat.name, cat.id)) + .fetch(); + assertThat(cats).hasSize(6); + for (Cat c : cats) { + assertThat(c.getName()).isNotNull(); + assertThat(c.getId() > 0).isTrue(); + } + } + + @Test + public void entityQueries() { + var catEntity = QCat.cat; + + var cats = query().from(cat).orderBy(cat.name.asc()).select(catEntity).fetch(); + assertThat(cats).hasSize(6); + for (Cat c : cats) { + assertThat(c.getName()).isNotNull(); + } + } + + @Test + public void entityQueries2() { + var mate = new SAnimal_("mate"); + var catEntity = QCat.cat; + + var cats = + query() + .from(cat) + .innerJoin(mate) + .on(cat.mateId.eq(mate.id)) + .where(cat.dtype.eq("C"), mate.dtype.eq("C")) + .select(catEntity) + .fetch(); + assertThat(cats).isEmpty(); + } + + @Test + public void entityQueries3() { + var catEntity = new SAnimal_("animal_"); + assertThat( + query() + .from(catEntity) + .select(catEntity.toes.max()) + .where(catEntity.dtype.eq("C")) + .fetchFirst() + .intValue()) + .isEqualTo(0); + } + + @Test + @NoBatooJPA + @NoEclipseLink + public void entityQueries4() { + var catEntity = QCat.cat; + var cats = query().from(cat).select(catEntity, cat.name, cat.id).fetch(); + assertThat(cats).hasSize(6); + + for (Tuple tuple : cats) { + assertThat(tuple.get(catEntity) instanceof Cat).isTrue(); + assertThat(tuple.get(cat.name) instanceof String).isTrue(); + assertThat(tuple.get(cat.id) instanceof Integer).isTrue(); + } + } + + @Test + @NoBatooJPA + @NoEclipseLink + public void entityQueries5() { + var catEntity = QCat.cat; + var otherCat = new SAnimal_("otherCat"); + var otherCatEntity = new QCat("otherCat"); + var cats = query().from(cat, otherCat).select(catEntity, otherCatEntity).fetch(); + assertThat(cats).hasSize(36); + + for (Tuple tuple : cats) { + assertThat(tuple.get(catEntity) instanceof Cat).isTrue(); + assertThat(tuple.get(otherCatEntity) instanceof Cat).isTrue(); + } + } + + @Test + @NoBatooJPA + @NoEclipseLink + public void entityQueries6() { + var catEntity = QCat.cat; + var results = + query().from(cat).select(Projections.constructor(CatDTO.class, catEntity)).fetch(); + assertThat(results).hasSize(6); + + for (CatDTO cat : results) { + assertThat(cat.cat instanceof Cat).isTrue(); + } + } + + @Test + public void entityQueries7() { + var company = SCompany_.company_; + assertThat(query().from(company).select(company.officialName).fetch()) + .isEqualTo(Collections.emptyList()); + } + + @Test + public void in() { + assertThat(query().from(cat).where(cat.dtype.in("C", "CX")).fetchCount()).isEqualTo(6L); + } + + @Test + public void limit_offset() { + assertThat( + query() + .from(cat) + .orderBy(cat.id.asc()) + .limit(2) + .offset(2) + .select(cat.id, cat.name) + .fetch()) + .hasSize(2); + } + + @Test + public void list() { + assertThat(query().from(cat).where(cat.dtype.eq("C")).select(cat.id).fetch()).hasSize(6); + } + + @Test + public void list_limit_and_offset() { + assertThat(query().from(cat).orderBy(cat.id.asc()).offset(3).limit(3).select(cat.id).fetch()) + .hasSize(3); + } + + @Test + public void list_limit_and_offset2() { + var tuples = + query().from(cat).orderBy(cat.id.asc()).offset(3).limit(3).select(cat.id, cat.name).fetch(); + assertThat(tuples).hasSize(3); + assertThat(tuples.getFirst().size()).isEqualTo(2); + } + + @Test + public void list_limit_and_offset3() { + var tuples = + query() + .from(cat) + .orderBy(cat.id.asc()) + .offset(3) + .limit(3) + .select(Projections.tuple(cat.id, cat.name)) + .fetch(); + assertThat(tuples).hasSize(3); + assertThat(tuples.getFirst().size()).isEqualTo(2); + } + + @Test + public void list_multiple() { + print( + query() + .from(cat) + .where(cat.dtype.eq("C")) + .select(cat.id, cat.name, cat.bodyweight) + .fetch()); + } + + @Test + public void list_non_path() { + assertThat( + query() + .from(cat) + .where(cat.dtype.eq("C")) + .select(cat.birthdate.year(), cat.birthdate.month(), cat.birthdate.dayOfMonth()) + .fetch()) + .hasSize(6); + } + + @Test + public void list_results() { + var results = + query().from(cat).limit(3).orderBy(cat.name.asc()).select(cat.name).fetchResults(); + assertThat(results.getResults()).isEqualTo(Arrays.asList("Beck", "Bobby", "Harold")); + assertThat(results.getTotal()).isEqualTo(6L); + } + + @Test + @ExcludeIn(Target.H2) + public void list_wildcard() { + assertThat(query().from(cat).where(cat.dtype.eq("C")).select(Wildcard.all).fetch()).hasSize(6); + } + + @Test + public void list_with_count() { + print( + query() + .from(cat) + .where(cat.dtype.eq("C")) + .groupBy(cat.name) + .select(cat.name, cat.id.count()) + .fetch()); + } + + @Test + public void list_with_limit() { + assertThat(query().from(cat).limit(3).select(cat.id).fetch()).hasSize(3); + } + + @Test + @ExcludeIn({Target.H2, Target.MYSQL}) + public void list_with_offset() { + assertThat(query().from(cat).orderBy(cat.id.asc()).offset(3).select(cat.id).fetch()).hasSize(3); + } + + @Test + @ExcludeIn(Target.HSQLDB) + public void no_from() { + assertThat(query().select(DateExpression.currentDate()).fetchFirst()).isNotNull(); + } + + @Test + public void null_as_uniqueResult() { + assertThat( + query() + .from(cat) + .where(cat.name.eq(UUID.randomUUID().toString())) + .select(cat.name) + .fetchOne()) + .isNull(); + } + + private void print(Iterable rows) { + for (Tuple row : rows) { + System.out.println(row); + } + } + + @Test + public void projections_duplicateColumns() { + var cat = new SAnimal_("cat"); + assertThat(query().from(cat).select(Projections.list(cat.count(), cat.count())).fetch()) + .hasSize(1); + } + + @Test + public void single_result() { + query().from(cat).select(cat.id).fetchFirst(); + } + + @Test + public void single_result_multiple() { + assertThat( + query() + .from(cat) + .orderBy(cat.id.asc()) + .select(new Expression[] {cat.id}) + .fetchFirst() + .get(cat.id) + .intValue()) + .isEqualTo(1); + } + + @Test + @SuppressWarnings("unchecked") + public void union() throws SQLException { + SubQueryExpression sq1 = select(cat.id.max()).from(cat); + SubQueryExpression sq2 = select(cat.id.min()).from(cat); + var list = query().union(sq1, sq2).list(); + assertThat(list).isNotEmpty(); + } + + @Test + @SuppressWarnings("unchecked") + public void union_all() { + SubQueryExpression sq1 = select(cat.id.max()).from(cat); + SubQueryExpression sq2 = select(cat.id.min()).from(cat); + var list = query().unionAll(sq1, sq2).list(); + assertThat(list).isNotEmpty(); + } + + @SuppressWarnings("unchecked") + @Test + @ExcludeIn({Target.DERBY, Target.POSTGRESQL}) + @Ignore // FIXME + public void union2() { + var rows = + query() + .union( + select(cat.name, cat.id).from(cat).where(cat.name.eq("Beck")).distinct(), + select(cat.name, null).from(cat).where(cat.name.eq("Kate")).distinct()) + .list(); + + assertThat(rows).hasSize(2); + for (Tuple row : rows) { + System.err.println(row); + } + } + + @SuppressWarnings("unchecked") + @Test + @ExcludeIn(Target.DERBY) + @Ignore // FIXME + public void union3() { + var cat2 = new SAnimal_("cat2"); + var rows = + query() + .union( + select(cat.id, cat2.id).from(cat).innerJoin(cat2).on(cat2.id.eq(cat.id)), + select(cat.id, null).from(cat)) + .list(); + + assertThat(rows).hasSize(12); + var nulls = 0; + for (Tuple row : rows) { + System.err.println(Collections.singletonList(row)); + if (row.get(1, Object.class) == null) { + nulls++; + } + } + assertThat(nulls).isEqualTo(6); + } + + @SuppressWarnings("unchecked") + @Test + @ExcludeIn({Target.DERBY, Target.POSTGRESQL}) + @Ignore // FIXME + public void union4() { + query() + .union( + cat, + select(cat.name, cat.id).from(cat).where(cat.name.eq("Beck")).distinct(), + select(cat.name, null).from(cat).where(cat.name.eq("Kate")).distinct()) + .select(cat.name, cat.id) + .fetch(); + } + + @SuppressWarnings("unchecked") + @Test + @ExcludeIn({Target.DERBY, Target.ORACLE}) + public void union5() { + var cat2 = new SAnimal_("cat2"); + var rows = + query() + .union( + select(cat.id, cat2.id).from(cat).join(cat2).on(cat2.id.eq(cat.id.add(1))), + select(cat.id, cat2.id).from(cat).join(cat2).on(cat2.id.eq(cat.id.add(1)))) + .list(); + + assertThat(rows).hasSize(5); + for (Tuple row : rows) { + int first = row.get(cat.id); + int second = row.get(cat2.id); + assertThat(second).isEqualTo(first + 1); + } + } + + @Test + public void unique_result() { + assertThat( + query().from(cat).orderBy(cat.id.asc()).limit(1).select(cat.id).fetchOne().intValue()) + .isEqualTo(1); + } + + @Test + public void unique_result_multiple() { + assertThat( + query() + .from(cat) + .orderBy(cat.id.asc()) + .limit(1) + .select(new Expression[] {cat.id}) + .fetchOne() + .get(cat.id) + .intValue()) + .isEqualTo(1); + } + + @Test + @ExcludeIn(Target.H2) + public void wildcard() { + var rows = query().from(cat).select(cat.all()).fetch(); + assertThat(rows).hasSize(6); + print(rows); + + // rows = query().from(cat).fetch(cat.id, cat.all()); + // assertEquals(6, rows.size()); + // print(rows); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/AggregationTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/AggregationTest.java new file mode 100644 index 0000000000..97f3227b72 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/AggregationTest.java @@ -0,0 +1,46 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.cat; + +import org.junit.Test; + +public class AggregationTest extends AbstractQueryTest { + + @Test + public void max() { + assertToString("max(cat.bodyWeight)", cat.bodyWeight.max()); + } + + @Test + public void min() { + assertToString("min(cat.bodyWeight)", cat.bodyWeight.min()); + } + + @Test + public void avg() { + assertToString("avg(cat.bodyWeight)", cat.bodyWeight.avg()); + } + + @Test + public void count() { + assertToString("count(cat)", cat.count()); + } + + @Test + public void countDistinct() { + assertToString("count(distinct cat)", cat.countDistinct()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Article.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Article.java new file mode 100644 index 0000000000..c4c08377d5 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Article.java @@ -0,0 +1,10 @@ +package com.querydsl.jpa; + +public class Article { + + String name; + + Content content; + + Person author; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/BooleanOperationsTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/BooleanOperationsTest.java new file mode 100644 index 0000000000..6f2a49df9e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/BooleanOperationsTest.java @@ -0,0 +1,104 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.cat; +import static com.querydsl.jpa.Constants.cust; +import static com.querydsl.jpa.Constants.kitten; +import static com.querydsl.jpa.JPAExpressions.selectFrom; +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.BooleanBuilder; +import org.junit.Test; + +public class BooleanOperationsTest extends AbstractQueryTest { + + @Test + public void booleanOperations_or() { + assertToString("cust is null or cat is null", cust.isNull().or(cat.isNull())); + } + + @Test + public void booleanOperations_and() { + assertToString("cust is null and cat is null", cust.isNull().and(cat.isNull())); + } + + @Test + public void booleanOperations_not() { + assertToString("not cust is null", cust.isNull().not()); + } + + @Test + public void booleanOperations2_and() { + cat.name.eq(cust.name.firstName).and(cat.bodyWeight.eq(kitten.bodyWeight)); + } + + @Test + public void booleanOperations2_or() { + cat.name.eq(cust.name.firstName).or(cat.bodyWeight.eq(kitten.bodyWeight)); + } + + @Test + public void logicalOperations_or() { + assertToString("cat = kitten or kitten = cat", cat.eq(kitten).or(kitten.eq(cat))); + } + + @Test + public void logicalOperations_and() { + assertToString("cat = kitten and kitten = cat", cat.eq(kitten).and(kitten.eq(cat))); + } + + @Test + public void logicalOperations_and2() { + assertToString( + "cat is null and (kitten is null or kitten.bodyWeight > ?1)", + cat.isNull().and(kitten.isNull().or(kitten.bodyWeight.gt(10)))); + } + + @Test + public void booleanBuilder1() { + var bb1 = new BooleanBuilder(); + bb1.and(cat.eq(cat)); + + var bb2 = new BooleanBuilder(); + bb2.or(cat.eq(cat)); + bb2.or(cat.eq(cat)); + + assertToString("cat = cat and (cat = cat or cat = cat)", bb1.and(bb2)); + } + + @Test + public void booleanBuilder2() { + var bb1 = new BooleanBuilder(); + bb1.and(cat.eq(cat)); + + var bb2 = new BooleanBuilder(); + bb2.or(cat.eq(cat)); + bb2.or(cat.eq(cat)); + + assertToString("cat = cat and (cat = cat or cat = cat)", bb1.and(bb2.getValue())); + } + + @Test + public void booleanBuilder_with_null_in_where() { + assertThat(selectFrom(cat).where(new BooleanBuilder()).toString()) + .isEqualTo("select cat\nfrom Cat cat"); + } + + @Test + public void booleanBuilder_with_null_in_having() { + assertThat(selectFrom(cat).groupBy(cat.name).having(new BooleanBuilder()).toString()) + .isEqualTo("select cat\nfrom Cat cat\ngroup by cat.name"); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/CastTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/CastTest.java new file mode 100644 index 0000000000..c20bc82fec --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/CastTest.java @@ -0,0 +1,60 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.core.types.dsl.NumberExpression; +import org.junit.Test; + +public class CastTest extends AbstractQueryTest { + + private static NumberExpression expr = Expressions.numberPath(Integer.class, "int"); + + @Test + public void bytes() { + assertThat(expr.byteValue().getType()).isEqualTo(Byte.class); + } + + @Test + public void doubles() { + assertThat(expr.doubleValue().getType()).isEqualTo(Double.class); + } + + @Test + public void floats() { + assertThat(expr.floatValue().getType()).isEqualTo(Float.class); + } + + @Test + public void integers() { + assertThat(expr.intValue().getType()).isEqualTo(Integer.class); + } + + @Test + public void longs() { + assertThat(expr.longValue().getType()).isEqualTo(Long.class); + } + + @Test + public void shorts() { + assertThat(expr.shortValue().getType()).isEqualTo(Short.class); + } + + @Test + public void stringCast() { + assertThat(expr.stringValue().getType()).isEqualTo(String.class); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/CollectionTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/CollectionTest.java new file mode 100644 index 0000000000..35a711a9a0 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/CollectionTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.cat; +import static com.querydsl.jpa.Constants.cat1; + +import com.querydsl.jpa.domain.Cat; +import org.junit.Test; + +public class CollectionTest extends AbstractQueryTest { + + @Test + public void constant_inElements_set() { + assertToString("?1 member of cat.kittensSet", cat.kittensSet.contains(new Cat())); + } + + @Test + public void constant_inElements_list() { + assertToString("?1 member of cat.kittens", cat.kittens.contains(new Cat())); + } + + @Test + public void path_inElements_list() { + assertToString("cat member of cat1.kittens", cat.in(cat1.kittens)); + } + + @Test + public void path_inElements_set() { + assertToString("cat member of cat1.kittensSet", cat.in(cat1.kittensSet)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/ComparableTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/ComparableTest.java new file mode 100644 index 0000000000..3fb6705b4f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/ComparableTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.cat; +import static com.querydsl.jpa.Constants.kitten; + +import org.junit.Test; + +public class ComparableTest extends AbstractQueryTest { + + @Test + public void eq() { + assertToString("cat.bodyWeight = kitten.bodyWeight", cat.bodyWeight.eq(kitten.bodyWeight)); + } + + @Test + public void goe() { + assertToString("cat.bodyWeight >= kitten.bodyWeight", cat.bodyWeight.goe(kitten.bodyWeight)); + } + + @Test + public void gt() { + assertToString("cat.bodyWeight > kitten.bodyWeight", cat.bodyWeight.gt(kitten.bodyWeight)); + } + + @Test + public void loe() { + assertToString("cat.bodyWeight <= kitten.bodyWeight", cat.bodyWeight.loe(kitten.bodyWeight)); + } + + @Test + public void lt() { + assertToString("cat.bodyWeight < kitten.bodyWeight", cat.bodyWeight.lt(kitten.bodyWeight)); + } + + @Test + public void ne() { + assertToString("cat.bodyWeight <> kitten.bodyWeight", cat.bodyWeight.ne(kitten.bodyWeight)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Constants.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Constants.java new file mode 100644 index 0000000000..59e000957e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Constants.java @@ -0,0 +1,179 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.jpa.domain.QAccount; +import com.querydsl.jpa.domain.QAnimal; +import com.querydsl.jpa.domain.QAuditLog; +import com.querydsl.jpa.domain.QBar; +import com.querydsl.jpa.domain.QCalendar; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.domain.QCatalog; +import com.querydsl.jpa.domain.QCompany; +import com.querydsl.jpa.domain.QCustomer; +import com.querydsl.jpa.domain.QDocument; +import com.querydsl.jpa.domain.QDomesticCat; +import com.querydsl.jpa.domain.QFoo; +import com.querydsl.jpa.domain.QFormula; +import com.querydsl.jpa.domain.QItem; +import com.querydsl.jpa.domain.QName; +import com.querydsl.jpa.domain.QNameList; +import com.querydsl.jpa.domain.QNamed; +import com.querydsl.jpa.domain.QOrder; +import com.querydsl.jpa.domain.QParameter; +import com.querydsl.jpa.domain.QPayment; +import com.querydsl.jpa.domain.QPerson; +import com.querydsl.jpa.domain.QPlayer; +import com.querydsl.jpa.domain.QPrice; +import com.querydsl.jpa.domain.QProduct; +import com.querydsl.jpa.domain.QShow; +import com.querydsl.jpa.domain.QStatus; +import com.querydsl.jpa.domain.QStatusChange; +import com.querydsl.jpa.domain.QStore; +import com.querydsl.jpa.domain.QUser; + +public final class Constants { + + private Constants() {} + + static final QAccount account = new QAccount("account"); + + static final QAnimal an = new QAnimal("an"); + + static final QBar bar = new QBar("bar"); + + static final QCalendar calendar = new QCalendar("calendar"); + + // QCat + static final QCat cat = new QCat("cat"); + + static final QCat cat1 = new QCat("cat1"); + + static final QCat cat2 = new QCat("cat2"); + + static final QCat cat3 = new QCat("cat3"); + + static final QCat cat4 = new QCat("cat4"); + + static final QCat cat5 = new QCat("cat5"); + + // QCatalog + static final QCatalog catalog = new QCatalog("catalog"); + + static final QCat child = new QCat("child"); + // QCompany + static final QCompany company = new QCompany("company"); + + static final QCompany company1 = new QCompany("company1"); + + static final QCompany company2 = new QCompany("company2"); + + static final QCompany company3 = new QCompany("company3"); + + static final QCompany company4 = new QCompany("company4"); + + static final QCompany company5 = new QCompany("company5"); + + // Customer + static final QCustomer cust = new QCustomer("cust"); + + // Qdoofus d = new Qdoofus("d"); + + // QDocument + static final QDocument doc = new QDocument("doc"); + + // DomesticQCat + static final QDomesticCat domesticCat = new QDomesticCat("domesticCat"); + + static final QCat fatcat = new QCat("fatcat"); + + static final QFoo foo = new QFoo("foo"); + + static final QFormula form = new QFormula("form"); + // QItem + static final QItem item = new QItem("item"); + + static final QCat kit = new QCat("kit"); + + static final QCat kitten = new QCat("kitten"); + + static final QCat kitten2 = new QCat("kitten2"); + + static final QCat kittens = new QCat("kittens"); + + static final QNameList list = new QNameList("list"); + + // AuditLog + static final QAuditLog log = new QAuditLog("log"); + + static final QNamed m = new QNamed("m"); + + static final QCat mate = new QCat("mate"); + + static final QCat mother = new QCat("mother"); + + static final QNamed n = new QNamed("n"); + + static final QName name = new QName("name"); + + static final QCat offspr = new QCat("offspr"); + + static final QOrder ord = new QOrder("ord"); + // Order + static final QOrder order = new QOrder("order"); + + static final QPerson p = new QPerson("p"); + + static final QParameter param = new QParameter("param"); + + // Payment + static final QPayment payment = new QPayment("payment"); + + static final QPerson person = new QPerson("person"); + + static final QPlayer player = new QPlayer("player"); + + // Price + static final QPrice price = new QPrice("price"); + + static final QProduct prod = new QProduct("prod"); + + // Product + static final QProduct product = new QProduct("product"); + + static final QCat qat = new QCat("qat"); + + static final QCat rival = new QCat("rival"); + + static final QShow show = new QShow("show"); + + static final QStatus status = new QStatus("status"); + + static final QStatusChange statusChange = new QStatusChange("statusChange"); + + static final QStore store = new QStore("store"); + + // User + static final QUser user = new QUser("user"); + + static final QUser user1 = new QUser("user1"); + + static final QUser user2 = new QUser("user2"); + + static final QUser user3 = new QUser("user3"); + + static final QUser user4 = new QUser("user4"); + + static final QUser user5 = new QUser("user5"); +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/ConstructorsTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/ConstructorsTest.java new file mode 100644 index 0000000000..8cb7e8c2d6 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/ConstructorsTest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.cat; + +import com.querydsl.core.types.ConstructorExpression; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.Projections; +import org.junit.Ignore; +import org.junit.Test; + +public class ConstructorsTest extends AbstractQueryTest { + + public static final class BookmarkDTO {} + + public static final class QBookmarkDTO extends ConstructorExpression { + + private static final long serialVersionUID = 2664671413344744578L; + + public QBookmarkDTO(Expression address) { + super(BookmarkDTO.class, new Class[] {String.class}, address); + } + } + + @Test + @Ignore + public void constructors() { + ConstructorExpression c = + Projections.constructor( + com.querydsl.jpa.domain.Cat.class, new Class[] {String.class}, cat.name); + assertToString("new " + com.querydsl.jpa.domain.Cat.class.getName() + "(cat.name)", c); + assertToString( + "new " + getClass().getName() + "$BookmarkDTO(cat.name)", new QBookmarkDTO(cat.name)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Content.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Content.java new file mode 100644 index 0000000000..ab6ce7cc5f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Content.java @@ -0,0 +1,6 @@ +package com.querydsl.jpa; + +public class Content { + + Article article; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/CustomExpressionsTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/CustomExpressionsTest.java new file mode 100644 index 0000000000..d6de837793 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/CustomExpressionsTest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.cat; +import static com.querydsl.jpa.Constants.cust; + +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.TemplateFactory; +import com.querydsl.core.types.dsl.StringTemplate; +import java.util.Arrays; +import org.junit.Test; + +public class CustomExpressionsTest extends AbstractQueryTest { + + public static class MyCustomExpr extends StringTemplate { + + private static final long serialVersionUID = 1L; + + public MyCustomExpr(Expression... args) { + super(TemplateFactory.DEFAULT.create("myCustom({0},{1})"), Arrays.asList(args)); + } + } + + @Test + public void customExpressions() { + assertToString("myCustom(cust,cat)", new MyCustomExpr(cust, cat)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/CustomFinder.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/CustomFinder.java new file mode 100644 index 0000000000..e8a367365a --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/CustomFinder.java @@ -0,0 +1,52 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.BooleanBuilder; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.dsl.ComparablePath; +import com.querydsl.core.types.dsl.EntityPathBase; +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.core.types.dsl.SimplePath; +import com.querydsl.jpa.impl.JPAQuery; +import jakarta.persistence.EntityManager; +import java.util.List; +import java.util.Map; + +/** + * @author tiwe + */ +public final class CustomFinder { + + private CustomFinder() {} + + @SuppressWarnings("unchecked") + public static List findCustom( + EntityManager em, Class entityClass, Map filters, String sort) { + EntityPath entityPath = new EntityPathBase<>(entityClass, "entity"); + var builder = new BooleanBuilder(); + for (Map.Entry entry : filters.entrySet()) { + SimplePath property = + Expressions.path((Class) entry.getValue().getClass(), entityPath, entry.getKey()); + builder.and(property.eq(entry.getValue())); + } + ComparablePath sortProperty = Expressions.comparablePath(Comparable.class, entityPath, sort); + return new JPAQuery(em) + .from(entityPath) + .where(builder.getValue()) + .orderBy(sortProperty.asc()) + .select(entityPath) + .fetch(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/DateTimeTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/DateTimeTest.java new file mode 100644 index 0000000000..61fe87fe36 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/DateTimeTest.java @@ -0,0 +1,66 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.catalog; + +import com.querydsl.core.types.dsl.DateExpression; +import com.querydsl.core.types.dsl.DateTimeExpression; +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.core.types.dsl.TimeExpression; +import java.util.Date; +import org.junit.Test; + +public class DateTimeTest extends AbstractQueryTest { + + @Test + public void currentDate() { + assertToString("current_date", DateExpression.currentDate()); + } + + @Test + public void currentDate2() { + assertToString("current_date", DateTimeExpression.currentDate()); + } + + @Test + public void currentTime() { + assertToString("current_time", TimeExpression.currentTime()); + } + + @Test + public void currentTimestamp() { + assertToString("current_timestamp", DateTimeExpression.currentTimestamp()); + } + + @Test + public void dayOfMonth() { + assertToString("day(date)", Expressions.datePath(Date.class, "date").dayOfMonth()); + } + + @Test + public void dayOfMonth2() { + assertToString("day(date)", Expressions.dateTimePath(Date.class, "date").dayOfMonth()); + } + + @Test + public void dateOperations2() { + // catalog.effectiveDate.second(); + // catalog.effectiveDate.minute(); + // catalog.effectiveDate.hour(); + catalog.effectiveDate.dayOfMonth(); + catalog.effectiveDate.month(); + catalog.effectiveDate.year(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/DependenciesTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/DependenciesTest.java new file mode 100644 index 0000000000..f8cfbdfa96 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/DependenciesTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; +import jdepend.framework.JDepend; +import org.junit.Test; + +public class DependenciesTest { + + @Test + public void test() throws IOException { + var jdepend = new JDepend(); + jdepend.addDirectory("target/classes/com/querydsl/jpa"); + jdepend.addDirectory("target/classes/com/querydsl/jpa/hibernate"); + jdepend.addDirectory("target/classes/com/querydsl/jpa/hibernate/sql"); + jdepend.addDirectory("target/classes/com/querydsl/jpa/impl"); + jdepend.addDirectory("target/classes/com/querydsl/jpa/sql"); + + jdepend.analyze(); + assertThat(jdepend.containsCycles()).isFalse(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/DummySessionHolder.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/DummySessionHolder.java new file mode 100644 index 0000000000..f44f4e9ad6 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/DummySessionHolder.java @@ -0,0 +1,31 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.jpa.hibernate.SessionHolder; +import org.hibernate.query.NativeQuery; +import org.hibernate.query.Query; + +public class DummySessionHolder implements SessionHolder { + + @Override + public Query createQuery(String queryString) { + throw new UnsupportedOperationException(); + } + + @Override + public NativeQuery createSQLQuery(String queryString) { + throw new UnsupportedOperationException(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/EJBQLTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/EJBQLTest.java new file mode 100644 index 0000000000..49339f468b --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/EJBQLTest.java @@ -0,0 +1,50 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.cat; + +import org.junit.Test; + +public class EJBQLTest extends AbstractQueryTest { + + // Any function or operator defined by EJB-QL 3.0: substring(), trim(), + // lower(), upper(), length(), locate(), abs(), sqrt(), bit_length(), + // mod() + // substring(), + // trim(), + // lower(), + // upper(), + // length(), + // locate(), + // abs(), + // sqrt(), + // bit_length(), + // mod() + + @Test + public void trim() { + assertToString("trim(cat.name)", cat.name.trim()); + } + + @Test + public void lower() { + assertToString("lower(cat.name)", cat.name.lower()); + } + + @Test + public void upper() { + assertToString("upper(cat.name)", cat.name.upper()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/ExpressionSerializationTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/ExpressionSerializationTest.java new file mode 100644 index 0000000000..5688864360 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/ExpressionSerializationTest.java @@ -0,0 +1,27 @@ +package com.querydsl.jpa; + +import static com.querydsl.core.testutil.Serialization.serialize; +import static com.querydsl.jpa.JPAExpressions.selectFrom; +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.types.Expression; +import com.querydsl.jpa.domain.QCat; +import java.io.IOException; +import org.junit.Test; + +public class ExpressionSerializationTest { + + @Test + public void serialize1() throws Exception { + Expression expr = QCat.cat.name.eq("test"); + Expression expr2 = serialize(expr); + + assertThat(expr2).isEqualTo(expr); + assertThat(expr2.hashCode()).isEqualTo(expr.hashCode()); + } + + @Test + public void query() throws ClassNotFoundException, IOException { + selectFrom(QCat.cat).where(serialize(QCat.cat.name.eq("test"))); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/FeaturesTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/FeaturesTest.java new file mode 100644 index 0000000000..95400fce5e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/FeaturesTest.java @@ -0,0 +1,172 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.cat; +import static com.querydsl.jpa.Constants.cust; +import static com.querydsl.jpa.Constants.kitten; +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.jpa.domain.QAccount; +import com.querydsl.jpa.domain.QInheritedProperties; +import org.junit.Test; + +public class FeaturesTest extends AbstractQueryTest { + + @Test + public void domainConstruction() { + var i = new QInheritedProperties("i"); + assertThat(i.superclassProperty).isNotNull(); + assertThat(i.classProperty).isNotNull(); + } + + @Test + public void domainConstruction2() { + var a = new QAccount("a"); + assertThat(a.embeddedData.someData).isNotNull(); + } + + @Test + public void basicStructure() { + assertThat(cat.getMetadata().getParent()).isNull(); + } + + @Test + public void basicStructure2() { + assertThat(cat.alive.getMetadata().getParent()).isEqualTo(cat); + } + + @Test + public void basicStructure3() { + assertThat(cat.getMetadata().getName()).isEqualTo("cat"); + } + + @Test + public void argumentHandling() { + // Kitty is reused, so it should be used via one named parameter + assertToString( + "cat.name = ?1 or cust.name.firstName = ?2 or kitten.name = ?3", + cat.name.eq("Kitty").or(cust.name.firstName.eq("Hans")).or(kitten.name.eq("Kitty"))); + } + + @Test + public void basicOperations() { + assertToString("cat.bodyWeight = kitten.bodyWeight", cat.bodyWeight.eq(kitten.bodyWeight)); + } + + @Test + public void basicOperations2() { + assertToString("cat.bodyWeight <> kitten.bodyWeight", cat.bodyWeight.ne(kitten.bodyWeight)); + } + + @Test + public void basicOperations3() { + assertToString( + "cat.bodyWeight + kitten.bodyWeight = kitten.bodyWeight", + cat.bodyWeight.add(kitten.bodyWeight).eq(kitten.bodyWeight)); + } + + @Test + public void equalsAndNotEqualsForAllExpressions() { + assertToString("cat.name = cust.name.firstName", cat.name.eq(cust.name.firstName)); + } + + @Test + public void equalsAndNotEqualsForAllExpressions2() { + assertToString("cat.name <> cust.name.firstName", cat.name.ne(cust.name.firstName)); + } + + @Test + public void groupingOperationsAndNullChecks() { + // in, not in, between, is null, is not null, is empty, is not empty, + // member of and not member of + // in, + // not in, + // between, + // is null, + // is not null, + // is empty, + // is not empty, + // member of + // not member of + kitten.in(cat.kittens); + kitten.in(cat.kittens).not(); + kitten.bodyWeight.between(10, 20); + kitten.bodyWeight.isNull(); + kitten.bodyWeight.isNotNull(); + cat.kittens.isEmpty(); + cat.kittens.isNotEmpty(); + } + + @Test + public void toString_() { + assertToString("cat", cat); + assertToString("cat.alive", cat.alive); + assertToString("cat.bodyWeight", cat.bodyWeight); + assertToString("cat.name", cat.name); + + assertToString("cust.name", cust.name); + assertToString("cust.name.firstName = ?1", cust.name.firstName.eq("Martin")); + + // toString("cat.kittens as kitten", cat.kittens.as(kitten)); + + assertToString("cat.bodyWeight + ?1", cat.bodyWeight.add(10)); + assertToString("cat.bodyWeight - ?1", cat.bodyWeight.subtract(10)); + assertToString("cat.bodyWeight * ?1", cat.bodyWeight.multiply(10)); + assertToString("cat.bodyWeight / ?1", cat.bodyWeight.divide(10)); + + // toString("cat.bodyWeight as bw", cat.bodyWeight.as("bw")); + + assertToString("kitten member of cat.kittens", kitten.in(cat.kittens)); + + // toString("distinct cat.bodyWeight", distinct(cat.bodyWeight)); + } + + // /** + // * specs : + // * http://opensource.atlassian.com/projects/hibernate/browse/HHH-1538 + // */ + // @SuppressWarnings("unchecked") + // @Test + // public void bug326650() { + // assertEquals(Long.class, sum(var(Byte.class)).getType()); + // assertEquals(Long.class, sum(var(Short.class)).getType()); + // assertEquals(Long.class, sum(var(Integer.class)).getType()); + // assertEquals(Long.class, sum(var(Long.class)).getType()); + // + // assertEquals(Double.class, sum(var(Float.class)).getType()); + // assertEquals(Double.class, sum(var(Double.class)).getType()); + // + // assertEquals(BigInteger.class, sum(var(BigInteger.class)).getType()); + // assertEquals(BigDecimal.class, sum(var(BigDecimal.class)).getType()); + // + // // sum to var + // NumberExpression sum = (NumberExpression) sum(var(Integer.class)); // via Java + // level cast + // sum = sum(var(Integer.class)).longValue(); + // assertNotNull(sum); + // + // // sum comparison + // + // sum(var(Integer.class)).gt(0); + // sum(var(Integer.class)).intValue().gt(0); + // + // } + + private > NumberPath var(Class cl) { + return Expressions.numberPath(cl, "var"); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateBase.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateBase.java new file mode 100644 index 0000000000..4b2871944d --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateBase.java @@ -0,0 +1,179 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + +import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.DefaultQueryMetadata; +import com.querydsl.core.Target; +import com.querydsl.core.Tuple; +import com.querydsl.core.group.GroupBy; +import com.querydsl.core.testutil.ExcludeIn; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.Expression; +import com.querydsl.jpa.domain.Cat; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.domain.QGroup; +import com.querydsl.jpa.hibernate.DefaultSessionHolder; +import com.querydsl.jpa.hibernate.HibernateDeleteClause; +import com.querydsl.jpa.hibernate.HibernateQuery; +import com.querydsl.jpa.testutil.HibernateTestRunner; +import java.io.IOException; +import java.util.List; +import org.hibernate.LockMode; +import org.hibernate.Session; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestRule; +import org.junit.runner.RunWith; + +/** + * @author tiwe + */ +@RunWith(HibernateTestRunner.class) +public class HibernateBase extends AbstractJPATest implements HibernateTest { + + private static final QCat cat = QCat.cat; + + @Rule @ClassRule public static TestRule jpaProviderRule = new JPAProviderRule(); + + @Rule @ClassRule public static TestRule targetRule = new TargetRule(); + + private Session session; + + @Override + protected HibernateQuery query() { + return new HibernateQuery(session, getTemplates()); + } + + protected HibernateDeleteClause delete(EntityPath path) { + return new HibernateDeleteClause(session, path); + } + + @Override + protected HibernateQuery testQuery() { + return new HibernateQuery( + new DefaultSessionHolder(session), getTemplates(), new DefaultQueryMetadata()); + } + + protected JPQLTemplates getTemplates() { + return HQLTemplates.DEFAULT; + } + + @Override + public void setSession(Session session) { + this.session = session; + } + + @Override + protected void save(Object entity) { + session.save(entity); + } + + @Test + public void query_exposure() { + // save(new Cat()); + List results = query().from(cat).select(cat).createQuery().list(); + assertThat(results).isNotNull(); + assertThat(results).isNotEmpty(); + } + + @Test + public void delete() { + assertThat(delete(QGroup.group).execute()).isEqualTo(0); + } + + @Test + public void with_comment() { + query().from(cat).setComment("my comment").select(cat).fetch(); + } + + @Test + public void lockMode() { + query().from(cat).setLockMode(cat, LockMode.PESSIMISTIC_WRITE).select(cat).fetch(); + } + + @Test + public void flushMode() { + query().from(cat).setFlushMode(org.hibernate.FlushMode.AUTO).select(cat).fetch(); + } + + @Test + public void scroll() throws IOException { + CloseableIterator cats = + new ScrollableResultsIterator( + query().from(cat).select(cat).createQuery().getResultList()); + assertThat(cats).hasNext(); + while (cats.hasNext()) { + assertThat(cats.next()).isNotNull(); + } + cats.close(); + } + + @Test + public void scrollTuple() throws IOException { + CloseableIterator rows = + new ScrollableResultsIterator( + query().from(cat).select(cat.name, cat.birthdate).createQuery().getResultList()); + assertThat(rows).hasNext(); + while (rows.hasNext()) { + var row = rows.next(); + assertThat(row.size()).isEqualTo(2); + } + rows.close(); + } + + @SuppressWarnings("unchecked") + @Test + public void createQuery() { + List rows = query().from(cat).select(cat.id, cat.name).createQuery().list(); + for (Tuple row : rows) { + assertThat(row.size()).isEqualTo(2); + } + } + + @SuppressWarnings("unchecked") + @Test + public void createQuery2() { + List rows = + query().from(cat).select(new Expression[] {cat.id, cat.name}).createQuery().list(); + for (Tuple row : rows) { + assertThat(row.size()).isEqualTo(2); + } + } + + @Test + public void createQuery3() { + List rows = query().from(cat).select(cat.name).createQuery().list(); + for (String row : rows) { + assertThat(row instanceof String).isTrue(); + } + } + + @Test + @ExcludeIn(Target.DERBY) + public void createQuery4() { + assertDoesNotThrow( + () -> + query() + .from(cat) + .leftJoin(cat.kittens) + .fetchJoin() + .distinct() + .transform(GroupBy.groupBy(cat.id).as(cat))); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateHandlerTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateHandlerTest.java new file mode 100644 index 0000000000..b10d025ac8 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateHandlerTest.java @@ -0,0 +1,153 @@ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.easymock.EasyMock.anyObject; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.hibernate.ScrollMode.FORWARD_ONLY; + +import com.mysema.commons.lang.IteratorAdapter; +import com.querydsl.core.types.FactoryExpression; +import com.querydsl.jpa.domain4.Library; +import jakarta.persistence.PersistenceException; +import jakarta.persistence.Query; +import java.util.Iterator; +import java.util.List; +import org.eclipse.persistence.internal.jpa.EJBQueryImpl; +import org.eclipse.persistence.internal.localization.ExceptionLocalization; +import org.hibernate.query.NativeQuery; +import org.hibernate.query.spi.ScrollableResultsImplementor; +import org.hibernate.transform.ResultTransformer; +import org.junit.Test; + +public class HibernateHandlerTest { + + private final HibernateHandler hibernateHandler = new HibernateHandler(); + private final NativeQuery nativeQuery = createMock(NativeQuery.class); + private final String alias = "library"; + private final Class classType = Library.class; + + @Test + public void should_add_entity() { + expect(nativeQuery.unwrap(NativeQuery.class)).andReturn(nativeQuery); + expect(nativeQuery.addEntity(alias, classType)).andReturn(nativeQuery); + replay(nativeQuery); + + hibernateHandler.addEntity(nativeQuery, alias, classType); + + verify(nativeQuery); + } + + @Test(expected = PersistenceException.class) + public void addEntity_should_throw_persistence_exception_when_invalid_query_type() { + var notSupportedQuery = (Query) createMock(EJBQueryImpl.class); + var expectedThrow = + new PersistenceException( + ExceptionLocalization.buildMessage( + "unable_to_unwrap_jpa", + new String[] {Query.class.getName(), NativeQuery.class.getName()})); + + expect(notSupportedQuery.unwrap(NativeQuery.class)).andThrow(expectedThrow); + replay(notSupportedQuery); + + hibernateHandler.addEntity(notSupportedQuery, alias, classType); + } + + @Test + public void should_add_scalar() { + expect(nativeQuery.unwrap(NativeQuery.class)).andReturn(nativeQuery); + expect(nativeQuery.addScalar(alias)).andReturn(nativeQuery); + replay(nativeQuery); + + hibernateHandler.addScalar(nativeQuery, alias, classType); + + verify(nativeQuery); + } + + @Test(expected = PersistenceException.class) + public void addScalar_should_throw_persistence_exception_when_invalid_query_type() { + var notSupportedQuery = (EJBQueryImpl) createMock(EJBQueryImpl.class); + var expectedThrow = + new PersistenceException( + ExceptionLocalization.buildMessage( + "unable_to_unwrap_jpa", + new String[] {Query.class.getName(), NativeQuery.class.getName()})); + + expect(notSupportedQuery.unwrap(NativeQuery.class)).andThrow(expectedThrow); + replay(notSupportedQuery); + + hibernateHandler.addScalar(notSupportedQuery, alias, classType); + } + + @Test + public void should_get_false_when_check_native_query_type() { + assertThat(hibernateHandler.createNativeQueryTyped()).isFalse(); + } + + @Test + public void + should_get_true_when_check_wrap_entity_projections_for_hibernate_query_syntax_by_using_curly_braces() { + assertThat(hibernateHandler.wrapEntityProjections()).isTrue(); + } + + @Test + public void should_return_transforming_iterator_when_call_iterate_function() { + var scrollableResultsImplementor = + (ScrollableResultsImplementor) createMock(ScrollableResultsImplementor.class); + FactoryExpression factoryExpression = createMock(FactoryExpression.class); + + expect(nativeQuery.unwrap(org.hibernate.query.Query.class)).andReturn(nativeQuery); + expect(nativeQuery.scroll(FORWARD_ONLY)).andReturn(scrollableResultsImplementor); + expect(nativeQuery.getResultList()).andReturn(List.of()); + replay(nativeQuery); + + assertThat(hibernateHandler.iterate(nativeQuery, factoryExpression)) + .isInstanceOf(TransformingIterator.class); + } + + @Test + public void should_return_iterator_adapter_when_call_iterate_function() { + var query = (Query) createMock(Query.class); + var queryResultList = (List) createMock(List.class); + var iterator = (Iterator) createMock(Iterator.class); + + expect(query.unwrap(org.hibernate.query.Query.class)) + .andThrow(new PersistenceException("Cannot unwrap Query")); + expect(query.getResultList()).andReturn(queryResultList); + expect(queryResultList.iterator()).andReturn(iterator); + replay(query); + + assertThat(hibernateHandler.iterate(query, null).getClass()).isEqualTo(IteratorAdapter.class); + } + + @Test + public void should_ReturnTransformingIterator_when_other_query_implementor() { + var query = (Query) createMock(Query.class); + FactoryExpression factoryExpression = createMock(FactoryExpression.class); + var queryResultList = (List) createMock(List.class); + var iterator = (Iterator) createMock(Iterator.class); + + expect(query.unwrap(org.hibernate.query.Query.class)) + .andThrow(new PersistenceException("Cannot unwrap Query")); + expect(query.getResultList()).andReturn(queryResultList); + expect(queryResultList.iterator()).andReturn(iterator); + replay(query); + + assertThat(hibernateHandler.iterate(query, factoryExpression).getClass()) + .isEqualTo(TransformingIterator.class); + } + + @Test + public void should_transform() { + FactoryExpression projection = createMock(FactoryExpression.class); + + expect(nativeQuery.unwrap(org.hibernate.query.Query.class)).andReturn(nativeQuery); + expect(nativeQuery.setResultTransformer(anyObject(ResultTransformer.class))) + .andReturn(nativeQuery); + replay(nativeQuery); + + assertThat(hibernateHandler.transform(nativeQuery, projection)).isTrue(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateQueryFactoryTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateQueryFactoryTest.java new file mode 100644 index 0000000000..fa67dcd593 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateQueryFactoryTest.java @@ -0,0 +1,60 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.domain.query.QAnimal; +import com.querydsl.jpa.hibernate.MutinyQueryFactory; +import java.util.function.Supplier; +import org.easymock.EasyMock; +import org.hibernate.Session; +import org.junit.Before; +import org.junit.Test; + +public class HibernateQueryFactoryTest { + + private MutinyQueryFactory queryFactory; + + @Before + public void setUp() { + Supplier provider = () -> EasyMock.createNiceMock(Session.class); + queryFactory = new MutinyQueryFactory(JPQLTemplates.DEFAULT, provider); + } + + @Test + public void query() { + assertThat(queryFactory.query()).isNotNull(); + } + + @Test + public void from() { + assertThat(queryFactory.from(QAnimal.animal)).isNotNull(); + } + + @Test + public void delete() { + assertThat(queryFactory.delete(QAnimal.animal)).isNotNull(); + } + + @Test + public void update() { + assertThat(queryFactory.update(QAnimal.animal)).isNotNull(); + } + + @Test + public void insert() { + assertThat(queryFactory.insert(QAnimal.animal)).isNotNull(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateQueryMutabilityTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateQueryMutabilityTest.java new file mode 100644 index 0000000000..1d42353717 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateQueryMutabilityTest.java @@ -0,0 +1,66 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.QueryMutability; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.hibernate.HibernateQuery; +import com.querydsl.jpa.testutil.HibernateTestRunner; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import org.hibernate.Session; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; + +@Ignore +@RunWith(HibernateTestRunner.class) +public class HibernateQueryMutabilityTest implements HibernateTest { + + private Session session; + + protected HibernateQuery query() { + return new HibernateQuery(session); + } + + @Override + public void setSession(Session session) { + this.session = session; + } + + @Test + public void test() + throws SecurityException, + IllegalArgumentException, + NoSuchMethodException, + IllegalAccessException, + InvocationTargetException, + IOException { + var cat = QCat.cat; + HibernateQuery query = query().from(cat); + new QueryMutability(query).test(cat, cat.name); + } + + @Test + public void clone_() { + var cat = QCat.cat; + HibernateQuery query = query().from(cat).where(cat.name.isNotNull()); + HibernateQuery query2 = query.clone(session); + assertThat(query2.getMetadata().getJoins()).isEqualTo(query.getMetadata().getJoins()); + assertThat(query2.getMetadata().getWhere()).isEqualTo(query.getMetadata().getWhere()); + query2.select(cat).fetch(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateQueryTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateQueryTest.java new file mode 100644 index 0000000000..51bf45a1e8 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateQueryTest.java @@ -0,0 +1,46 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.BooleanBuilder; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.domain.QEmployee; +import com.querydsl.jpa.domain.QUser; +import com.querydsl.jpa.hibernate.HibernateQuery; +import org.junit.Test; + +public class HibernateQueryTest { + + @Test + public void clone_() { + var cat = QCat.cat; + var emptyBooleanBuilder = new BooleanBuilder(); + HibernateQuery hq = + new HibernateQuery().from(cat).where(cat.name.isNull().and(emptyBooleanBuilder)); + HibernateQuery hq2 = hq.clone(); + assertThat(hq2).isNotNull(); + } + + @Test + public void innerJoin() { + HibernateQuery hqlQuery = new HibernateQuery(); + var employee = QEmployee.employee; + hqlQuery.from(employee); + hqlQuery.innerJoin(employee.user, QUser.user); + assertThat(hqlQuery.toString()) + .isEqualTo("select employee\nfrom Employee employee\n inner join employee.user as user"); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateSQLBase.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateSQLBase.java new file mode 100644 index 0000000000..e75c174210 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateSQLBase.java @@ -0,0 +1,87 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.ExcludeIn; +import com.querydsl.jpa.domain.Cat; +import com.querydsl.jpa.domain.Color; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.domain.sql.SAnimal_; +import com.querydsl.jpa.hibernate.sql.HibernateSQLQuery; +import com.querydsl.jpa.testutil.HibernateTestRunner; +import com.querydsl.sql.SQLTemplates; +import org.hibernate.Session; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestRule; +import org.junit.runner.RunWith; + +@RunWith(HibernateTestRunner.class) +public class HibernateSQLBase extends AbstractSQLTest implements HibernateTest { + + @Rule @ClassRule public static TestRule targetRule = new TargetRule(); + + private final SQLTemplates templates = Mode.getSQLTemplates(); + + private final SAnimal_ cat = new SAnimal_("cat"); + + private Session session; + + @Override + protected HibernateSQLQuery query() { + return new HibernateSQLQuery(session, templates); + } + + @Override + public void setSession(Session session) { + this.session = session; + } + + @Before + public void setUp() { + if (query().from(cat).fetchCount() == 0) { + session.save(new Cat("Beck", 1, Color.BLACK)); + session.save(new Cat("Kate", 2, Color.BLACK)); + session.save(new Cat("Kitty", 3, Color.BLACK)); + session.save(new Cat("Bobby", 4, Color.BLACK)); + session.save(new Cat("Harold", 5, Color.BLACK)); + session.save(new Cat("Tim", 6, Color.BLACK)); + session.flush(); + } + } + + @Test + public void entityQueries_createQuery() { + var cat = new SAnimal_("cat"); + var catEntity = QCat.cat; + + var query = query().from(cat).select(catEntity).createQuery(); + assertThat(query.list()).hasSize(6); + } + + @Test + @ExcludeIn(Target.MYSQL) + public void entityQueries_createQuery2() { + var cat = new SAnimal_("CAT"); + var catEntity = QCat.cat; + + var query = query().from(cat).select(catEntity).createQuery(); + assertThat(query.list()).hasSize(6); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateTest.java new file mode 100644 index 0000000000..857ba210a4 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/HibernateTest.java @@ -0,0 +1,26 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import org.hibernate.Session; + +/** + * @author Shredder121 + */ +public interface HibernateTest { + + void setSession(Session session); +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/IntegrationBase.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/IntegrationBase.java new file mode 100644 index 0000000000..3aef7b0cb9 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/IntegrationBase.java @@ -0,0 +1,208 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.cat; +import static com.querydsl.jpa.Constants.kitten; +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.types.EntityPath; +import com.querydsl.jpa.domain.Cat; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.hibernate.HibernateDeleteClause; +import com.querydsl.jpa.hibernate.HibernateInsertClause; +import com.querydsl.jpa.hibernate.HibernateQuery; +import com.querydsl.jpa.hibernate.HibernateUpdateClause; +import com.querydsl.jpa.hibernate.HibernateUtil; +import com.querydsl.jpa.testutil.HibernateTestRunner; +import java.util.Arrays; +import java.util.List; +import org.hibernate.ScrollMode; +import org.hibernate.Session; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(HibernateTestRunner.class) +public class IntegrationBase extends ParsingTest implements HibernateTest { + + private Session session; + + @Override + protected QueryHelper query() { + return new QueryHelper(HQLTemplates.DEFAULT) { + @Override + public void parse() { + try { + System.out.println("query : " + toString().replace('\n', ' ')); + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + serializer.serialize(getMetadata(), false, null); + var query = session.createQuery(serializer.toString()); + HibernateUtil.setConstants(query, serializer.getConstants(), getMetadata().getParams()); + query.list(); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(e); + } finally { + System.out.println(); + } + } + }; + } + + @Override + @Test + public void groupBy() throws Exception { + // NOTE : commented out, because HQLSDB doesn't support these queries + } + + @Override + @Test + public void groupBy_2() throws Exception { + // NOTE : commented out, because HQLSDB doesn't support these queries + } + + @Override + @Test + public void orderBy() throws Exception { + // NOTE : commented out, because HQLSDB doesn't support these queries + } + + @Override + @Test + public void docoExamples910() throws Exception { + // NOTE : commented out, because HQLSDB doesn't support these queries + } + + private HibernateDeleteClause delete(EntityPath entity) { + return new HibernateDeleteClause(session, entity); + } + + private HibernateUpdateClause update(EntityPath entity) { + return new HibernateUpdateClause(session, entity); + } + + private HibernateInsertClause insert(EntityPath entity) { + return new HibernateInsertClause(session, entity); + } + + @Test + public void scroll() { + session.save(new Cat("Bob", 10)); + session.save(new Cat("Steve", 11)); + + var cat = QCat.cat; + HibernateQuery query = new HibernateQuery(session); + var results = query.from(cat).select(cat).scroll(ScrollMode.SCROLL_INSENSITIVE); + while (results.next()) { + assertThat(((Object[]) results.get())[0]).isNotNull(); + } + results.close(); + } + + @Test + public void insert() { + session.save(new Cat("Bob", 10)); + + var cat = QCat.cat; + var amount = insert(cat).set(cat.name, "Bobby").set(cat.alive, false).execute(); + assertThat(amount).isEqualTo(1); + + assertThat(query().from(cat).where(cat.name.eq("Bobby")).fetchCount()).isEqualTo(1L); + } + + @Test + public void insert2() { + session.save(new Cat("Bob", 10)); + + var cat = QCat.cat; + var amount = insert(cat).columns(cat.name, cat.alive).values("Bobby", false).execute(); + assertThat(amount).isEqualTo(1); + + assertThat(query().from(cat).where(cat.name.eq("Bobby")).fetchCount()).isEqualTo(1L); + } + + @Test + public void insert3() { + session.save(new Cat("Bob", 10)); + + var cat = QCat.cat; + var bob = new QCat("Bob"); + + var amount = + insert(cat) + .columns(cat.name, cat.alive) + .select(JPAExpressions.select(bob.name, bob.alive).from(bob)) + .execute(); + assertThat(amount).isEqualTo(1); + + assertThat(query().from(cat).where(cat.name.eq("Bobby")).fetchCount()).isEqualTo(1L); + } + + @Test + public void update() { + session.save(new Cat("Bob", 10)); + session.save(new Cat("Steve", 11)); + + var cat = QCat.cat; + var amount = + update(cat) + .where(cat.name.eq("Bob")) + .set(cat.name, "Bobby") + .set(cat.alive, false) + .execute(); + assertThat(amount).isEqualTo(1); + + assertThat(query().from(cat).where(cat.name.eq("Bob")).fetchCount()).isEqualTo(0L); + } + + @Test + public void update_with_null() { + session.save(new Cat("Bob", 10)); + session.save(new Cat("Steve", 11)); + + var cat = QCat.cat; + var amount = + update(cat) + .where(cat.name.eq("Bob")) + .set(cat.name, (String) null) + .set(cat.alive, false) + .execute(); + assertThat(amount).isEqualTo(1); + } + + @Test + public void delete() { + session.save(new Cat("Bob", 10)); + session.save(new Cat("Steve", 11)); + + var cat = QCat.cat; + var amount = delete(cat).where(cat.name.eq("Bob")).execute(); + assertThat(amount).isEqualTo(1); + } + + @Test + public void collection() throws Exception { + List cats = Arrays.asList(new Cat("Bob", 10), new Cat("Steve", 11)); + for (Cat cat : cats) { + session.save(cat); + } + + query().from(cat).innerJoin(cat.kittens, kitten).where(kitten.in(cats)).parse(); + } + + @Override + public void setSession(Session session) { + this.session = session; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPABase.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPABase.java new file mode 100644 index 0000000000..1cb77eec6c --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPABase.java @@ -0,0 +1,326 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.core.group.GroupBy.list; +import static com.querydsl.jpa.JPAExpressions.selectFrom; +import static com.querydsl.jpa.JPAExpressions.selectOne; +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.DefaultQueryMetadata; +import com.querydsl.core.Target; +import com.querydsl.core.Tuple; +import com.querydsl.core.group.GroupBy; +import com.querydsl.core.testutil.ExcludeIn; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.jpa.domain.Cat; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.domain.QCatSummary; +import com.querydsl.jpa.domain.QChild; +import com.querydsl.jpa.domain.QGroup; +import com.querydsl.jpa.domain.QParent; +import com.querydsl.jpa.impl.JPADeleteClause; +import com.querydsl.jpa.impl.JPAQuery; +import com.querydsl.jpa.testutil.JPATestRunner; +import jakarta.persistence.EntityManager; +import jakarta.persistence.FlushModeType; +import jakarta.persistence.LockModeType; +import java.sql.Connection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestRule; +import org.junit.runner.RunWith; + +/** + * @author tiwe + */ +@RunWith(JPATestRunner.class) +public class JPABase extends AbstractJPATest implements JPATest { + + private static final QCat cat = QCat.cat; + + @Rule @ClassRule public static TestRule targetRule = new TargetRule(); + + @Rule @ClassRule public static TestRule jpaProviderRule = new JPAProviderRule(); + + private EntityManager entityManager; + + @Override + protected JPAQuery query() { + return new JPAQuery(entityManager); + } + + protected JPADeleteClause delete(EntityPath path) { + return new JPADeleteClause(entityManager, path); + } + + @Override + protected JPAQuery testQuery() { + return new JPAQuery(entityManager, new DefaultQueryMetadata()); + } + + @Override + public void setEntityManager(EntityManager entityManager) { + this.entityManager = entityManager; + } + + @Override + protected void save(Object entity) { + entityManager.persist(entity); + entityManager.flush(); + } + + @Test + @NoEclipseLink + @NoOpenJPA + @NoHibernate + public void connection_access() { + assertThat(query().from(cat).select(cat).createQuery().unwrap(Connection.class)).isNotNull(); + } + + @Test + @Ignore + public void delete() { + delete(cat).execute(); + } + + @Test + public void delete2() { + assertThat(delete(QGroup.group).execute()).isEqualTo(0); + } + + @Test + @NoBatooJPA + public void delete_where() { + delete(cat).where(cat.name.eq("XXX")).execute(); + } + + @Test + @ExcludeIn(Target.MYSQL) + public void delete_where_any() { + delete(cat).where(cat.kittens.any().name.eq("XXX")).execute(); + } + + @Test + @NoBatooJPA + @ExcludeIn(Target.MYSQL) + public void delete_where_subQuery_exists() { + var parent = cat; + var child = new QCat("kitten"); + + delete(child) + .where( + child.id.eq(-100), + selectOne().from(parent).where(parent.id.eq(-200), child.in(parent.kittens)).exists()) + .execute(); + } + + @Test + @NoBatooJPA + public void delete_where_subQuery2() { + var child = QChild.child; + var parent = QParent.parent; + + var subQuery = selectFrom(parent).where(parent.id.eq(2), child.parent.eq(parent)); + // child.in(parent.children)); + + delete(child).where(child.id.eq(1), subQuery.exists()).execute(); + } + + @Test + public void finder() { + Map conditions = new HashMap<>(); + conditions.put("name", "Bob123"); + + List cats = CustomFinder.findCustom(entityManager, Cat.class, conditions, "name"); + assertThat(cats).hasSize(1); + assertThat(cats.getFirst().getName()).isEqualTo("Bob123"); + } + + @Test + public void flushMode() { + assertThat(query().from(cat).setFlushMode(FlushModeType.AUTO).select(cat).fetch()).isNotEmpty(); + } + + @Test + @NoEclipseLink + @NoOpenJPA + public void hint() { + var query = + query().from(cat).setHint("org.hibernate.cacheable", true).select(cat).createQuery(); + + assertThat(query).isNotNull(); + assertThat(query.getHints()).containsKey("org.hibernate.cacheable"); + assertThat(query.getResultList()).isNotEmpty(); + } + + @Test + public void hint2() { + assertThat(query().from(cat).setHint("org.hibernate.cacheable", true).select(cat).fetch()) + .isNotEmpty(); + } + + @Test + @NoHibernate + @NoOpenJPA + @NoBatooJPA + public void hint3() { + var query = + query() + .from(cat) + .setHint("eclipselink.batch.type", "IN") + .setHint("eclipselink.batch", "person.workAddress") + .setHint("eclipselink.batch", "person.homeAddress") + .select(cat) + .createQuery(); + + assertThat(query).isNotNull(); + assertThat(query.getHints()).containsEntry("eclipselink.batch", "person.homeAddress"); + } + + @Test + @ExcludeIn(Target.DERBY) + public void iterate() { + var cats = query().from(cat).select(cat).iterate(); + while (cats.hasNext()) { + var cat = cats.next(); + assertThat(cat).isNotNull(); + } + cats.close(); + } + + @Test + public void limit1_uniqueResult() { + assertThat(query().from(cat).limit(1).select(cat).fetchOne()).isNotNull(); + } + + @Test + public void lockMode() { + var query = + query().from(cat).setLockMode(LockModeType.PESSIMISTIC_READ).select(cat).createQuery(); + assertThat(LockModeType.PESSIMISTIC_READ).isEqualTo(query.getLockMode()); + assertThat(query.getResultList()).isNotEmpty(); + } + + @Test + public void lockMode2() { + assertThat(query().from(cat).setLockMode(LockModeType.PESSIMISTIC_READ).select(cat).fetch()) + .isNotEmpty(); + } + + @Test + public void queryExposure() { + // save(new Cat(20)); + List results = query().from(cat).select(cat).createQuery().getResultList(); + assertThat(results).isNotNull(); + assertThat(results).isNotEmpty(); + } + + @Test + @Ignore // isn't a valid JPQL query + public void subquery_uniqueResult() { + var cat2 = new QCat("cat2"); + + var exists = selectOne().from(cat2).where(cat2.eyecolor.isNotNull()).exists(); + assertThat( + query() + .from(cat) + .where(cat.breed.eq(0).not()) + .select(new QCatSummary(cat.breed.count(), exists)) + .fetchOne()) + .isNotNull(); + } + + @SuppressWarnings("unchecked") + @Test + @NoEclipseLink + @NoBatooJPA + public void createQuery() { + List rows = query().from(cat).select(cat.id, cat.name).createQuery().getResultList(); + for (Tuple row : rows) { + assertThat(row.size()).isEqualTo(2); + } + } + + @SuppressWarnings("unchecked") + @Test + @NoEclipseLink + @NoBatooJPA + public void createQuery2() { + List rows = query().from(cat).select(cat.id, cat.name).createQuery().getResultList(); + for (Tuple row : rows) { + assertThat(row.size()).isEqualTo(2); + } + } + + @Test + public void createQuery3() { + List rows = query().from(cat).select(cat.name).createQuery().getResultList(); + for (String row : rows) { + assertThat(row).isNotNull(); + } + } + + @Test + @NoHibernate + @ExcludeIn(Target.DERBY) + public void createQuery4() { + var rows = query().from(cat).select(new Expression[] {Expressions.nullExpression()}).fetch(); + for (Tuple row : rows) { + assertThat(row).isNotNull(); + assertThat(row.size()).isEqualTo(1); + assertThat(row.get(Expressions.nullExpression())).isNull(); + } + } + + @Test + public void fetchCountResultsGroupByWithMultipleFields() { + var results = + query() + .from(cat) + .groupBy(cat.alive, cat.breed) + .select(cat.alive, cat.breed, cat.id.sumLong()) + .fetchResults(); + + assertThat(results.getTotal()).isEqualTo(1); + } + + @Test + public void fetchCountResultsGroupByWithHaving() { + var results = + query() + .from(cat) + .groupBy(cat.alive) + .having(cat.id.sumLong().gt(5)) + .select(cat.alive, cat.id.sumLong()) + .fetchResults(); + + assertThat(results.getTotal()).isEqualTo(1); + } + + @Test + public void shouldTransformWithGroupBy() { + Map> transform = + query().select(cat).from(cat).transform(GroupBy.groupBy(cat.alive).as(list(cat))); + + assertThat(transform).hasSize(1); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPACollectionAnyVisitorTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPACollectionAnyVisitorTest.java new file mode 100644 index 0000000000..0e67c52faf --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPACollectionAnyVisitorTest.java @@ -0,0 +1,162 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.support.Context; +import com.querydsl.core.types.ConstantImpl; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.ExpressionUtils; +import com.querydsl.core.types.Predicate; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.domain.QCompany; +import com.querydsl.jpa.domain.QDomesticCat; +import com.querydsl.jpa.domain.QEmployee; +import org.junit.Test; + +public class JPACollectionAnyVisitorTest { + + private QCat cat = QCat.cat; + + @Test + public void path() { + assertThat(serialize(cat.kittens.any())).isEqualTo("cat_kittens_0"); + } + + @Test + public void longer_path() { + assertThat(serialize(cat.kittens.any().name)).isEqualTo("cat_kittens_0.name"); + } + + @Test + public void nested_any_booleanOperation() { + var company = QCompany.company; + Predicate predicate = company.departments.any().employees.any().firstName.eq("Bob"); + assertThat(serialize(predicate)) + .isEqualTo( + """ + exists (select 1 + from company.departments as company_departments_0 + inner join company_departments_0.employees as company_departments_0_employees_1 + where company_departments_0_employees_1.firstName = ?1)\ + """); + } + + @Test + public void simple_booleanOperation() { + Predicate predicate = cat.kittens.any().name.eq("Ruth123"); + assertThat(serialize(predicate)) + .isEqualTo( + """ + exists (select 1 + from cat.kittens as cat_kittens_0 + where cat_kittens_0.name = ?1)\ + """); + } + + @Test + public void simple_booleanOperation_longPath() { + Predicate predicate = cat.kittens.any().kittens.any().name.eq("Ruth123"); + assertThat(serialize(predicate)) + .isEqualTo( + """ + exists (select 1 + from cat.kittens as cat_kittens_0 + inner join cat_kittens_0.kittens as cat_kittens_0_kittens_1 + where cat_kittens_0_kittens_1.name = ?1)\ + """); + } + + @Test + public void simple_booleanOperation_elementCollection() { + var employee = QEmployee.employee; + Predicate predicate = employee.jobFunctions.any().stringValue().eq("CODER"); + assertThat(serialize(predicate)) + .isEqualTo( + """ + exists (select 1 + from Employee employee_1463394548 + inner join employee_1463394548.jobFunctions as employee_jobFunctions_0 + where employee_1463394548 = employee and str(employee_jobFunctions_0) = ?1)\ + """); + } + + @Test + public void simple_stringOperation() { + Predicate predicate = cat.kittens.any().name.substring(1).eq("uth123"); + assertThat(serialize(predicate)) + .isEqualTo( + """ + exists (select 1 + from cat.kittens as cat_kittens_0 + where substring(cat_kittens_0.name,2) = ?1)\ + """); + } + + @Test + public void and_operation() { + Predicate predicate = + cat.kittens.any().name.eq("Ruth123").and(cat.kittens.any().bodyWeight.gt(10.0)); + assertThat(serialize(predicate)) + .isEqualTo( + """ + exists (select 1 + from cat.kittens as cat_kittens_0 + where cat_kittens_0.name = ?1) and exists (select 1 + from cat.kittens as cat_kittens_1 + where cat_kittens_1.bodyWeight > ?2)\ + """); + } + + @Test + public void template() { + Expression templateExpr = + ExpressionUtils.template( + Boolean.class, "{0} = {1}", cat.kittens.any().name, ConstantImpl.create("Ruth123")); + assertThat(serialize(templateExpr)) + .isEqualTo( + """ + exists (select 1 + from cat.kittens as cat_kittens_0 + where cat_kittens_0.name = ?1)\ + """); + } + + @Test + public void cast() { + // JPAQuery query = new JPAQuery(em).from(QPerson.person); + // QDog anyDog = QPerson.person.animals.any().as(QDog.class); + // query.where(anyDog.gender.eq("M")); + // List foundOwners = query.fetch(QPerson.person); + + var anyCat = QCat.cat.kittens.any().as(QDomesticCat.class); + Predicate predicate = anyCat.name.eq("X"); + + assertThat(serialize(predicate)) + .isEqualTo( + """ + exists (select 1 + from cat.kittens as cat_kittens_0 + where cat_kittens_0.name = ?1)\ + """); + } + + private String serialize(Expression expression) { + Expression transformed = expression.accept(new JPACollectionAnyVisitor(), new Context()); + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT, null); + serializer.handle(transformed); + return serializer.toString(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAIntegrationBase.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAIntegrationBase.java new file mode 100644 index 0000000000..31781a1917 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAIntegrationBase.java @@ -0,0 +1,60 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.jpa.impl.JPAProvider; +import com.querydsl.jpa.impl.JPAUtil; +import com.querydsl.jpa.testutil.JPATestRunner; +import jakarta.persistence.EntityManager; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.rules.TestRule; +import org.junit.runner.RunWith; + +@RunWith(JPATestRunner.class) +public class JPAIntegrationBase extends ParsingTest implements JPATest { + + @Rule @ClassRule public static TestRule targetRule = new TargetRule(); + + @Rule @ClassRule public static TestRule hibernateOnly = new JPAProviderRule(); + + private EntityManager em; + + private JPQLTemplates templates; + + @Override + protected QueryHelper query() { + return new QueryHelper(templates) { + @Override + public void parse() { + var serializer = new JPQLSerializer(templates); + serializer.serialize(getMetadata(), false, null); + var query = em.createQuery(serializer.toString()); + JPAUtil.setConstants(query, serializer.getConstants(), getMetadata().getParams()); + try { + query.getResultList(); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + }; + } + + @Override + public void setEntityManager(EntityManager em) { + this.em = em; + this.templates = JPAProvider.getTemplates(em); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAProviderRule.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAProviderRule.java new file mode 100644 index 0000000000..7af87fd192 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAProviderRule.java @@ -0,0 +1,42 @@ +package com.querydsl.jpa; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.EmptyStatement; +import java.util.Arrays; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +/** + * @author tiwe + */ +public class JPAProviderRule implements TestRule { + + @Override + public Statement apply(Statement base, Description description) { + var noEclipseLink = description.getAnnotation(NoEclipseLink.class); + var noOpenJPA = description.getAnnotation(NoOpenJPA.class); + var noBatooJPA = description.getAnnotation(NoBatooJPA.class); + var noHibernate = description.getAnnotation(NoHibernate.class); + var mode = Mode.mode.get(); + if (mode == null) { + return base; + } else if (noEclipseLink != null + && applies(noEclipseLink.value()) + && mode.contains("-eclipselink")) { + return EmptyStatement.DEFAULT; + } else if (noOpenJPA != null && applies(noOpenJPA.value()) && mode.contains("-openjpa")) { + return EmptyStatement.DEFAULT; + } else if (noBatooJPA != null && applies(noBatooJPA.value()) && mode.contains("-batoo")) { + return EmptyStatement.DEFAULT; + } else if (noHibernate != null && applies(noHibernate.value()) && !mode.contains("-")) { + return EmptyStatement.DEFAULT; + } else { + return base; + } + } + + private boolean applies(Target[] targets) { + return targets.length == 0 || Arrays.asList(targets).contains(Mode.target.get()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAProviderTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAProviderTest.java new file mode 100644 index 0000000000..dea5041bcc --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAProviderTest.java @@ -0,0 +1,112 @@ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.jpa.impl.JPAProvider; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.HashMap; +import java.util.Map; +import org.junit.After; +import org.junit.Ignore; +import org.junit.Test; + +// 5.664 +public class JPAProviderTest { + + private EntityManagerFactory factory; + + private EntityManager em; + + @After + public void tearDown() { + if (em != null) { + em.close(); + } + if (factory != null) { + factory.close(); + } + } + + @Test + public void hibernate() { + Map properties = new HashMap<>(); + factory = Persistence.createEntityManagerFactory("h2", properties); + em = factory.createEntityManager(); + System.out.println(em.getDelegate().getClass()); + assertThat(JPAProvider.getTemplates(em)).isEqualTo(Hibernate5Templates.DEFAULT); + } + + @Test + public void hibernate_for_proxy() { + factory = Persistence.createEntityManagerFactory("h2"); + em = factory.createEntityManager(); + InvocationHandler handler = + new InvocationHandler() { + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return method.invoke(em, args); + } + }; + var proxy = + (EntityManager) + Proxy.newProxyInstance( + Thread.currentThread().getContextClassLoader(), + new Class[] {EntityManager.class}, + handler); + assertThat(JPAProvider.getTemplates(proxy)).isEqualTo(Hibernate5Templates.DEFAULT); + } + + @Test + public void eclipseLink() { + factory = Persistence.createEntityManagerFactory("h2-eclipselink"); + em = factory.createEntityManager(); + System.out.println(em.getDelegate().getClass()); + System.out.println(em.getProperties()); + assertThat(JPAProvider.getTemplates(em)).isEqualTo(EclipseLinkTemplates.DEFAULT); + } + + @Test + public void eclipseLink_for_proxy() { + factory = Persistence.createEntityManagerFactory("h2-eclipselink"); + em = factory.createEntityManager(); + InvocationHandler handler = + new InvocationHandler() { + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return method.invoke(em, args); + } + }; + var proxy = + (EntityManager) + Proxy.newProxyInstance( + Thread.currentThread().getContextClassLoader(), + new Class[] {EntityManager.class}, + handler); + assertThat(JPAProvider.getTemplates(proxy)).isEqualTo(EclipseLinkTemplates.DEFAULT); + } + + @Test + @Ignore // doesn't work on JDK 7 + public void openJPA() { + factory = Persistence.createEntityManagerFactory("derby-openjpa"); + em = factory.createEntityManager(); + System.out.println(em.getDelegate().getClass()); + System.out.println(em.getProperties()); + assertThat(JPAProvider.getTemplates(em)).isEqualTo(OpenJPATemplates.DEFAULT); + } + + @Test + @Ignore // temporarily ignored, since Batoo hangs on EntityManager creation + public void batoo() { + factory = Persistence.createEntityManagerFactory("h2-batoo"); + em = factory.createEntityManager(); + System.out.println(em.getDelegate().getClass()); + System.out.println(em.getProperties()); + assertThat(JPAProvider.getTemplates(em)).isEqualTo(BatooTemplates.DEFAULT); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAQueryFactoryTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAQueryFactoryTest.java new file mode 100644 index 0000000000..ed5e80d29f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAQueryFactoryTest.java @@ -0,0 +1,161 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.jpa.domain.QAnimal; +import com.querydsl.jpa.impl.JPAQueryFactory; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Supplier; +import org.easymock.EasyMock; +import org.junit.Before; +import org.junit.Test; + +public class JPAQueryFactoryTest { + + private EntityManagerFactory factoryMock; + + private EntityManager mock; + + private JPAQueryFactory queryFactory; + + private JPQLQueryFactory queryFactory2; + + private JPAQueryFactory queryFactory3; + + private Map properties = new HashMap<>(); + + @Before + public void setUp() { + factoryMock = EasyMock.createMock(EntityManagerFactory.class); + mock = EasyMock.createMock(EntityManager.class); + Supplier provider = () -> mock; + queryFactory = new JPAQueryFactory(JPQLTemplates.DEFAULT, provider); + queryFactory2 = queryFactory; + + queryFactory3 = new JPAQueryFactory(provider); + } + + @Test + public void query() { + assertThat(queryFactory.query()).isNotNull(); + } + + @Test + public void query2() { + queryFactory2.query().from(QAnimal.animal); + } + + @Test + public void query3() { + EasyMock.expect(mock.getEntityManagerFactory()).andReturn(factoryMock); + EasyMock.expect(factoryMock.getProperties()).andReturn(properties); + EasyMock.expect(mock.unwrap(EasyMock.anyObject(Class.class))).andReturn(mock).atLeastOnce(); + + EasyMock.replay(mock, factoryMock); + + queryFactory3.query().from(QAnimal.animal); + + EasyMock.verify(mock, factoryMock); + } + + @Test + public void from() { + assertThat(queryFactory.from(QAnimal.animal)).isNotNull(); + } + + @Test + public void delete() { + assertThat(queryFactory.delete(QAnimal.animal)).isNotNull(); + } + + @Test + public void delete2() { + queryFactory2.delete(QAnimal.animal).where(QAnimal.animal.bodyWeight.gt(0)); + } + + @Test + public void delete3() { + EasyMock.expect(mock.getEntityManagerFactory()).andReturn(factoryMock); + EasyMock.expect(factoryMock.getProperties()).andReturn(properties); + EasyMock.expect(mock.unwrap(EasyMock.anyObject(Class.class))).andReturn(mock).atLeastOnce(); + EasyMock.replay(mock, factoryMock); + + assertThat(queryFactory3.delete(QAnimal.animal)).isNotNull(); + + EasyMock.verify(mock, factoryMock); + } + + @Test + public void update() { + assertThat(queryFactory.update(QAnimal.animal)).isNotNull(); + } + + @Test + public void update2() { + queryFactory2 + .update(QAnimal.animal) + .set(QAnimal.animal.birthdate, new Date()) + .where(QAnimal.animal.birthdate.isNull()); + } + + @Test + public void update3() { + EasyMock.expect(mock.getEntityManagerFactory()).andReturn(factoryMock); + EasyMock.expect(factoryMock.getProperties()).andReturn(properties); + EasyMock.expect(mock.unwrap(EasyMock.anyObject(Class.class))).andReturn(mock).atLeastOnce(); + EasyMock.replay(mock, factoryMock); + + assertThat(queryFactory3.update(QAnimal.animal)).isNotNull(); + + EasyMock.verify(mock, factoryMock); + } + + @Test + public void insert() { + assertThat(queryFactory.insert(QAnimal.animal)).isNotNull(); + } + + @Test + public void insert2() { + queryFactory2.insert(QAnimal.animal).set(QAnimal.animal.birthdate, new Date()); + } + + @Test + public void insert3() { + EasyMock.expect(mock.getEntityManagerFactory()).andReturn(factoryMock); + EasyMock.expect(factoryMock.getProperties()).andReturn(properties); + EasyMock.expect(mock.unwrap(EasyMock.anyObject(Class.class))).andReturn(mock).atLeastOnce(); + EasyMock.replay(mock, factoryMock); + + assertThat(queryFactory3.insert(QAnimal.animal)).isNotNull(); + + EasyMock.verify(mock, factoryMock); + } + + @Test + public void insert4() { + queryFactory + .insert(QAnimal.animal) + .columns(QAnimal.animal.id, QAnimal.animal.birthdate) + .select( + JPAExpressions.select(QAnimal.animal.id, QAnimal.animal.birthdate) + .from(QAnimal.animal)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAQueryMixinTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAQueryMixinTest.java new file mode 100644 index 0000000000..b88cbbc5b1 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAQueryMixinTest.java @@ -0,0 +1,236 @@ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.JoinExpression; +import com.querydsl.core.JoinType; +import com.querydsl.core.types.OrderSpecifier; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.domain.QCompany; +import com.querydsl.jpa.domain.QDepartment; +import com.querydsl.jpa.domain.QEmployee; +import com.querydsl.jpa.domain4.QBookMark; +import com.querydsl.jpa.domain4.QBookVersion; +import java.util.Arrays; +import java.util.Collections; +import org.junit.Test; + +public class JPAQueryMixinTest { + + private JPAQueryMixin mixin = new JPAQueryMixin<>(); + + @Test + public void where_null() { + mixin.where((Predicate) null); + } + + @Test + public void orderBy() { + var cat = QCat.cat; + var catMate = new QCat("cat_mate"); + mixin.from(cat); + mixin.orderBy(cat.mate.name.asc()); + + var md = mixin.getMetadata(); + assertThat(md.getJoins()) + .isEqualTo( + Arrays.asList( + new JoinExpression(JoinType.DEFAULT, cat), + new JoinExpression(JoinType.LEFTJOIN, cat.mate.as(catMate)))); + assertThat(md.getOrderBy()).isEqualTo(Collections.singletonList(catMate.name.asc())); + } + + @Test + public void orderBy_nonRoot_twice() { + var department = QDepartment.department; + var departmentCompany = new QCompany("department_company"); + var departmentCompanyCeo = new QEmployee("department_company_ceo"); + mixin.from(department); + mixin.orderBy(department.company.ceo.firstName.asc(), department.company.ceo.lastName.asc()); + + var md = mixin.getMetadata(); + assertThat(md.getJoins()) + .isEqualTo( + Arrays.asList( + new JoinExpression(JoinType.DEFAULT, department), + new JoinExpression(JoinType.LEFTJOIN, department.company.as(departmentCompany)), + new JoinExpression( + JoinType.LEFTJOIN, departmentCompany.ceo.as(departmentCompanyCeo)))); + assertThat(md.getOrderBy()) + .isEqualTo( + Arrays.asList( + departmentCompanyCeo.firstName.asc(), departmentCompanyCeo.lastName.asc())); + } + + @Test + public void orderBy_where() { + var cat = QCat.cat; + mixin.from(cat); + mixin.where(cat.mate.name.isNotNull()); + mixin.orderBy(cat.mate.name.asc()); + + var md = mixin.getMetadata(); + assertThat(md.getJoins()) + .isEqualTo(Collections.singletonList(new JoinExpression(JoinType.DEFAULT, cat))); + assertThat(md.getOrderBy()).isEqualTo(Collections.singletonList(cat.mate.name.asc())); + } + + @Test + public void orderBy_groupBy() { + var cat = QCat.cat; + mixin.from(cat); + mixin.groupBy(cat.mate.name); + mixin.orderBy(cat.mate.name.asc()); + + var md = mixin.getMetadata(); + assertThat(md.getJoins()) + .isEqualTo(Collections.singletonList(new JoinExpression(JoinType.DEFAULT, cat))); + assertThat(md.getOrderBy()).isEqualTo(Collections.singletonList(cat.mate.name.asc())); + } + + @Test + public void orderBy_operation() { + var cat = QCat.cat; + var catMate = new QCat("cat_mate"); + mixin.from(cat); + mixin.orderBy(cat.mate.name.lower().asc()); + + var md = mixin.getMetadata(); + assertThat(md.getJoins()) + .isEqualTo( + Arrays.asList( + new JoinExpression(JoinType.DEFAULT, cat), + new JoinExpression(JoinType.LEFTJOIN, cat.mate.as(catMate)))); + assertThat(md.getOrderBy()).isEqualTo(Collections.singletonList(catMate.name.lower().asc())); + } + + @Test + public void orderBy_long() { + var cat = QCat.cat; + var catMate = new QCat("cat_mate"); + var catMateMate = new QCat("cat_mate_mate"); + mixin.from(cat); + mixin.orderBy(cat.mate.mate.name.asc()); + + var md = mixin.getMetadata(); + assertThat(md.getJoins()) + .isEqualTo( + Arrays.asList( + new JoinExpression(JoinType.DEFAULT, cat), + new JoinExpression(JoinType.LEFTJOIN, cat.mate.as(catMate)), + new JoinExpression(JoinType.LEFTJOIN, catMate.mate.as(catMateMate)))); + assertThat(md.getOrderBy()).isEqualTo(Collections.singletonList(catMateMate.name.asc())); + } + + @Test + public void orderBy_reuse() { + var cat = QCat.cat; + var mate = new QCat("mate"); + mixin.from(cat); + mixin.leftJoin(cat.mate, mate); + mixin.orderBy(cat.mate.name.asc()); + + var md = mixin.getMetadata(); + assertThat(md.getJoins()) + .isEqualTo( + Arrays.asList( + new JoinExpression(JoinType.DEFAULT, cat), + new JoinExpression(JoinType.LEFTJOIN, cat.mate.as(mate)))); + assertThat(md.getOrderBy()).isEqualTo(Collections.singletonList(mate.name.asc())); + } + + @Test + public void orderBy_long_reuse() { + var cat = QCat.cat; + var mate = new QCat("mate"); + var mateMate = new QCat("mate_mate"); + mixin.from(cat); + mixin.leftJoin(cat.mate, mate); + mixin.orderBy(cat.mate.mate.name.asc()); + + var md = mixin.getMetadata(); + assertThat(md.getJoins()) + .isEqualTo( + Arrays.asList( + new JoinExpression(JoinType.DEFAULT, cat), + new JoinExpression(JoinType.LEFTJOIN, cat.mate.as(mate)), + new JoinExpression(JoinType.LEFTJOIN, mate.mate.as(mateMate)))); + assertThat(md.getOrderBy()).isEqualTo(Collections.singletonList(mateMate.name.asc())); + } + + @Test + public void orderBy_any() { + var cat = QCat.cat; + var catKittens = new QCat("cat_kittens"); + mixin.from(cat); + mixin.orderBy(cat.kittens.any().name.asc()); + + var md = mixin.getMetadata(); + assertThat(md.getJoins()) + .isEqualTo( + Arrays.asList( + new JoinExpression(JoinType.DEFAULT, cat), + new JoinExpression(JoinType.LEFTJOIN, cat.kittens.as(catKittens)))); + assertThat(md.getOrderBy()).isEqualTo(Collections.singletonList(catKittens.name.asc())); + } + + @Test + public void orderBy_embeddable() { + var bookVersion = QBookVersion.bookVersion; + mixin.from(bookVersion); + mixin.orderBy(bookVersion.definition.name.asc()); + + var md = mixin.getMetadata(); + assertThat(md.getJoins()) + .isEqualTo(Collections.singletonList(new JoinExpression(JoinType.DEFAULT, bookVersion))); + assertThat(md.getOrderBy()) + .isEqualTo(Collections.singletonList(bookVersion.definition.name.asc())); + } + + @SuppressWarnings("unchecked") + @Test + public void orderBy_embeddable2() { + var article = QArticle.article; + var articleContentArticle = new QArticle("article_content_article"); + mixin.from(article); + mixin.orderBy(article.content.article.name.asc()); + + var md = mixin.getMetadata(); + assertThat(md.getJoins()) + .isEqualTo( + Arrays.asList( + new JoinExpression(JoinType.DEFAULT, article), + new JoinExpression( + JoinType.LEFTJOIN, article.content.article.as(articleContentArticle)))); + assertThat(md.getOrderBy()) + .isEqualTo(Collections.singletonList(articleContentArticle.name.asc())); + } + + @SuppressWarnings("unchecked") + @Test + public void orderBy_embeddable_collection() { + var bookVersion = QBookVersion.bookVersion; + var bookMark = new QBookMark("bookVersion_definition_bookMarks"); + mixin.from(bookVersion); + mixin.orderBy(bookVersion.definition.bookMarks.any().comment.asc()); + + var md = mixin.getMetadata(); + assertThat(md.getJoins()) + .isEqualTo(Collections.singletonList(new JoinExpression(JoinType.DEFAULT, bookVersion))); + assertThat(md.getOrderBy()) + .isEqualTo( + Collections.singletonList( + Expressions.stringPath(bookVersion.definition.bookMarks, "comment").asc())); + } + + @Test + public void orderBy_nullsLast() { + var cat = QCat.cat; + mixin.from(cat); + mixin.orderBy(cat.mate.name.asc().nullsLast()); + assertThat(mixin.getMetadata().getOrderBy().get(0).getNullHandling()) + .isEqualTo(OrderSpecifier.NullHandling.NullsLast); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAQueryMutability2Test.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAQueryMutability2Test.java new file mode 100644 index 0000000000..cb460b22c2 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAQueryMutability2Test.java @@ -0,0 +1,134 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.core.types.dsl.Expressions.numberOperation; +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.types.Operator; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.impl.JPAQuery; +import com.querydsl.jpa.testutil.JPATestRunner; +import jakarta.persistence.EntityManager; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(JPATestRunner.class) +public class JPAQueryMutability2Test implements JPATest { + + private EntityManager entityManager; + + private final Operator customOperator = + new Operator() { + @Override + public String name() { + return "custom"; + } + + @Override + public String toString() { + return name(); + } + + @Override + public Class getType() { + return Object.class; + } + }; + + private final JPQLTemplates customTemplates = + new HQLTemplates() { + { + add(customOperator, "sign({0})"); + } + }; + + protected JPAQuery query() { + return new JPAQuery(entityManager); + } + + protected JPAQuery query(JPQLTemplates templates) { + return new JPAQuery(entityManager, templates); + } + + @Override + public void setEntityManager(EntityManager entityManager) { + this.entityManager = entityManager; + } + + @Test + public void test() { + var cat = QCat.cat; + JPAQuery query = query().from(cat); + + query.fetchCount(); + query.distinct().fetchCount(); + + query.select(cat).iterate(); + query.select(cat, cat).iterate(); + query.distinct().select(cat).iterate(); + query.distinct().select(cat, cat).iterate(); + + query.select(cat).fetch(); + query.select(cat, cat).fetch(); + query.distinct().select(cat).fetch(); + query.distinct().select(cat, cat).fetch(); + + query.select(cat).fetchResults(); + query.distinct().select(cat).fetchResults(); + } + + @Test + public void clone_() { + var cat = QCat.cat; + JPAQuery query = query().from(cat).where(cat.name.isNotNull()); + JPAQuery query2 = query.clone(entityManager); + assertThat(query2.getMetadata().getJoins()).isEqualTo(query.getMetadata().getJoins()); + assertThat(query2.getMetadata().getWhere()).isEqualTo(query.getMetadata().getWhere()); + query2.select(cat).fetch(); + } + + @Test + public void clone_custom_templates() { + var cat = QCat.cat; + JPAQuery query = query().from(cat); + // attach using the custom templates + query + .clone(entityManager, customTemplates) + .select(numberOperation(Integer.class, customOperator, cat.floatProperty)) + .fetchOne(); + } + + @Test + public void clone_keep_templates() { + var cat = QCat.cat; + JPAQuery query = query(customTemplates).from(cat); + // keep the original templates + query + .clone() + .select(numberOperation(Integer.class, customOperator, cat.floatProperty)) + .fetchOne(); + } + + @Test(expected = IllegalArgumentException.class) + public void clone_lose_templates() { + var cat = QCat.cat; + JPAQuery query = query(customTemplates).from(cat); + // clone using the entitymanager's default templates + query + .clone(entityManager) + .select(numberOperation(Integer.class, customOperator, cat.floatProperty)) + .fetchOne(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAQueryMutabilityTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAQueryMutabilityTest.java new file mode 100644 index 0000000000..4debde362e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPAQueryMutabilityTest.java @@ -0,0 +1,74 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.QueryMutability; +import com.querydsl.jpa.domain.Cat; +import com.querydsl.jpa.domain.sql.SAnimal_; +import com.querydsl.jpa.sql.JPASQLQuery; +import com.querydsl.jpa.testutil.JPATestRunner; +import com.querydsl.sql.DerbyTemplates; +import com.querydsl.sql.SQLTemplates; +import jakarta.persistence.EntityManager; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; + +@Ignore +@RunWith(JPATestRunner.class) +public class JPAQueryMutabilityTest implements JPATest { + + private static final SQLTemplates derbyTemplates = new DerbyTemplates(); + + private EntityManager entityManager; + + protected JPASQLQuery query() { + return new JPASQLQuery(entityManager, derbyTemplates); + } + + @Override + public void setEntityManager(EntityManager entityManager) { + this.entityManager = entityManager; + } + + @Test + public void test() + throws SecurityException, + IllegalArgumentException, + NoSuchMethodException, + IllegalAccessException, + InvocationTargetException, + IOException { + entityManager.persist(new Cat("Beck", 1)); + entityManager.flush(); + + var cat = new SAnimal_("cat"); + JPASQLQuery query = query().from(cat); + new QueryMutability(query).test(cat.id, cat.name); + } + + @Test + public void clone_() { + var cat = new SAnimal_("cat"); + JPASQLQuery query = query().from(cat).where(cat.name.isNotNull()); + JPASQLQuery query2 = query.clone(entityManager); + assertThat(query2.getMetadata().getJoins()).isEqualTo(query.getMetadata().getJoins()); + assertThat(query2.getMetadata().getWhere()).isEqualTo(query.getMetadata().getWhere()); + query2.select(cat.id).fetch(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPASQLBase.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPASQLBase.java new file mode 100644 index 0000000000..555eb3e518 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPASQLBase.java @@ -0,0 +1,153 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.ExcludeIn; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.Projections; +import com.querydsl.jpa.domain.Cat; +import com.querydsl.jpa.domain.Color; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.domain.sql.SAnimal_; +import com.querydsl.jpa.sql.JPASQLQuery; +import com.querydsl.jpa.testutil.JPATestRunner; +import com.querydsl.sql.SQLTemplates; +import jakarta.persistence.EntityManager; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestRule; +import org.junit.runner.RunWith; + +@RunWith(JPATestRunner.class) +public class JPASQLBase extends AbstractSQLTest implements JPATest { + + @Rule @ClassRule public static TestRule targetRule = new TargetRule(); + + @Rule @ClassRule public static TestRule hibernateOnly = new JPAProviderRule(); + + private final SQLTemplates templates = Mode.getSQLTemplates(); + + private EntityManager entityManager; + + private final SAnimal_ cat = new SAnimal_("cat"); + private final QCat catEntity = QCat.cat; + + @Override + protected JPASQLQuery query() { + return new JPASQLQuery(entityManager, templates); + } + + @Override + public void setEntityManager(EntityManager entityManager) { + this.entityManager = entityManager; + } + + @Before + public void setUp() { + if (query().from(cat).fetchCount() == 0) { + entityManager.persist(new Cat("Beck", 1, Color.BLACK)); + entityManager.persist(new Cat("Kate", 2, Color.BLACK)); + entityManager.persist(new Cat("Kitty", 3, Color.BLACK)); + entityManager.persist(new Cat("Bobby", 4, Color.BLACK)); + entityManager.persist(new Cat("Harold", 5, Color.BLACK)); + entityManager.persist(new Cat("Tim", 6, Color.BLACK)); + entityManager.flush(); + } + } + + private void insertEntitiesForTest(final List entities) { + for (T entity : entities) { + entityManager.persist(entity); + } + entityManager.flush(); + } + + private void removeEntitiesForTest(final List entities) { + for (T entity : entities) { + entityManager.remove(entity); + } + entityManager.flush(); + } + + @Test + public void entityQueries_createQuery() { + var query = query().from(cat).select(catEntity).createQuery(); + assertThat(query.getResultList()).hasSize(6); + } + + @Test + @ExcludeIn(Target.MYSQL) + public void entityQueries_createQuery2() { + var cat = new SAnimal_("CAT"); + + var query = query().from(cat).select(catEntity).createQuery(); + assertThat(query.getResultList()).hasSize(6); + } + + @Test + public void should_fetch_results_with_factory_expression() { + final var expectedTotalResultCount = 6L; + final var bindings = new HashMap>(); + bindings.put("name", cat.name); + + final var actualTotalResultCount = + query().from(cat).select(Projections.bean(Cat.class, bindings)).fetchResults().getTotal(); + + assertThat(actualTotalResultCount).isEqualTo(expectedTotalResultCount); + } + + @Test + public void should_get_grouped_list_by_using_fetch_results() { + final var expectedCatColorKindCount = 1L; + + final var actualCatColorKindCount = + query() + .from(cat) + .select(catEntity.color) + .groupBy(catEntity.color) + .fetchResults() + .getTotal(); + + assertThat(actualCatColorKindCount).isEqualTo(expectedCatColorKindCount); + } + + @Test + public void should_get_black_cat_count_by_using_group_by_and_having() { + final var expectedTabbyCatCount = 2L; + final var tabbyColorCatFoo = new Cat("Foo", 7, Color.TABBY); + final var tabbyColorCatBar = new Cat("Bar", 8, Color.TABBY); + + insertEntitiesForTest(Arrays.asList(tabbyColorCatFoo, tabbyColorCatBar)); + + final long actualTabbyCatCount = + query() + .from(cat) + .select(catEntity.name.count()) + .groupBy(catEntity.color) + .having(catEntity.name.count().eq(2L)) + .fetchOne(); + + removeEntitiesForTest(Arrays.asList(tabbyColorCatFoo, tabbyColorCatBar)); + + assertThat(actualTabbyCatCount).isEqualTo(expectedTabbyCatCount); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPATest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPATest.java new file mode 100644 index 0000000000..3d28c73fcc --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPATest.java @@ -0,0 +1,26 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import jakarta.persistence.EntityManager; + +/** + * @author Shredder121 + */ +public interface JPATest { + + void setEntityManager(EntityManager entityManager); +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPQLQueryTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPQLQueryTest.java new file mode 100644 index 0000000000..707d979175 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPQLQueryTest.java @@ -0,0 +1,75 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.hibernate.HibernateQuery; +import com.querydsl.jpa.impl.JPAQuery; +import org.junit.Before; +import org.junit.Test; + +public class JPQLQueryTest { + + private QCat cat = QCat.cat; + + private HibernateQuery query = new HibernateQuery(); + + @Before + public void setUp() { + query.from(cat); + } + + @Test(expected = IllegalArgumentException.class) + public void innerJoinPEntityOfPPEntityOfP() { + query.innerJoin(cat.mate, cat.mate); + } + + @Test(expected = IllegalArgumentException.class) + public void innerJoinPathOfQextendsCollectionOfPPathOfP() { + query.innerJoin(cat.kittens, cat.mate); + } + + @Test(expected = IllegalArgumentException.class) + public void joinPEntityOfPPEntityOfP() { + query.join(cat.mate, cat.mate); + } + + @Test(expected = IllegalArgumentException.class) + public void joinPathOfQextendsCollectionOfPPathOfP() { + query.join(cat.kittens, cat.mate); + } + + @Test(expected = IllegalArgumentException.class) + public void leftJoinPEntityOfPPEntityOfP() { + query.leftJoin(cat.mate, cat.mate); + } + + @Test(expected = IllegalArgumentException.class) + public void leftJoinPathOfQextendsCollectionOfPPathOfP() { + query.leftJoin(cat.kittens, cat.mate); + } + + @Test + public void toString_() { + assertThat(new HibernateQuery().toString()).isEmpty(); + assertThat(new JPAQuery().toString()).isEmpty(); + assertThat(new HibernateQuery().select(cat)).hasToString("select cat"); + assertThat(new JPAQuery().select(cat)).hasToString("select cat"); + assertThat(new HibernateQuery().from(cat).toString()) + .isEqualTo("select cat\nfrom Cat cat"); + assertThat(new JPAQuery().from(cat)).hasToString("select cat\nfrom Cat cat"); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPQLSerializerTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPQLSerializerTest.java new file mode 100644 index 0000000000..bf9a715463 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPQLSerializerTest.java @@ -0,0 +1,362 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.JPAExpressions.selectOne; +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.DefaultQueryMetadata; +import com.querydsl.core.JoinType; +import com.querydsl.core.QueryMetadata; +import com.querydsl.core.domain.QAnimal; +import com.querydsl.core.domain.QCat; +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.dsl.EntityPathBase; +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.jpa.domain.JobFunction; +import com.querydsl.jpa.domain.Location; +import com.querydsl.jpa.domain.QDomesticCat; +import com.querydsl.jpa.domain.QEmployee; +import java.util.Arrays; +import org.junit.Test; + +public class JPQLSerializerTest { + + @Test + public void and_or() { + // A.a.id.eq(theId).and(B.b.on.eq(false).or(B.b.id.eq(otherId))); + var cat = QCat.cat; + Predicate pred = cat.id.eq(1).and(cat.name.eq("Kitty").or(cat.name.eq("Boris"))); + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + serializer.handle(pred); + assertThat(serializer).hasToString("cat.id = ?1 and (cat.name = ?2 or cat.name = ?3)"); + assertThat(pred).hasToString("cat.id = 1 && (cat.name = Kitty || cat.name = Boris)"); + } + + @Test + public void case1() { + var cat = QCat.cat; + var serializer = new JPQLSerializer(JPQLTemplates.DEFAULT); + Expression expr = + Expressions.cases().when(cat.toes.eq(2)).then(2).when(cat.toes.eq(3)).then(3).otherwise(4); + serializer.handle(expr); + assertThat(serializer.toString()) + .isEqualTo("case when (cat.toes = ?1) then ?2 when (cat.toes = ?3) then ?4 else ?5 end"); + } + + @Test + public void case1_hibernate() { + var cat = QCat.cat; + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + Expression expr = + Expressions.cases().when(cat.toes.eq(2)).then(2).when(cat.toes.eq(3)).then(3).otherwise(4); + serializer.handle(expr); + assertThat(serializer.toString()) + .isEqualTo("case when (cat.toes = ?1) then ?2 when (cat.toes = ?3) then ?4 else 4 end"); + } + + @Test + public void case2() { + var cat = QCat.cat; + var serializer = new JPQLSerializer(JPQLTemplates.DEFAULT); + Expression expr = + Expressions.cases() + .when(cat.toes.eq(2)) + .then(cat.id.multiply(2)) + .when(cat.toes.eq(3)) + .then(cat.id.multiply(3)) + .otherwise(4); + serializer.handle(expr); + assertThat(serializer.toString()) + .isEqualTo( + """ + case when (cat.toes = ?1) then (cat.id * ?2) when (cat.toes = ?3) then (cat.id * ?4)\ + else ?5 end\ + """); + } + + @Test + public void case2_hibernate() { + var cat = QCat.cat; + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + Expression expr = + Expressions.cases() + .when(cat.toes.eq(2)) + .then(cat.id.multiply(2)) + .when(cat.toes.eq(3)) + .then(cat.id.multiply(3)) + .otherwise(4); + serializer.handle(expr); + assertThat(serializer.toString()) + .isEqualTo( + """ + case when (cat.toes = ?1) then (cat.id * ?2) when (cat.toes = ?3) then (cat.id * ?4)\ + else 4 end\ + """); + } + + @Test + public void count() { + var cat = QCat.cat; + QueryMetadata md = new DefaultQueryMetadata(); + md.addJoin(JoinType.DEFAULT, cat); + md.setProjection(cat.mate.countDistinct()); + var serializer1 = new JPQLSerializer(HQLTemplates.DEFAULT); + serializer1.serialize(md, true, null); + assertThat(serializer1.toString()) + .isEqualTo("select count(count(distinct cat.mate))\n" + "from Cat cat"); + + var serializer2 = new JPQLSerializer(HQLTemplates.DEFAULT); + serializer2.serialize(md, false, null); + assertThat(serializer2.toString()) + .isEqualTo("select count(distinct cat.mate)\n" + "from Cat cat"); + } + + @Test + public void fromWithCustomEntityName() { + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + EntityPath entityPath = new EntityPathBase<>(Location.class, "entity"); + QueryMetadata md = new DefaultQueryMetadata(); + md.addJoin(JoinType.DEFAULT, entityPath); + serializer.serialize(md, false, null); + assertThat(serializer).hasToString("select entity\nfrom Location2 entity"); + } + + @Test + public void join_with() { + var cat = QCat.cat; + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + QueryMetadata md = new DefaultQueryMetadata(); + md.addJoin(JoinType.DEFAULT, cat); + md.addJoin(JoinType.INNERJOIN, cat.mate); + md.addJoinCondition(cat.mate.alive); + serializer.serialize(md, false, null); + assertThat(serializer.toString()) + .isEqualTo("select cat\nfrom Cat cat\n inner join cat.mate with cat.mate.alive"); + } + + @Test + public void normalizeNumericArgs() { + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + NumberPath doublePath = Expressions.numberPath(Double.class, "doublePath"); + serializer.handle(doublePath.add(1)); + serializer.handle(doublePath.between((float) 1.0, 1L)); + serializer.handle(doublePath.lt((byte) 1)); + for (Object constant : serializer.getConstants()) { + assertThat(constant.getClass()).isEqualTo(Double.class); + } + } + + @Test + public void delete_clause_uses_dELETE_fROM() { + var employee = QEmployee.employee; + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + QueryMetadata md = new DefaultQueryMetadata(); + md.addJoin(JoinType.DEFAULT, employee); + md.addWhere(employee.lastName.isNull()); + serializer.serializeForDelete(md); + assertThat(serializer.toString()) + .isEqualTo("delete from Employee employee\nwhere employee.lastName is null"); + } + + @Test + public void delete_with_subQuery() { + var parent = QCat.cat; + var child = new QCat("kitten"); + + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + QueryMetadata md = new DefaultQueryMetadata(); + md.addJoin(JoinType.DEFAULT, child); + md.addWhere( + child + .id + .eq(1) + .and( + selectOne() + .from(parent) + .where(parent.id.eq(2), child.in(parent.kittens)) + .exists())); + serializer.serializeForDelete(md); + assertThat(serializer.toString()) + .isEqualTo( + """ + delete from Cat kitten + where kitten.id = ?1 and exists (select 1 + from Cat cat + where cat.id = ?2 and kitten member of cat.kittens)\ + """); + } + + @Test + public void in() { + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + serializer.handle(Expressions.numberPath(Integer.class, "id").in(Arrays.asList(1, 2))); + assertThat(serializer).hasToString("id in (?1)"); + } + + @Test + public void not_in() { + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + serializer.handle(Expressions.numberPath(Integer.class, "id").notIn(Arrays.asList(1, 2))); + assertThat(serializer).hasToString("id not in (?1)"); + } + + @Test + public void like() { + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + serializer.handle(Expressions.stringPath("str").contains("abc!")); + assertThat(serializer).hasToString("str like ?1 escape '!'"); + assertThat(serializer.getConstants().get(0)).hasToString("%abc!!%"); + } + + @Test + public void stringContainsIc() { + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + serializer.handle(Expressions.stringPath("str").containsIgnoreCase("ABc!")); + assertThat(serializer).hasToString("lower(str) like ?1 escape '!'"); + assertThat(serializer.getConstants().get(0)).hasToString("%abc!!%"); + } + + @Test + public void substring() { + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + var cat = QCat.cat; + serializer.handle(cat.name.substring(cat.name.length().subtract(1), 1)); + assertThat(serializer.toString()) + .isEqualTo("substring(cat.name,length(cat.name) + ?1,?2 - (length(cat.name) - ?3))"); + } + + @Test + public void nullsFirst() { + var cat = QCat.cat; + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + QueryMetadata md = new DefaultQueryMetadata(); + md.addJoin(JoinType.DEFAULT, cat); + md.addOrderBy(cat.name.asc().nullsFirst()); + serializer.serialize(md, false, null); + assertThat(serializer.toString()) + .isEqualTo( + """ + select cat + from Cat cat + order by cat.name asc nulls first"""); + } + + @Test + public void nullsLast() { + var cat = QCat.cat; + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + QueryMetadata md = new DefaultQueryMetadata(); + md.addJoin(JoinType.DEFAULT, cat); + md.addOrderBy(cat.name.asc().nullsLast()); + serializer.serialize(md, false, null); + assertThat(serializer.toString()) + .isEqualTo( + """ + select cat + from Cat cat + order by cat.name asc nulls last"""); + } + + @SuppressWarnings("unchecked") + @Test + public void treat() { + var cat = QCat.cat; + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + QueryMetadata md = new DefaultQueryMetadata(); + md.addJoin(JoinType.DEFAULT, cat); + md.addJoin(JoinType.JOIN, cat.mate.as((Path) QDomesticCat.domesticCat)); + md.setProjection(QDomesticCat.domesticCat); + serializer.serialize(md, false, null); + assertThat(serializer.toString()) + .isEqualTo( + """ + select domesticCat + from Cat cat + inner join treat(cat.mate as DomesticCat) as domesticCat\ + """); + } + + @Test + public void treated_path() { + var animal = QAnimal.animal; + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + QueryMetadata md = new DefaultQueryMetadata(); + md.addJoin(JoinType.DEFAULT, animal); + + md.addWhere(JPAExpressions.treat(animal, QCat.class).breed.eq(1)); + md.setProjection(animal); + serializer.serialize(md, false, null); + assertThat(serializer.toString()) + .isEqualTo( + """ + select animal + from Animal animal + where treat(animal as Cat).breed = ?1\ + """); + } + + @Test + public void openJPA_variables() { + var cat = QCat.cat; + var serializer = new JPQLSerializer(OpenJPATemplates.DEFAULT); + QueryMetadata md = new DefaultQueryMetadata(); + md.addJoin(JoinType.DEFAULT, cat); + md.addJoin(JoinType.INNERJOIN, cat.mate); + md.addJoinCondition(cat.mate.alive); + serializer.serialize(md, false, null); + assertThat(serializer.toString()) + .isEqualTo("select cat_\nfrom Cat cat_\n inner join cat_.mate on cat_.mate.alive"); + } + + @Test + public void visitLiteral_boolean() { + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + serializer.visitLiteral(Boolean.TRUE); + assertThat(serializer).hasToString("true"); + } + + @Test + public void visitLiteral_number() { + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + serializer.visitLiteral(1.543); + assertThat(serializer).hasToString("1.543"); + } + + @Test + public void visitLiteral_string() { + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + serializer.visitLiteral("abc''def"); + assertThat(serializer).hasToString("'abc''''def'"); + } + + @Test + public void visitLiteral_enum() { + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + serializer.visitLiteral(JobFunction.MANAGER); + assertThat(serializer).hasToString("com.querydsl.jpa.domain.JobFunction.MANAGER"); + } + + @Test + public void substring_indexOf() { + var cat = QCat.cat; + var serializer = new JPQLSerializer(HQLTemplates.DEFAULT); + cat.name.substring(cat.name.indexOf("")).accept(serializer, null); + assertThat(serializer).hasToString("substring(cat.name,locate(?1,cat.name)-1 + ?2)"); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPQLTemplatesTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPQLTemplatesTest.java new file mode 100644 index 0000000000..a403089573 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JPQLTemplatesTest.java @@ -0,0 +1,98 @@ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.types.Operator; +import com.querydsl.core.types.Ops; +import com.querydsl.core.types.Templates; +import com.querydsl.core.types.TemplatesTestUtils; +import java.util.Arrays; +import java.util.List; +import org.junit.Test; + +public class JPQLTemplatesTest { + + @Test + public void escape() { + List templates = + Arrays.asList( + new JPQLTemplates(), new HQLTemplates(), + new EclipseLinkTemplates(), new OpenJPATemplates()); + + for (Templates t : templates) { + assertThat(t.getTemplate(Ops.LIKE)).hasToString("{0} like {1} escape '!'"); + } + } + + @Test + public void custom_escape() { + List templates = + Arrays.asList( + new JPQLTemplates('X'), new HQLTemplates('X'), + new EclipseLinkTemplates('X'), new OpenJPATemplates('X')); + + for (Templates t : templates) { + assertThat(t.getTemplate(Ops.LIKE)).hasToString("{0} like {1} escape 'X'"); + } + } + + @Test + public void precedence() { + // Navigation operator (.) + // +, - unary *, + var p1 = getPrecedence(Ops.NEGATE); + // / multiplication and division + var p2 = getPrecedence(Ops.MULT, Ops.DIV); + // +, - addition and subtraction + var p3 = getPrecedence(Ops.ADD, Ops.SUB); + // Comparison operators : =, >, >=, <, <=, <> (not equal), [NOT] BETWEEN, [NOT] LIKE, [NOT] IN, + // IS [NOT] NULL, IS [NOT] EMPTY, [NOT] MEMBER [OF] + var p4 = + getPrecedence( + Ops.EQ, + Ops.GT, + Ops.GOE, + Ops.LT, + Ops.LOE, + Ops.NE, + Ops.BETWEEN, + Ops.LIKE, + Ops.LIKE_ESCAPE, + Ops.IN, + Ops.IS_NULL, + Ops.IS_NOT_NULL, + JPQLOps.MEMBER_OF, + JPQLOps.NOT_MEMBER_OF); + // NOT + var p5 = getPrecedence(Ops.NOT); + // AND + var p6 = getPrecedence(Ops.AND); + // OR + var p7 = getPrecedence(Ops.OR); + + assertThat(p1 < p2).isTrue(); + assertThat(p2 < p3).isTrue(); + assertThat(p3 < p4).isTrue(); + assertThat(p4 < p5).isTrue(); + assertThat(p5 < p6).isTrue(); + assertThat(p6 < p7).isTrue(); + } + + protected int getPrecedence(Operator... ops) { + var precedence = JPQLTemplates.DEFAULT.getPrecedence(ops[0]); + for (var i = 1; i < ops.length; i++) { + assertThat(JPQLTemplates.DEFAULT.getPrecedence(ops[i])) + .as(ops[i].name()) + .isEqualTo(precedence); + } + return precedence; + } + + @Test + public void generic_precedence() { + for (JPQLTemplates templates : + Arrays.asList(JPQLTemplates.DEFAULT, HQLTemplates.DEFAULT, EclipseLinkTemplates.DEFAULT)) { + TemplatesTestUtils.testPrecedence(templates); + } + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JoinFlagsTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JoinFlagsTest.java new file mode 100644 index 0000000000..4f5238a5ea --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JoinFlagsTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.cat; +import static com.querydsl.jpa.Constants.cat1; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +public class JoinFlagsTest extends AbstractQueryTest { + @Test + public void fetch() { + QueryHelper query = query().from(cat).innerJoin(cat.mate, cat1).fetchJoin(); + assertThat(query.toString()) + .isEqualTo("select cat\nfrom Cat cat\n inner join fetch cat.mate as cat1"); + } + + @Test + public void rightJoin() { + QueryHelper query = query().from(cat).rightJoin(cat.mate, cat1); + assertThat(query.toString()) + .isEqualTo("select cat\nfrom Cat cat\n right join cat.mate as cat1"); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JoinTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JoinTest.java new file mode 100644 index 0000000000..582e1fb742 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/JoinTest.java @@ -0,0 +1,81 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.core.alias.Alias.$; +import static com.querydsl.jpa.JPAExpressions.selectOne; + +import com.querydsl.core.alias.Alias; +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.jpa.hibernate.HibernateQuery; +import java.util.List; +import org.junit.Test; + +public class JoinTest { + + public interface Entity { + + List getNames(); + } + + private final Entity alias = Alias.alias(Entity.class); + + private final StringPath path = Expressions.stringPath("path"); + private final JPQLSubQuery subQuery = selectOne(); + private final HibernateQuery query = + new HibernateQuery(new DummySessionHolder(), HQLTemplates.DEFAULT); + + @Test + public void subQuery_innerJoin() { + subQuery.from($(alias)); + subQuery.innerJoin($(alias.getNames()), path); + // TODO : assertions + } + + @Test + public void subQuery_join() { + subQuery.from($(alias)); + subQuery.join($(alias.getNames()), path); + // TODO : assertions + } + + @Test + public void subQuery_leftJoin() { + subQuery.from($(alias)); + subQuery.leftJoin($(alias.getNames()), path); + // TODO : assertions + } + + @Test + public void query_innerJoin() { + query.from($(alias)); + query.innerJoin($(alias.getNames()), path); + // TODO : assertions + } + + @Test + public void query_join() { + query.from($(alias)); + query.join($(alias.getNames()), path); + // TODO : assertions + } + + @Test + public void query_leftJoin() { + query.from($(alias)); + query.leftJoin($(alias.getNames()), path); + // TODO : assertions + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/MapOperationsTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/MapOperationsTest.java new file mode 100644 index 0000000000..45642cf222 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/MapOperationsTest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.show; +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.jpa.impl.JPAQuery; +import org.junit.Test; + +public class MapOperationsTest extends AbstractQueryTest { + + @Test + public void map_with_groupBy() { + assertThat( + new JPAQuery() + .from(show) + .select(show.acts.get("A")) + .groupBy(show.acts.get("A")) + .toString()) + .isEqualTo( + """ + select show_acts_0 + from Show show + left join show.acts as show_acts_0 on key(show_acts_0) = ?1 + group by show_acts_0\ + """); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/MathTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/MathTest.java new file mode 100644 index 0000000000..2d993fc8f4 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/MathTest.java @@ -0,0 +1,110 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.cat; +import static com.querydsl.jpa.Constants.kitten; + +import com.querydsl.jpa.domain.QCat; +import org.junit.Test; + +public class MathTest extends AbstractQueryTest { + + @Test + public void test() { + var path = QCat.cat.bodyWeight; + assertToString( + "(cat.bodyWeight - sum(cat.bodyWeight)) * cat.bodyWeight", + path.subtract(path.sumDouble()).multiply(path)); + } + + @Test + public void add() { + assertToString("cat.bodyWeight + ?1", cat.bodyWeight.add(10)); + } + + @Test + public void subtract() { + assertToString("cat.bodyWeight - ?1", cat.bodyWeight.subtract(10)); + } + + @Test + public void multiply() { + assertToString("cat.bodyWeight * ?1", cat.bodyWeight.multiply(10)); + } + + @Test + public void divide() { + assertToString("cat.bodyWeight / ?1", cat.bodyWeight.divide(10)); + } + + @Test + public void add_and_compare() { + assertToString("cat.bodyWeight + ?1 < ?2", cat.bodyWeight.add(10.0).lt(10.0)); + } + + @Test + public void subtract_and_compare() { + assertToString("cat.bodyWeight - ?1 < ?2", cat.bodyWeight.subtract(10.0).lt(10.0)); + } + + @Test + public void multiply_and_compare() { + assertToString("cat.bodyWeight * ?1 < ?2", cat.bodyWeight.multiply(10.0).lt(10.0)); + } + + @Test + public void divide_and_compare() { + assertToString("cat.bodyWeight / ?1 < ?2", cat.bodyWeight.divide(10.0).lt(20.0)); + } + + @Test + public void add_and_multiply() { + assertToString("(cat.bodyWeight + ?1) * ?2", cat.bodyWeight.add(10).multiply(20)); + } + + @Test + public void subtract_and_multiply() { + assertToString("(cat.bodyWeight - ?1) * ?2", cat.bodyWeight.subtract(10).multiply(20)); + } + + @Test + public void multiply_and_add() { + assertToString("cat.bodyWeight * ?1 + ?2", cat.bodyWeight.multiply(10).add(20)); + } + + @Test + public void multiply_and_subtract() { + assertToString("cat.bodyWeight * ?1 - ?2", cat.bodyWeight.multiply(10).subtract(20)); + } + + @Test + public void arithmetic_and_arithmetic2() { + var c1 = new QCat("c1"); + var c2 = new QCat("c2"); + var c3 = new QCat("c3"); + assertToString("c1.id + c2.id * c3.id", c1.id.add(c2.id.multiply(c3.id))); + assertToString("c1.id * (c2.id + c3.id)", c1.id.multiply(c2.id.add(c3.id))); + assertToString("(c1.id + c2.id) * c3.id", c1.id.add(c2.id).multiply(c3.id)); + } + + @Test + public void mathematicalOperations() { + // mathematical operators +, -, *, / + cat.bodyWeight.add(kitten.bodyWeight); + cat.bodyWeight.subtract(kitten.bodyWeight); + cat.bodyWeight.multiply(kitten.bodyWeight); + cat.bodyWeight.divide(kitten.bodyWeight); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Mode.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Mode.java new file mode 100644 index 0000000000..38053a2832 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Mode.java @@ -0,0 +1,52 @@ +package com.querydsl.jpa; + +import com.querydsl.core.Target; +import com.querydsl.sql.CUBRIDTemplates; +import com.querydsl.sql.DerbyTemplates; +import com.querydsl.sql.H2Templates; +import com.querydsl.sql.HSQLDBTemplates; +import com.querydsl.sql.MySQLTemplates; +import com.querydsl.sql.OracleTemplates; +import com.querydsl.sql.PostgreSQLTemplates; +import com.querydsl.sql.SQLServer2008Templates; +import com.querydsl.sql.SQLTemplates; +import com.querydsl.sql.SQLiteTemplates; +import com.querydsl.sql.TeradataTemplates; + +/** + * @author tiwe + */ +public final class Mode { + + public static final ThreadLocal mode = new ThreadLocal<>(); + + public static final ThreadLocal target = new ThreadLocal<>(); + + public static SQLTemplates getSQLTemplates() { + switch (target.get()) { + case CUBRID: + return new CUBRIDTemplates(); + case DERBY: + return new DerbyTemplates(); + case H2: + return new H2Templates(); + case HSQLDB: + return new HSQLDBTemplates(); + case SQLSERVER: + return new SQLServer2008Templates(); + case MYSQL: + return new MySQLTemplates(); + case ORACLE: + return new OracleTemplates(); + case POSTGRESQL: + return new PostgreSQLTemplates(); + case SQLITE: + return new SQLiteTemplates(); + case TERADATA: + return new TeradataTemplates(); + } + throw new IllegalStateException("Unknown mode " + mode); + } + + private Mode() {} +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/NativeSQLSerializerTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/NativeSQLSerializerTest.java new file mode 100644 index 0000000000..3fa2c425e1 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/NativeSQLSerializerTest.java @@ -0,0 +1,72 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.DefaultQueryMetadata; +import com.querydsl.core.JoinType; +import com.querydsl.core.types.dsl.PathBuilder; +import com.querydsl.jpa.domain.sql.SAnimal_; +import com.querydsl.sql.Configuration; +import com.querydsl.sql.MySQLTemplates; +import jakarta.persistence.Column; +import org.junit.Test; + +public class NativeSQLSerializerTest { + + public static class Entity { + @Column private String name; + + @Column(name = "first_name") + private String firstName; + } + + @Test + public void in() { + var conf = new Configuration(new MySQLTemplates()); + var serializer = new NativeSQLSerializer(conf, true); + var md = new DefaultQueryMetadata(); + var cat = SAnimal_.animal_; + md.addJoin(JoinType.DEFAULT, cat); + md.addWhere(cat.name.in("X", "Y")); + md.setProjection(cat.id); + serializer.serialize(md, false); + assertThat(serializer.toString()) + .isEqualTo( + """ + select animal_.ID + from animal_ animal_ + where animal_.NAME in (?1, ?2)\ + """); + } + + @Test + public void path_column() { + var entity = new PathBuilder<>(Entity.class, "entity"); + var conf = new Configuration(new MySQLTemplates()); + var serializer = new NativeSQLSerializer(conf, true); + serializer.handle(entity.get("name")); + assertThat(serializer).hasToString("entity.name"); + } + + @Test + public void path_column2() { + var entity = new PathBuilder<>(Entity.class, "entity"); + var conf = new Configuration(new MySQLTemplates()); + var serializer = new NativeSQLSerializer(conf, true); + serializer.handle(entity.get("firstName")); + assertThat(serializer).hasToString("entity.first_name"); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/NoBatooJPA.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/NoBatooJPA.java new file mode 100644 index 0000000000..31a0c4f765 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/NoBatooJPA.java @@ -0,0 +1,15 @@ +package com.querydsl.jpa; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.TYPE}) +@Inherited +public @interface NoBatooJPA { + + com.querydsl.core.Target[] value() default {}; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/NoEclipseLink.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/NoEclipseLink.java new file mode 100644 index 0000000000..5705f97cc3 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/NoEclipseLink.java @@ -0,0 +1,15 @@ +package com.querydsl.jpa; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.TYPE}) +@Inherited +public @interface NoEclipseLink { + + com.querydsl.core.Target[] value() default {}; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/NoHibernate.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/NoHibernate.java new file mode 100644 index 0000000000..71ffbc2f2c --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/NoHibernate.java @@ -0,0 +1,15 @@ +package com.querydsl.jpa; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.TYPE}) +@Inherited +public @interface NoHibernate { + + com.querydsl.core.Target[] value() default {}; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/NoOpenJPA.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/NoOpenJPA.java new file mode 100644 index 0000000000..bfcb8cc4ab --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/NoOpenJPA.java @@ -0,0 +1,15 @@ +package com.querydsl.jpa; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.TYPE}) +@Inherited +public @interface NoOpenJPA { + + com.querydsl.core.Target[] value() default {}; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/OrderExpressionsTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/OrderExpressionsTest.java new file mode 100644 index 0000000000..5959d2d27e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/OrderExpressionsTest.java @@ -0,0 +1,28 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.cat; +import static com.querydsl.jpa.Constants.kitten; + +import org.junit.Test; + +public class OrderExpressionsTest extends AbstractQueryTest { + + @Test + public void orderExpressionInFunctionalWay() { + cat.bodyWeight.asc(); + cat.bodyWeight.add(kitten.bodyWeight).asc(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/OrderHelper.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/OrderHelper.java new file mode 100644 index 0000000000..670650beb1 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/OrderHelper.java @@ -0,0 +1,99 @@ +package com.querydsl.jpa; + +import com.querydsl.core.types.EntityPath; +import com.querydsl.core.types.dsl.PathBuilder; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; +import org.apache.commons.lang.StringUtils; + +public final class OrderHelper { + + private OrderHelper() {} + + private static final Pattern DOT = Pattern.compile("\\."); + + @SuppressWarnings("unchecked") + public static PathBuilder join( + JPQLQuery query, PathBuilder builder, Map> joins, String path) { + PathBuilder rv = joins.get(path); + if (rv == null) { + if (path.contains(".")) { + var tokens = DOT.split(path); + var parent = new String[tokens.length - 1]; + System.arraycopy(tokens, 0, parent, 0, tokens.length - 1); + var parentKey = StringUtils.join(parent, "."); + builder = join(query, builder, joins, parentKey); + rv = new PathBuilder(Object.class, StringUtils.join(tokens, "_")); + query.leftJoin((EntityPath) builder.get(tokens[tokens.length - 1]), rv); + } else { + rv = new PathBuilder(Object.class, path); + query.leftJoin((EntityPath) builder.get(path), rv); + } + joins.put(path, rv); + } + return rv; + } + + @SuppressWarnings("unchecked") + public static PathBuilder join( + JPQLSubQuery query, + PathBuilder builder, + Map> joins, + String path) { + PathBuilder rv = joins.get(path); + if (rv == null) { + if (path.contains(".")) { + var tokens = DOT.split(path); + var parent = new String[tokens.length - 1]; + System.arraycopy(tokens, 0, parent, 0, tokens.length - 1); + var parentKey = StringUtils.join(parent, "."); + builder = join(query, builder, joins, parentKey); + rv = new PathBuilder(Object.class, StringUtils.join(tokens, "_")); + query.leftJoin((EntityPath) builder.get(tokens[tokens.length - 1]), rv); + } else { + rv = new PathBuilder(Object.class, path); + query.leftJoin((EntityPath) builder.get(path), rv); + } + joins.put(path, rv); + } + return rv; + } + + @SuppressWarnings("unchecked") + public static void orderBy(JPQLQuery query, EntityPath entity, List order) { + PathBuilder builder = new PathBuilder(entity.getType(), entity.getMetadata()); + Map> joins = new HashMap<>(); + + for (String entry : order) { + var tokens = DOT.split(entry); + if (tokens.length > 1) { + var parent = new String[tokens.length - 1]; + System.arraycopy(tokens, 0, parent, 0, tokens.length - 1); + PathBuilder parentAlias = join(query, builder, joins, StringUtils.join(parent, ".")); + query.orderBy(parentAlias.getString(tokens[tokens.length - 1]).asc()); + } else { + query.orderBy(builder.getString(tokens[0]).asc()); + } + } + } + + @SuppressWarnings("unchecked") + public static void orderBy(JPQLSubQuery query, EntityPath entity, List order) { + PathBuilder builder = new PathBuilder(entity.getType(), entity.getMetadata()); + Map> joins = new HashMap<>(); + + for (String entry : order) { + var tokens = DOT.split(entry); + if (tokens.length > 1) { + var parent = new String[tokens.length - 1]; + System.arraycopy(tokens, 0, parent, 0, tokens.length - 1); + PathBuilder parentAlias = join(query, builder, joins, StringUtils.join(parent, ".")); + query.orderBy(parentAlias.getString(tokens[tokens.length - 1]).asc()); + } else { + query.orderBy(builder.getString(tokens[0]).asc()); + } + } + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/OrderHelperTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/OrderHelperTest.java new file mode 100644 index 0000000000..271297a130 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/OrderHelperTest.java @@ -0,0 +1,42 @@ +package com.querydsl.jpa; + +import static com.querydsl.jpa.JPAExpressions.select; +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.types.dsl.PathBuilder; +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; + +public class OrderHelperTest { + + @Test + public void order() { + var entity = new PathBuilder<>(Object.class, "project"); + List order = new ArrayList<>(); + order.add("customer.name"); + order.add("department.superior.name"); + order.add("customer.company.name"); + order.add("previousProject.customer.company.name"); + order.add("department.name"); + + JPQLSubQuery query = select(entity); + query.from(entity); + OrderHelper.orderBy(query, entity, order); + assertThat(query.toString()) + .isEqualTo( + """ + select project + from Object project + left join project.customer as customer + left join project.department as department + left join department.superior as department_superior + left join customer.company as customer_company + left join project.previousProject as previousProject + left join previousProject.customer as previousProject_customer + left join previousProject_customer.company as previousProject_customer_company + order by customer.name asc, department_superior.name asc, customer_company.name asc,\ + previousProject_customer_company.name asc, department.name asc\ + """); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/PackageVerification.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/PackageVerification.java new file mode 100644 index 0000000000..bf32257b63 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/PackageVerification.java @@ -0,0 +1,63 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.apt.hibernate.HibernateAnnotationProcessor; +import com.querydsl.apt.jpa.JPAAnnotationProcessor; +import com.querydsl.codegen.CodegenModule; +import com.querydsl.codegen.utils.CodeWriter; +import com.querydsl.core.types.Expression; +import jakarta.persistence.Entity; +import java.io.File; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Scanner; +import org.junit.Test; + +public class PackageVerification { + + @Test + public void verify_package() throws Exception { + var version = System.getProperty("version"); + verify(new File("target/querydsl-jpa-" + version + "-apt-hibernate-one-jar.jar"), true); + verify(new File("target/querydsl-jpa-" + version + "-apt-one-jar.jar"), false); + } + + private void verify(File oneJar, boolean hibernateDeps) throws Exception { + assertThat(oneJar.exists()).as(oneJar.getPath() + " doesn't exist").isTrue(); + // verify classLoader + var oneJarClassLoader = new URLClassLoader(new URL[] {oneJar.toURI().toURL()}); + oneJarClassLoader.loadClass(Expression.class.getName()); // querydsl-core + oneJarClassLoader.loadClass(CodeWriter.class.getName()); // codegen + oneJarClassLoader + .loadClass(CodegenModule.class.getName()) + .getDeclaredConstructor() + .newInstance(); + oneJarClassLoader.loadClass(Entity.class.getName()); // jpa + Class processor; + if (hibernateDeps) { + oneJarClassLoader.loadClass(org.hibernate.annotations.Type.class.getName()); // hibernate + processor = HibernateAnnotationProcessor.class; + } else { + processor = JPAAnnotationProcessor.class; + } + Class cl = oneJarClassLoader.loadClass(processor.getName()); // querydsl-apt + cl.getDeclaredConstructor().newInstance(); + var resourceKey = "META-INF/services/javax.annotation.processing.Processor"; + assertThat(new Scanner(oneJarClassLoader.findResource(resourceKey).openStream()).nextLine()) + .isEqualTo(processor.getName()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/ParsingTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/ParsingTest.java new file mode 100644 index 0000000000..8bd2e63c2d --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/ParsingTest.java @@ -0,0 +1,781 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.core.Target.DERBY; +import static com.querydsl.core.Target.H2; +import static com.querydsl.core.Target.HSQLDB; +import static com.querydsl.core.Target.MYSQL; +import static com.querydsl.core.Target.ORACLE; +import static com.querydsl.core.Target.POSTGRESQL; +import static com.querydsl.core.Target.SQLSERVER; +import static com.querydsl.core.alias.Alias.$; +import static com.querydsl.core.alias.Alias.alias; +import static com.querydsl.jpa.Constants.account; +import static com.querydsl.jpa.Constants.an; +import static com.querydsl.jpa.Constants.bar; +import static com.querydsl.jpa.Constants.calendar; +import static com.querydsl.jpa.Constants.cat; +import static com.querydsl.jpa.Constants.catalog; +import static com.querydsl.jpa.Constants.cust; +import static com.querydsl.jpa.Constants.fatcat; +import static com.querydsl.jpa.Constants.foo; +import static com.querydsl.jpa.Constants.form; +import static com.querydsl.jpa.Constants.item; +import static com.querydsl.jpa.Constants.kit; +import static com.querydsl.jpa.Constants.kitten; +import static com.querydsl.jpa.Constants.list; +import static com.querydsl.jpa.Constants.log; +import static com.querydsl.jpa.Constants.m; +import static com.querydsl.jpa.Constants.mate; +import static com.querydsl.jpa.Constants.mother; +import static com.querydsl.jpa.Constants.n; +import static com.querydsl.jpa.Constants.name; +import static com.querydsl.jpa.Constants.offspr; +import static com.querydsl.jpa.Constants.ord; +import static com.querydsl.jpa.Constants.p; +import static com.querydsl.jpa.Constants.param; +import static com.querydsl.jpa.Constants.payment; +import static com.querydsl.jpa.Constants.person; +import static com.querydsl.jpa.Constants.price; +import static com.querydsl.jpa.Constants.prod; +import static com.querydsl.jpa.Constants.product; +import static com.querydsl.jpa.Constants.qat; +import static com.querydsl.jpa.Constants.rival; +import static com.querydsl.jpa.Constants.store; +import static com.querydsl.jpa.JPAExpressions.select; +import static com.querydsl.jpa.JPAExpressions.selectFrom; +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.testutil.ExcludeIn; +import com.querydsl.core.types.dsl.ComparableExpression; +import com.querydsl.core.types.dsl.DateExpression; +import com.querydsl.core.types.dsl.NumberExpression; +import com.querydsl.jpa.domain.Cat; +import com.querydsl.jpa.domain.Catalog; +import com.querydsl.jpa.domain.Color; +import com.querydsl.jpa.domain.Customer; +import com.querydsl.jpa.domain.DomesticCat; +import com.querydsl.jpa.domain.Payment; +import com.querydsl.jpa.domain.Product; +import com.querydsl.jpa.domain.QFamily; +import com.querydsl.jpa.domain.QFooDTO; +import com.querydsl.jpa.domain.QItem; +import com.querydsl.jpa.domain.QProduct; +import org.junit.Ignore; +import org.junit.Test; + +public class ParsingTest extends AbstractQueryTest { + + @Test + public void parseOrd() throws Exception { + query().from(ord).where(ord.paid.isTrue()).parse(); + } + + @Test + @NoEclipseLink({HSQLDB, DERBY}) + public void arrayExpr() throws Exception { + query().from(ord).where(ord.items(0).id.eq(1234L)).parse(); + } + + @Test + public void basic() { + query().from(cat, fatcat).select(cat.name, fatcat.name).parse(); + } + + @Test + @ExcludeIn(SQLSERVER) + public void beforeAndAfter() { + ComparableExpression ed = catalog.effectiveDate; + query() + .from(catalog) + .where( + ed.gt(DateExpression.currentDate()), + ed.goe(DateExpression.currentDate()), + ed.lt(DateExpression.currentDate()), + ed.loe(DateExpression.currentDate())) + .select(catalog) + .parse(); + } + + @Test + @ExcludeIn(ORACLE) + public void complexConstructor() throws Exception { + query().from(bar).select(new QFooDTO(bar.count())).parse(); + } + + @Test + public void docoExamples910() throws Exception { + query() + .from(cat) + .groupBy(cat.color) + .select(cat.color, cat.weight.sumLong(), cat.count()) + .parse(); + } + + @Test + public void docoExamples910_2() throws Exception { + query() + .from(cat) + .groupBy(cat.color) + .having(cat.color.in(Color.TABBY, Color.BLACK)) + .select(cat.color, cat.weight.sumLong(), cat.count()) + .parse(); + } + + @Test + @Ignore + public void docoExamples910_3() throws Exception { + query() + .from(cat) + .join(cat.kittens, kitten) + .groupBy(cat) + .having(kitten.weight.avg().gt(100.0)) + .orderBy(kitten.count().asc(), kitten.weight.sumLong().desc()) + .select(cat) + .parse(); + } + + @Test + public void docoExamples911() throws Exception { + query().from(fatcat).where(fatcat.weight.gt(select(cat.weight.avg()).from(cat))).parse(); + } + + @Test + public void docoExamples911_2() throws Exception { + query().from(cat).where(cat.name.eqAny(select(name.nickName).from(name))).parse(); + } + + @Test + public void docoExamples911_3() throws Exception { + query().from(cat).where(select(mate).from(mate).where(mate.mate.eq(cat)).notExists()).parse(); + } + + @Test + public void docoExamples911_4() throws Exception { + query().from(cat).where(selectFrom(mate).where(mate.mate.eq(cat)).exists()).parse(); + } + + @Test + public void docoExamples911_5() throws Exception { + query().from(cat).where(cat.name.notIn(select(name.nickName).from(name))).parse(); + } + + @Test + public void docoExamples912() throws Exception { + query() + .from(ord, cust) + .join(ord.lineItems, item) + .join(item.product, product) + .from(catalog) + .join(catalog.prices, price) + .where( + ord.paid + .not() + .and(ord.customer.eq(cust)) + .and(price.product.eq(product)) + .and(catalog.effectiveDate.gt(DateExpression.currentDate())) + .and( + catalog.effectiveDate.gtAny( + select(catalog.effectiveDate) + .from(catalog) + .where(catalog.effectiveDate.lt(DateExpression.currentDate()))))) + .groupBy(ord) + .having(price.amount.sumLong().gt(0L)) + .orderBy(price.amount.sumLong().desc()) + .select(ord.id, price.amount.sumLong(), item.count()); + + var c1 = new Customer(); + var c2 = new Catalog(); + + query() + .from(ord) + .join(ord.lineItems, item) + .join(item.product, product) + .from(catalog) + .join(catalog.prices, price) + .where( + ord.paid + .not() + .and(ord.customer.eq(c1)) + .and(price.product.eq(product)) + .and(catalog.eq(c2))) + .groupBy(ord) + .having(price.amount.sumLong().gt(0L)) + .orderBy(price.amount.sumLong().desc()) + .select(ord.id, price.amount.sumLong(), item.count()); + } + + @Test + public void docoExamples92() throws Exception { + query().from(cat).parse(); + } + + @Test + public void docoExamples92_2() throws Exception { + query().from(cat).parse(); + } + + @Test + public void docoExamples92_3() throws Exception { + query().from(form, param).parse(); + } + + @Test + public void docoExamples93() throws Exception { + query().from(cat).innerJoin(cat.mate, mate).leftJoin(cat.kittens, kitten).parse(); + } + + @Test + public void docoExamples93_2() throws Exception { + query().from(cat).leftJoin(cat.mate.kittens, kitten).parse(); + } + + @Test + public void docoExamples93_3() throws Exception { + query().from(cat).join(cat.mate, mate).leftJoin(cat.kittens, kitten).parse(); + } + + @Test + public void docoExamples93_4() throws Exception { + query().from(cat).innerJoin(cat.mate, mate).leftJoin(cat.kittens, kitten).parse(); + } + + @Test + public void docoExamples93_viaAlias() throws Exception { + var c = alias(Cat.class, "cat"); + var k = alias(Cat.class, "kittens"); + var m = alias(Cat.class, "mate"); + + query().from($(c)).innerJoin($(c.getMate()), $(m)).leftJoin($(c.getKittens()), $(k)).parse(); + } + + @Test + public void docoExamples93_viaAlias2() throws Exception { + var c = alias(Cat.class, "cat"); + var k = alias(Cat.class, "kittens"); + + query().from($(c)).leftJoin($(c.getMate().getKittens()), $(k)).parse(); + } + + @Test + public void docoExamples93_viaAlias3() throws Exception { + var c = alias(Cat.class, "cat"); + var k = alias(Cat.class, "kittens"); + var m = alias(Cat.class, "mate"); + + query().from($(c)).innerJoin($(c.getMate()), $(m)).leftJoin($(c.getKittens()), $(k)).parse(); + } + + @Test + public void docoExamples93_viaAlias4() throws Exception { + var c = alias(Cat.class, "cat"); + var k = alias(Cat.class, "kittens"); + var m = alias(Cat.class, "mate"); + + query().from($(c)).innerJoin($(c.getMate()), $(m)).leftJoin($(c.getKittens()), $(k)).parse(); + } + + @Test + public void docoExamples94() throws Exception { + query().from(cat).innerJoin(cat.mate, mate).select(cat.mate).parse(); + } + + @Test + public void docoExamples94_2() throws Exception { + query().from(cat).select(cat.mate).parse(); + } + + @Test + @NoOpenJPA + @NoBatooJPA + public void docoExamples94_3() throws Exception { + query().from(cat).select(cat.kittens).parse(); + } + + @Test + public void docoExamples94_4() throws Exception { + query().from(cust).select(cust.name.firstName).parse(); + } + + @Test + public void docoExamples94_5() throws Exception { + query() + .from(mother) + .innerJoin(mother.mate, mate) + .leftJoin(mother.kittens, offspr) + .select(mother, offspr, mate) + .parse(); + } + + @Test + public void docoExamples94_6() throws Exception { + query() + .from(mother) + .innerJoin(mother.mate, mate) + .leftJoin(mother.kittens, kitten) + .select(new QFamily(mother, mate, kitten)) + .parse(); + } + + @Test + public void docoExamples95() throws Exception { + query() + .from(cat) + .select(cat.weight.avg(), cat.weight.sumLong(), cat.weight.max(), cat.count()) + .parse(); + } + + @Test + public void docoExamples96() throws Exception { + query().from(cat).parse(); + } + + @Test + public void docoExamples96_2() throws Exception { + query().from(m, n).where(n.name.eq(m.name)).parse(); + } + + @Test + @ExcludeIn(ORACLE) + public void docoExamples97() throws Exception { + query().from(foo, bar).where(foo.startDate.eq(bar.date)).select(foo).parse(); + } + + @Test + public void docoExamples97_2() throws Exception { + query().from(cat).where(cat.mate.name.isNotNull()).parse(); + } + + @Test + public void docoExamples97_3() throws Exception { + query().from(cat, rival).where(cat.mate.eq(rival.mate)).parse(); + } + + @Test + public void docoExamples97_4() throws Exception { + query().from(cat, mate).where(cat.mate.eq(mate)).select(cat, mate).parse(); + } + + @Test + public void docoExamples97_5() throws Exception { + query().from(cat).where(cat.id.eq(123)).parse(); + } + + @Test + public void docoExamples97_6() throws Exception { + query().from(cat).where(cat.mate.id.eq(69)).parse(); + } + + @Test + public void docoExamples97_7() throws Exception { + query() + .from(person) + .where(person.pid.country.eq("AU"), person.pid.medicareNumber.eq(123456)) + .parse(); + } + + @Test + public void docoExamples97_8() throws Exception { + query().from(account).where(account.owner.pid.medicareNumber.eq(123456)).parse(); + } + + @Test + public void docoExamples97_9() throws Exception { + query().from(cat).where(cat.instanceOf(DomesticCat.class)).parse(); + } + + @Test + @Ignore + // @NoEclipseLink + public void docoExamples97_10() throws Exception { + query() + .from(log, payment) + .where(log.item.instanceOf(Payment.class), log.item.id.eq(payment.id)) + .parse(); + } + + @Test + @ExcludeIn(DERBY) + public void docoExamples97_10_2() throws Exception { + query() + .from(log, payment) + .innerJoin(log.item, item) + .where(item.instanceOf(Payment.class), item.id.eq(payment.id)) + .parse(); + } + + @Test + public void docoExamples98_1() throws Exception { + query().from(cat).where(cat.name.between("A", "B")).parse(); + } + + @Test + public void docoExamples98_2() throws Exception { + query().from(cat).where(cat.name.in("Foo", "Bar", "Baz")).parse(); + } + + @Test + public void docoExamples98_3() throws Exception { + query().from(cat).where(cat.name.notBetween("A", "B")).parse(); + } + + @Test + public void docoExamples98_4() throws Exception { + query().from(cat).where(cat.name.notIn("Foo", "Bar", "Baz")).parse(); + } + + @Test + public void docoExamples98_5() throws Exception { + query().from(cat).where(cat.kittens.size().gt(0)).parse(); + } + + @Test + public void docoExamples98_6() throws Exception { + query().from(mother, kit).select(mother).where(kit.in(mother.kittens)).parse(); + } + + @Test + @NoEclipseLink + public void docoExamples98_7() throws Exception { + query().from(list, p).select(p).where(p.name.eqAny(list.names)).parse(); + } + + @Test + public void docoExamples98_8() throws Exception { + query().from(cat).where(cat.kittens.isNotEmpty()).parse(); + } + + @Test + public void docoExamples98_9() throws Exception { + query() + .from(person, calendar) + .select(person) + .where( + calendar.holidays("national holiday").eq(person.birthDay), + person.nationality.calendar.eq(calendar)) + .parse(); + } + + @Test + @ExcludeIn({DERBY, HSQLDB, ORACLE}) + public void docoExamples98_10() throws Exception { + query() + .from(item, ord) + .select(item) + .where(ord.items(ord.deliveredItemIndices(0)).eq(item), ord.id.eq(1L)) + .parse(); + } + + @Test + @NoEclipseLink + @ExcludeIn({DERBY, HSQLDB, H2, MYSQL, ORACLE, POSTGRESQL}) + @Ignore + public void docoExamples98_11() throws Exception { + query() + .from(item, ord) + .select(item) + .where(ord.items(ord.items.size().subtract(1)).eq(item)) + .parse(); + } + + @Test + @NoEclipseLink + @NoOpenJPA + @NoBatooJPA + @ExcludeIn({DERBY, HSQLDB, ORACLE}) + public void docoExamples98_12() throws Exception { + query() + .from(prod, store) + .innerJoin(store.customers, cust) + .select(cust) + .where( + prod.name.eq("widget"), + store.location.name.in("Melbourne", "Sydney"), + prod.eqAll(cust.currentOrder.lineItems)) + .parse(); + } + + @Test + public void docoExamples98() throws Exception { + prod.eq(new Product()); + prod.eq(new QProduct("p")); + prod.eq(new QItem("p")); + } + + @Test + public void docoExamples99() throws Exception { + query().from(cat).orderBy(cat.name.asc(), cat.weight.desc(), cat.birthdate.asc()).parse(); + } + + @Test + public void doubleLiteral() throws Exception { + query().from(cat).where(cat.weight.lt((int) 3.1415)).parse(); + } + + @Test + public void doubleLiteral2() throws Exception { + query().from(cat).where(cat.weight.gt((int) 3.1415e3)).parse(); + } + + @Test + @NoOpenJPA + public void fetch() { + query().from(cat).innerJoin(cat.mate, mate).fetchJoin().parse(); + } + + @Test + @NoOpenJPA + public void fetch2() { + query().from(cat).innerJoin(cat.mate, mate).fetchJoin().fetchJoin().parse(); + } + + @Test + public void in() throws Exception { + query().from(foo).where(foo.bar.in("a", "b", "c")).parse(); + } + + @Test + public void notIn() throws Exception { + query().from(foo).where(foo.bar.notIn("a", "b", "c")).parse(); + } + + @Test + public void joins() { + query().from(cat).join(cat.mate, mate).select(cat).parse(); + } + + @Test + public void innerJoin() { + query().from(cat).innerJoin(cat.mate, mate).select(cat).parse(); + } + + @Test + public void leftJoin() { + query().from(cat).leftJoin(cat.mate, mate).select(cat).parse(); + } + + @Test + @NoOpenJPA + @NoBatooJPA + public void joins2() { + query().from(cat).join(cat.mate, mate).on(mate.name.eq("Bob")).parse(); + } + + @Test + public void multipleFromClasses() throws Exception { + query().from(qat, foo).parse(); + } + + @Test + public void serialization() { + QueryHelper query = query(); + + query.from(cat); + assertThat(query).hasToString("select cat\nfrom Cat cat"); + + query.from(fatcat); + assertThat(query).hasToString("select cat\nfrom Cat cat, Cat fatcat"); + } + + @Test + @NoEclipseLink + @NoOpenJPA + @ExcludeIn(MYSQL) + public void casts_byte() throws Exception { + NumberExpression bw = cat.bodyWeight; + query().from(cat).select(bw.byteValue()).parse(); + } + + @Test + @NoOpenJPA + public void casts_double() throws Exception { + NumberExpression bw = cat.bodyWeight; + query().from(cat).select(bw.doubleValue()).parse(); + } + + @Test + @NoOpenJPA + @ExcludeIn(MYSQL) + public void casts_float() throws Exception { + NumberExpression bw = cat.bodyWeight; + query().from(cat).select(bw.floatValue()).parse(); + } + + @Test + @NoOpenJPA + @ExcludeIn(MYSQL) + public void casts_int() throws Exception { + NumberExpression bw = cat.bodyWeight; + query().from(cat).select(bw.intValue()).parse(); + } + + @Test + @NoOpenJPA + @ExcludeIn({DERBY, HSQLDB, MYSQL}) + public void casts_long() throws Exception { + NumberExpression bw = cat.bodyWeight; + query().from(cat).select(bw.longValue()).parse(); + } + + @Test + @NoEclipseLink + @NoOpenJPA + @ExcludeIn(MYSQL) + public void casts_short() throws Exception { + NumberExpression bw = cat.bodyWeight; + query().from(cat).select(bw.shortValue()).parse(); + } + + @Test + @NoOpenJPA + @ExcludeIn({DERBY, HSQLDB, MYSQL}) + public void casts_string() throws Exception { + NumberExpression bw = cat.bodyWeight; + query().from(cat).select(bw.stringValue()).parse(); + } + + @Test + @NoEclipseLink + @NoOpenJPA + @ExcludeIn(MYSQL) + public void casts_2() throws Exception { + NumberExpression bw = cat.bodyWeight; + query().from(cat).select(bw.castToNum(Byte.class)).parse(); + } + + @Test + @Ignore + public void groupBy() throws Exception { + query().from(qat).groupBy(qat.breed).parse(); + } + + @Test + @Ignore + public void groupBy_2() throws Exception { + query().from(qat).groupBy(qat.breed, qat.eyecolor).parse(); + } + + @Test + public void not() throws Exception { + query().from(cat).where(cat.kittens.size().lt(1).not()).parse(); + } + + @Test + public void not_2() throws Exception { + query().from(cat).where(cat.kittens.size().gt(1).not()).parse(); + } + + @Test + public void not_3() throws Exception { + query().from(cat).where(cat.kittens.size().goe(1).not()).parse(); + } + + @Test + public void not_4() throws Exception { + query().from(cat).where(cat.kittens.size().loe(1).not()).parse(); + } + + @Test + public void not_5() throws Exception { + query().from(cat).where(cat.name.between("A", "B").not()).parse(); + } + + @Test + public void not_6() throws Exception { + query().from(cat).where(cat.name.notBetween("A", "B").not()).parse(); + } + + @Test + public void not_7() throws Exception { + query().from(cat).where(cat.kittens.size().loe(1).not().not()).parse(); + } + + @Test + public void not_8() throws Exception { + query().from(cat).where(cat.kittens.size().loe(1).not().not().not()).parse(); + } + + @Test + @Ignore + public void orderBy() throws Exception { + // NOT SUPPORTED + query().from(qat).orderBy(qat.toes.avg().asc()).parse(); + } + + @Test + @NoOpenJPA + public void orderBy_2() throws Exception { + query().from(an).orderBy(an.bodyWeight.sqrt().divide(2.0).asc()).parse(); + } + + @Test + public void select1() throws Exception { + // query().select(Ops.AggOps.COUNT_ALL_AGG_EXPR).from(qat).parse(); + + query().from(qat).select(qat.weight.avg()).parse(); + } + + @Test + @Ignore + public void sum() { + // NOT SUPPORTED + query().from(cat).select(cat.kittens.size().sumLong()).parse(); + } + + @Test + @Ignore + public void sum_2() { + // NOT SUPPORTED + query().from(cat).where(cat.kittens.size().sumLong().gt(0)).select(cat).parse(); + } + + @Test + public void sum_3() { + query().from(cat).where(cat.kittens.isEmpty()).select(cat).parse(); + } + + @Test + public void sum_4() { + query().from(cat).where(cat.kittens.isNotEmpty()).select(cat).parse(); + } + + @Test + public void where() throws Exception { + query().from(qat).where(qat.name.in("crater", "bean", "fluffy")).parse(); + } + + @Test + public void where_2() throws Exception { + query().from(qat).where(qat.name.notIn("crater", "bean", "fluffy")).parse(); + } + + @Test + public void where_3() throws Exception { + query().from(an).where(an.bodyWeight.sqrt().gt(10.0)).parse(); + } + + @Test + public void where_4() throws Exception { + query().from(an).where(an.bodyWeight.sqrt().divide(2d).gt(10.0)).parse(); + } + + @Test + public void where_5() throws Exception { + query() + .from(an) + .where(an.bodyWeight.gt(10), an.bodyWeight.lt(100).or(an.bodyWeight.isNull())) + .parse(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Person.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Person.java new file mode 100644 index 0000000000..ffa925693a --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Person.java @@ -0,0 +1,6 @@ +package com.querydsl.jpa; + +public class Person { + + String firstName, lastName; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Projection.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Projection.java new file mode 100644 index 0000000000..c17237ff95 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/Projection.java @@ -0,0 +1,10 @@ +package com.querydsl.jpa; + +import com.querydsl.jpa.domain.Cat; + +public class Projection { + + public Projection(String str, Cat cat) {} + + public Projection(int i, boolean b) {} +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QArticle.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QArticle.java new file mode 100644 index 0000000000..9bb191eccd --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QArticle.java @@ -0,0 +1,55 @@ +package com.querydsl.jpa; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.EntityPathBase; +import com.querydsl.core.types.dsl.PathInits; +import com.querydsl.core.types.dsl.StringPath; +import jakarta.annotation.Generated; + +/** QArticle is a Querydsl query type for Article */ +@Generated("com.querydsl.codegen.EntitySerializer") +public class QArticle extends EntityPathBase
{ + + private static final long serialVersionUID = 1732636838L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QArticle article = new QArticle("article"); + + public final QPerson author; + + public final QContent content; + + public final StringPath name = createString("name"); + + public QArticle(String variable) { + this(Article.class, forVariable(variable), INITS); + } + + public QArticle(Path path) { + this( + path.getType(), + path.getMetadata(), + path.getMetadata().isRoot() ? INITS : PathInits.DEFAULT); + } + + public QArticle(PathMetadata metadata) { + this(metadata, metadata.isRoot() ? INITS : PathInits.DEFAULT); + } + + public QArticle(PathMetadata metadata, PathInits inits) { + this(Article.class, metadata, inits); + } + + public QArticle(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.author = inits.isInitialized("author") ? new QPerson(forProperty("author")) : null; + this.content = + inits.isInitialized("content") + ? new QContent(forProperty("content"), inits.get("content")) + : null; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QContent.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QContent.java new file mode 100644 index 0000000000..7c8b5da3ca --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QContent.java @@ -0,0 +1,49 @@ +package com.querydsl.jpa; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.BeanPath; +import com.querydsl.core.types.dsl.PathInits; +import jakarta.annotation.Generated; + +/** QContent is a Querydsl query type for Content */ +@Generated("com.querydsl.codegen.EmbeddableSerializer") +public class QContent extends BeanPath { + + private static final long serialVersionUID = -878421975L; + + private static final PathInits INITS = PathInits.DIRECT2; + + public static final QContent content = new QContent("content"); + + public final QArticle article; + + public QContent(String variable) { + this(Content.class, forVariable(variable), INITS); + } + + public QContent(Path path) { + this( + path.getType(), + path.getMetadata(), + path.getMetadata().isRoot() ? INITS : PathInits.DEFAULT); + } + + public QContent(PathMetadata metadata) { + this(metadata, metadata.isRoot() ? INITS : PathInits.DEFAULT); + } + + public QContent(PathMetadata metadata, PathInits inits) { + this(Content.class, metadata, inits); + } + + public QContent(Class type, PathMetadata metadata, PathInits inits) { + super(type, metadata, inits); + this.article = + inits.isInitialized("article") + ? new QArticle(forProperty("article"), inits.get("article")) + : null; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QPerson.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QPerson.java new file mode 100644 index 0000000000..bfef7bdfcc --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QPerson.java @@ -0,0 +1,34 @@ +package com.querydsl.jpa; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.EntityPathBase; +import com.querydsl.core.types.dsl.StringPath; +import jakarta.annotation.Generated; + +/** QPerson is a Querydsl query type for Person */ +@Generated("com.querydsl.codegen.EntitySerializer") +public class QPerson extends EntityPathBase { + + private static final long serialVersionUID = -219463259L; + + public static final QPerson person = new QPerson("person"); + + public final StringPath firstName = createString("firstName"); + + public final StringPath lastName = createString("lastName"); + + public QPerson(String variable) { + super(Person.class, forVariable(variable)); + } + + public QPerson(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QPerson(PathMetadata metadata) { + super(Person.class, metadata); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QProjection.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QProjection.java new file mode 100644 index 0000000000..723a510d96 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QProjection.java @@ -0,0 +1,22 @@ +package com.querydsl.jpa; + +import com.querydsl.core.types.ConstructorExpression; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.core.types.dsl.NumberExpression; +import com.querydsl.core.types.dsl.StringExpression; +import com.querydsl.jpa.domain.Cat; +import com.querydsl.jpa.domain.QCat; + +public class QProjection extends ConstructorExpression { + + private static final long serialVersionUID = -5866362075090550839L; + + public QProjection(StringExpression str, QCat cat) { + super(Projection.class, new Class[] {String.class, Cat.class}, new Expression[] {str, cat}); + } + + public QProjection(NumberExpression i, BooleanExpression b) { + super(Projection.class, new Class[] {int.class, boolean.class}, new Expression[] {i, b}); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QueryHandlerTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QueryHandlerTest.java new file mode 100644 index 0000000000..b9823db565 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QueryHandlerTest.java @@ -0,0 +1,17 @@ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +public class QueryHandlerTest { + + @Test + public void types() { + assertThat(EclipseLinkTemplates.DEFAULT.getQueryHandler().getClass()) + .isEqualTo(EclipseLinkHandler.class); + assertThat(HQLTemplates.DEFAULT.getQueryHandler().getClass()).isEqualTo(HibernateHandler.class); + assertThat(JPQLTemplates.DEFAULT.getQueryHandler().getClass()) + .isEqualTo(DefaultQueryHandler.class); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QueryHelper.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QueryHelper.java new file mode 100644 index 0000000000..5a01c6e1bb --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QueryHelper.java @@ -0,0 +1,117 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.DefaultQueryMetadata; +import com.querydsl.core.NonUniqueResultException; +import com.querydsl.core.QueryMetadata; +import com.querydsl.core.QueryResults; +import com.querydsl.core.Tuple; +import com.querydsl.core.types.Expression; +import java.util.logging.Logger; +import org.hibernate.query.hql.internal.HqlParseTreeBuilder; +import org.jetbrains.annotations.Nullable; + +class QueryHelper extends JPAQueryBase> { + + private static final Logger logger = Logger.getLogger(QueryHelper.class.getName()); + + QueryHelper(JPQLTemplates templates) { + this(new DefaultQueryMetadata(), templates); + } + + QueryHelper(QueryMetadata metadata, JPQLTemplates templates) { + super(metadata, templates); + } + + @Override + protected JPQLSerializer createSerializer() { + return new JPQLSerializer(getTemplates()); + } + + @Override + protected void reset() { + // do nothing + } + + @Override + public long fetchCount() { + return 0; + } + + @Override + @Nullable + public CloseableIterator iterate() { + throw new UnsupportedOperationException(); + } + + @Override + @Nullable + public QueryResults fetchResults() { + throw new UnsupportedOperationException(); + } + + /** + * Printing of the AST has been removed with hibernate 6. TODO: maybe re-add if we find a way to + * do it with hibernate 6. + */ + public void parse() { + // String input = toString(); + // logger.fine("input: " + input.replace('\n', ' ')); + // HqlParser parser = HqlParser.getInstance(input); + // parser.setFilter(false); + // parser.statement(); + // AST ast = parser.getAST(); + // ByteArrayOutputStream baos = new ByteArrayOutputStream(); + // parser.showAst(ast, new PrintStream(baos)); + // assertEquals( + // "At least one error occurred during parsing " + input, + // 0, + // parser.getParseErrorHandler().getErrorCount()); + + var input = toString(); + logger.fine("input: " + input.replace('\n', ' ')); + var parser = + HqlParseTreeBuilder.INSTANCE.buildHqlParser( + input, HqlParseTreeBuilder.INSTANCE.buildHqlLexer(input)); + parser.statement(); + } + + @Override + public T fetchOne() throws NonUniqueResultException { + throw new UnsupportedOperationException(); + } + + @Override + public QueryHelper clone() { + return new QueryHelper<>(getMetadata().clone(), getTemplates()); + } + + @Override + public QueryHelper select(Expression expr) { + queryMixin.setProjection(expr); + @SuppressWarnings("unchecked") // This is the new type + var newType = (QueryHelper) this; + return newType; + } + + @Override + public QueryHelper select(Expression... exprs) { + queryMixin.setProjection(exprs); + @SuppressWarnings("unchecked") // This is the new type + var newType = (QueryHelper) this; + return newType; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QueryMutabilityTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QueryMutabilityTest.java new file mode 100644 index 0000000000..c22646062c --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QueryMutabilityTest.java @@ -0,0 +1,66 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.QueryMutability; +import com.querydsl.jpa.domain.sql.SAnimal_; +import com.querydsl.jpa.hibernate.sql.HibernateSQLQuery; +import com.querydsl.sql.DerbyTemplates; +import com.querydsl.sql.SQLTemplates; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import org.hibernate.Session; +import org.junit.Ignore; +import org.junit.Test; + +public class QueryMutabilityTest { + + private static final SQLTemplates derbyTemplates = new DerbyTemplates(); + + private Session session; + + protected HibernateSQLQuery query() { + return new HibernateSQLQuery(session, derbyTemplates); + } + + public void setSession(Session session) { + this.session = session; + } + + @Test + @Ignore + public void queryMutability() + throws SecurityException, + IllegalArgumentException, + NoSuchMethodException, + IllegalAccessException, + InvocationTargetException, + IOException { + var cat = new SAnimal_("cat"); + HibernateSQLQuery query = query().from(cat); + new QueryMutability(query).test(cat.id, cat.name); + } + + @Test + public void clone_() { + var cat = new SAnimal_("cat"); + HibernateSQLQuery query = query().from(cat).where(cat.name.isNotNull()); + HibernateSQLQuery query2 = query.clone(session); + assertThat(query2.getMetadata().getJoins()).isEqualTo(query.getMetadata().getJoins()); + assertThat(query2.getMetadata().getWhere()).isEqualTo(query.getMetadata().getWhere()); + // query2.fetch(cat.id); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QueryPerformanceTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QueryPerformanceTest.java new file mode 100644 index 0000000000..d3e47a5f78 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/QueryPerformanceTest.java @@ -0,0 +1,112 @@ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.Target; +import com.querydsl.core.Tuple; +import com.querydsl.core.testutil.Performance; +import com.querydsl.jpa.domain.Cat; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.impl.JPAQuery; +import com.querydsl.jpa.testutil.JPATestRunner; +import jakarta.persistence.EntityManager; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; + +@RunWith(JPATestRunner.class) +@Ignore +@Category(Performance.class) +public class QueryPerformanceTest implements JPATest { + + private static final int iterations = 1000; + + private EntityManager entityManager; + + @BeforeClass + public static void setUpClass() { + Mode.mode.set("h2perf"); + Mode.target.set(Target.H2); + } + + @AfterClass + public static void tearDownClass() { + Mode.mode.remove(); + Mode.target.remove(); + } + + private JPAQuery query() { + return new JPAQuery(entityManager); + } + + @Before + public void setUp() { + if (query().from(QCat.cat).fetchCount() == 0) { + for (var i = 0; i < iterations; i++) { + entityManager.persist(new Cat(String.valueOf(i), i + 100)); + } + entityManager.flush(); + } + } + + @Test + public void byId_raw() { + var start = System.currentTimeMillis(); + for (var i = 0; i < iterations; i++) { + var cat = + (Cat) + entityManager + .createQuery("select cat from Cat cat where id = ?") + .setParameter(1, i + 100) + .getSingleResult(); + assertThat(cat).isNotNull(); + } + System.err.println("by id - raw" + (System.currentTimeMillis() - start)); + } + + @Test + public void byId_qdsl() { + var start = System.currentTimeMillis(); + for (var i = 0; i < iterations; i++) { + var cat = QCat.cat; + Cat c = query().from(cat).where(cat.id.eq(i + 100)).select(cat).fetchOne(); + assertThat(c).isNotNull(); + } + System.err.println("by id - dsl" + (System.currentTimeMillis() - start)); + } + + @Test + public void byId_twoCols_raw() { + var start = System.currentTimeMillis(); + for (var i = 0; i < iterations; i++) { + var row = + (Object[]) + entityManager + .createQuery("select cat.id, cat.name from Cat cat where id = ?") + .setParameter(1, i + 100) + .getSingleResult(); + assertThat(row).isNotNull(); + } + System.err.println("by id - 2 cols - raw" + (System.currentTimeMillis() - start)); + } + + @Test + public void byId_twoCols_qdsl() { + var start = System.currentTimeMillis(); + for (var i = 0; i < iterations; i++) { + var cat = QCat.cat; + Tuple row = query().from(cat).where(cat.id.eq(i + 100)).select(cat.id, cat.name).fetchOne(); + assertThat(row).isNotNull(); + } + System.err.println("by id - 2 cols - dsl" + (System.currentTimeMillis() - start)); + } + + @Override + public void setEntityManager(EntityManager entityManager) { + this.entityManager = entityManager; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/RelationalFunctionCallTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/RelationalFunctionCallTest.java new file mode 100644 index 0000000000..9625d47336 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/RelationalFunctionCallTest.java @@ -0,0 +1,73 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.sql.SQLExpressions.select; +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.types.PathMetadataFactory; +import com.querydsl.core.types.SubQueryExpression; +import com.querydsl.core.types.dsl.PathBuilder; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.Configuration; +import com.querydsl.sql.RelationalFunctionCall; +import com.querydsl.sql.RelationalPathBase; +import com.querydsl.sql.SQLExpressions; +import com.querydsl.sql.SQLSerializer; +import com.querydsl.sql.SQLServerTemplates; +import org.junit.Test; + +public class RelationalFunctionCallTest { + + // @Schema("PUBLIC") + // @Table("SURVEY") + public class QSurvey extends RelationalPathBase { + + private static final long serialVersionUID = -7427577079709192842L; + + public final StringPath name = createString("NAME"); + + public QSurvey(String path) { + super(QSurvey.class, PathMetadataFactory.forVariable(path), "PUBLIC", "SURVEY"); + } + } + + @Test + public void functionCall() { + // select tab.col from Table tab join TableValuedFunction('parameter') func on tab.col not like + // func.col + + var table = new QSurvey("SURVEY"); + RelationalFunctionCall func = + SQLExpressions.relationalFunctionCall(String.class, "TableValuedFunction", "parameter"); + var funcAlias = new PathBuilder<>(String.class, "tokFunc"); + SubQueryExpression expr = + select(table.name) + .from(table) + .join(func, funcAlias) + .on(table.name.like(funcAlias.getString("prop")).not()); + + var conf = new Configuration(new SQLServerTemplates()); + SQLSerializer serializer = new NativeSQLSerializer(conf, true); + serializer.serialize(expr.getMetadata(), false); + assertThat(serializer.toString()) + .isEqualTo( + """ + select SURVEY.NAME + from SURVEY SURVEY + join TableValuedFunction(?1) as tokFunc + on not (SURVEY.NAME like tokFunc.prop escape '\\')\ + """); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/SerializationBase.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/SerializationBase.java new file mode 100644 index 0000000000..6cf382df5f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/SerializationBase.java @@ -0,0 +1,102 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.testutil.Serialization; +import com.querydsl.core.types.Predicate; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.impl.JPAQuery; +import com.querydsl.jpa.testutil.JPATestRunner; +import jakarta.persistence.EntityManager; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(JPATestRunner.class) +public class SerializationBase implements JPATest { + + private QCat cat = QCat.cat; + + private EntityManager entityManager; + + @Test + public void test() throws IOException, ClassNotFoundException { + // create query + JPAQuery query = query(); + query.from(cat).where(cat.name.eq("Kate")).select(cat).fetch(); + + var metadata = query.getMetadata(); + assertThat(metadata.getJoins()).isNotEmpty(); + assertThat(metadata.getWhere() != null).isTrue(); + assertThat(metadata.getProjection() != null).isTrue(); + var metadata2 = Serialization.serialize(metadata); + + // validate it + assertThat(metadata2.getJoins()).isEqualTo(metadata.getJoins()); + assertThat(metadata2.getWhere()).isEqualTo(metadata.getWhere()); + assertThat(metadata2.getProjection()).isEqualTo(metadata.getProjection()); + + // create new query + JPAQuery query2 = new JPAQuery(entityManager, metadata2); + assertThat(query2).hasToString("select cat\nfrom Cat cat\nwhere cat.name = ?1"); + query2.select(cat).fetch(); + } + + @Test + public void any_serialized() throws Exception { + Predicate where = cat.kittens.any().name.eq("Ruth234"); + var where2 = Serialization.serialize(where); + + assertThat(query().from(cat).where(where).fetchCount()).isEqualTo(0); + assertThat(query().from(cat).where(where2).fetchCount()).isEqualTo(0); + } + + @Test + public void any_serialized2() throws Exception { + Predicate where = cat.kittens.any().name.eq("Ruth234"); + + var file = new File("target", "predicate.ser"); + if (!file.exists()) { + // serialize predicate on first run + var fileOutputStream = new FileOutputStream(file); + var out = new ObjectOutputStream(fileOutputStream); + out.writeObject(where); + out.close(); + assertThat(query().from(cat).where(where).fetchCount()).isEqualTo(0); + } else { + // deserialize predicate on second run + var fileInputStream = new FileInputStream(file); + var in = new ObjectInputStream(fileInputStream); + var where2 = (Predicate) in.readObject(); + in.close(); + assertThat(query().from(cat).where(where2).fetchCount()).isEqualTo(0); + } + } + + private JPAQuery query() { + return new JPAQuery(entityManager); + } + + @Override + public void setEntityManager(EntityManager entityManager) { + this.entityManager = entityManager; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/SignatureTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/SignatureTest.java new file mode 100644 index 0000000000..ea364c3b79 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/SignatureTest.java @@ -0,0 +1,33 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.FilteredClause; +import com.querydsl.jpa.hibernate.HibernateQuery; +import com.querydsl.jpa.impl.JPAQuery; +import org.junit.Test; + +public class SignatureTest { + + @Test + public void test() { + meet((JPAQuery) null); + meet((HibernateQuery) null); + meet((JPQLQuery) null); + } + + public static > T meet(T query) { + return null; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/StringOperationsTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/StringOperationsTest.java new file mode 100644 index 0000000000..c3ddef9155 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/StringOperationsTest.java @@ -0,0 +1,67 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.cat; +import static com.querydsl.jpa.Constants.cust; +import static com.querydsl.jpa.Constants.kitten; + +import com.querydsl.core.domain.QCat; +import com.querydsl.core.types.Expression; +import com.querydsl.core.types.Ops; +import com.querydsl.core.types.Path; +import com.querydsl.core.types.dsl.Expressions; +import org.junit.Test; + +public class StringOperationsTest extends AbstractQueryTest { + + @Test + public void stringConcatenations() { + assertToString("concat(cat.name,kitten.name)", cat.name.concat(kitten.name)); + } + + @Test + public void stringConversionOperations() { + assertToString("str(cat.bodyWeight)", cat.bodyWeight.stringValue()); + } + + @Test + public void stringOperationsInFunctionalWay() { + assertToString("concat(cat.name,cust.name.firstName)", cat.name.concat(cust.name.firstName)); + assertToString("lower(cat.name)", cat.name.lower()); + } + + @Test + @SuppressWarnings("rawtypes") + public void indexOf() { + Path path = QCat.cat.name; + Expression startIndex = Expressions.constant(0); + Expression endIndex = + Expressions.numberOperation(Integer.class, Ops.INDEX_OF, path, Expressions.constant("x")); + Expression substr = Expressions.stringOperation(Ops.SUBSTR_2ARGS, path, startIndex, endIndex); + assertToString("substring(cat.name,1,locate(?1,cat.name)-1 - ?2)", substr); + } + + @Test + public void indexOf2() { + var str = QCat.cat.name; + assertToString( + "substring(cat.name,1,locate(?1,cat.name)-1 - ?2)", str.substring(0, str.indexOf("x"))); + } + + @Test + public void indexOf3() { + assertToString("substring(cat.name,2,1)", QCat.cat.name.substring(1, 2)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/SubQueryTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/SubQueryTest.java new file mode 100644 index 0000000000..c307450d50 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/SubQueryTest.java @@ -0,0 +1,196 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.Constants.cat; +import static com.querydsl.jpa.Constants.fatcat; +import static com.querydsl.jpa.JPAExpressions.select; +import static com.querydsl.jpa.JPAExpressions.selectFrom; +import static com.querydsl.jpa.JPAExpressions.selectOne; +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.domain.QCat; +import com.querydsl.jpa.domain.QEmployee; +import com.querydsl.jpa.domain.QUser; +import org.junit.Test; + +public class SubQueryTest extends AbstractQueryTest { + + @Test + public void single_source() { + JPQLSubQuery query = selectFrom(cat); + assertThat(query).hasToString("select cat\nfrom Cat cat"); + } + + @Test + public void multiple_sources() { + JPQLSubQuery query = select(cat).from(cat, fatcat); + assertThat(query).hasToString("select cat\nfrom Cat cat, Cat fatcat"); + } + + @Test + public void in() { + cat.in(selectFrom(cat)); + } + + @Test + public void innerJoin() { + assertThat(selectFrom(cat).innerJoin(cat.mate).toString()) + .isEqualTo("select cat\nfrom Cat cat\n inner join cat.mate"); + } + + @Test + public void innerJoin2() { + var employee = QEmployee.employee; + var user = QUser.user; + assertThat(selectFrom(employee).innerJoin(employee.user, user).toString()) + .isEqualTo("select employee\nfrom Employee employee\n inner join employee.user as user"); + } + + @Test + public void leftJoin() { + assertThat(selectFrom(cat).leftJoin(cat.mate).toString()) + .isEqualTo("select cat\nfrom Cat cat\n left join cat.mate"); + } + + @Test + public void join() { + assertThat(selectFrom(cat).join(cat.mate).toString()) + .isEqualTo("select cat\nfrom Cat cat\n inner join cat.mate"); + } + + @Test + public void uniqueProjection() { + assertToString("(select cat from Cat cat)", selectFrom(cat)); + } + + @Test + public void listProjection() { + assertToString("(select cat from Cat cat)", selectFrom(cat)); + } + + @Test + public void listContains() { + assertToString("cat in (select cat from Cat cat)", cat.in(selectFrom(cat))); + } + + @Test + public void exists() { + assertToString("exists (select 1 from Cat cat)", selectOne().from(cat).exists()); + } + + @Test + public void exists_where() { + assertToString( + "exists (select 1 from Cat cat where cat.weight < ?1)", + selectFrom(cat).where(cat.weight.lt(1)).exists()); + } + + @Test + public void exists_via_unique() { + assertToString( + "exists (select 1 from Cat cat where cat.weight < ?1)", + selectOne().from(cat).where(cat.weight.lt(1)).exists()); + } + + @Test + public void notExists() { + assertToString("not exists (select 1 from Cat cat)", selectOne().from(cat).notExists()); + } + + @Test + public void notExists_where() { + assertToString( + "not exists (select 1 from Cat cat where cat.weight < ?1)", + selectOne().from(cat).where(cat.weight.lt(1)).notExists()); + } + + @Test + public void notExists_via_unique() { + assertToString( + "not exists (select 1 from Cat cat where cat.weight < ?1)", + selectOne().from(cat).where(cat.weight.lt(1)).notExists()); + } + + @Test + public void count() { + assertToString("(select count(cat) from Cat cat)", select(cat.count()).from(cat)); + } + + @Test + public void count_via_list() { + assertToString("(select count(cat) from Cat cat)", select(cat.count()).from(cat)); + } + + @Test + public void count_name() { + assertToString("(select count(cat.name) from Cat cat)", select(cat.name.count()).from(cat)); + } + + @Test + public void count_multiple_sources() { + var other = new QCat("other"); + assertToString( + "(select count(cat) from Cat cat, Cat other)", select(cat.count()).from(cat, other)); + } + + @Test + public void count_multiple_sources_via_list() { + var other = new QCat("other"); + assertToString( + "(select count(cat) from Cat cat, Cat other)", select(cat.count()).from(cat, other)); + } + + @Test + public void indexed_access() { + assertMatches( + """ + \\(select count\\(cat\\) from Cat cat \ + left join cat.kittens as cat_kittens_\\w+ \ + with index\\(cat_kittens_\\w+\\) = \\?1 where cat_kittens_\\w+.name = \\?2\\)\ + """, + select(cat.count()).from(cat).where(cat.kittens.get(0).name.eq("Kate"))); + } + + @Test + public void indexed_access_without_constant() { + assertMatches( + """ + \\(select count\\(cat\\) from Cat cat \ + left join cat.kittens as cat_kittens_\\w+ \ + with index\\(cat_kittens_\\w+\\) = cat.id where cat_kittens_\\w+.name = \\?1\\)\ + """, + select(cat.count()).from(cat).where(cat.kittens.get(cat.id).name.eq("Kate"))); + } + + @Test + public void indexOf() { + assertToString( + "(select count(cat) from Cat cat where locate(?1,cat.name)-1 = ?2)", + select(cat.count()).from(cat).where(cat.name.indexOf("a").eq(1))); + } + + // @Test + // public void orderBy() { + // JPQLQuery query = query().from(cat1).where(cat1.alive); + // SubQueryExpression subquery = + // sub().from(cat).where(cat.mate.id.eq(cat1.id)).select(cat.floatProperty.avg()); + // query.orderBy(subquery.subtract(-1.0f).asc()); + // + // assertEquals("select cat1 from Cat cat1 where cat1.alive order by (select + // avg(cat.floatProperty) from Cat cat where cat.mate.id = cat1.id) - ?1 asc", + // query.toString().replace("\n", " ")); + // } + +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/TargetRule.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/TargetRule.java new file mode 100644 index 0000000000..0402b6daf0 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/TargetRule.java @@ -0,0 +1,37 @@ +package com.querydsl.jpa; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.EmptyStatement; +import com.querydsl.core.testutil.ExcludeIn; +import com.querydsl.core.testutil.IncludeIn; +import java.util.Arrays; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +/** + * @author tiwe + */ +public class TargetRule implements TestRule { + + @Override + public Statement apply(Statement base, Description description) { + var target = Mode.target.get(); + var run = target == null || isExecuted(description, target); + return run ? base : EmptyStatement.DEFAULT; + } + + private boolean isExecuted(Description description, Target target) { + var ex = description.getAnnotation(ExcludeIn.class); + // excluded in given targets + if (ex != null && Arrays.asList(ex.value()).contains(target)) { + return false; + } + // included only in given targets + var in = description.getAnnotation(IncludeIn.class); + if (in != null && !Arrays.asList(in.value()).contains(target)) { + return false; + } + return true; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/TemplatesTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/TemplatesTest.java new file mode 100644 index 0000000000..39ee899efd --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/TemplatesTest.java @@ -0,0 +1,20 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import com.querydsl.core.TemplatesTestBase; + +public class TemplatesTest extends TemplatesTestBase {} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/TupleTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/TupleTest.java new file mode 100644 index 0000000000..b718a376d2 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/TupleTest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static com.querydsl.jpa.JPAExpressions.select; + +import com.querydsl.core.types.Projections; +import com.querydsl.core.types.SubQueryExpression; +import com.querydsl.jpa.domain.QCat; +import org.junit.Ignore; +import org.junit.Test; + +public class TupleTest extends AbstractQueryTest { + + @Test + @Ignore // FIXME + public void test() { + var cat = QCat.cat; + + SubQueryExpression subQuery = + select(cat.birthdate, cat.name, cat.mate) + .from(cat) + .where( + select(cat.mate, cat.birthdate.max()) + .from(cat) + .groupBy(cat.mate) + .contains(Projections.tuple(cat.mate, cat.birthdate))); + + assertToString( + """ + (select cat.birthdate, cat.name, cat.mate from Cat cat \ + where (cat.mate, cat.birthdate) in \ + (select cat.mate, max(cat.birthdate) from Cat cat group by cat.mate))\ + """, + subQuery); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/TypeCastTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/TypeCastTest.java new file mode 100644 index 0000000000..a3d310efb0 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/TypeCastTest.java @@ -0,0 +1,77 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.jpa.domain.Animal; +import com.querydsl.jpa.domain.Cat; +import com.querydsl.jpa.domain.InheritedProperties; +import com.querydsl.jpa.domain.QAnimal; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.domain.QInheritedProperties; +import org.junit.Test; + +public class TypeCastTest { + + @Test + public void mappedSuperclass() { + var subClass = QInheritedProperties.inheritedProperties; + var superClass = subClass._super; + + assertThat(superClass.getType()).isEqualTo(InheritedProperties.class); + // assertEquals(InheritedProperties.class.getSimpleName(), superClass.getEntityName()); + assertThat(superClass).hasToString("inheritedProperties"); + } + + // @Test + // public void mappedSuperclass2() { + // QInheritedProperties subClass = QInheritedProperties.inheritedProperties; + // QSuperclass superClass = new QSuperclass(subClass.getMetadata()); + // + // assertEquals(Superclass.class, superClass.getType()); + // assertEquals(Superclass.class.getSimpleName(), superClass.getEntityName()); + // assertEquals("inheritedProperties", superClass.toString()); + // } + + @Test + public void subClassToSuper() { + var cat = QCat.cat; + var animal = new QAnimal(cat); + + assertThat(animal.getType()).isEqualTo(Cat.class); + // assertEquals(Cat.class.getSimpleName(), animal.getEntityName()); + assertThat(animal).hasToString("cat"); + } + + @Test + public void subClassToSuper2() { + var cat = QCat.cat; + var animal = new QAnimal(cat.getMetadata()); + + assertThat(animal.getType()).isEqualTo(Animal.class); + // assertEquals(Animal.class.getSimpleName(), animal.getEntityName()); + assertThat(animal).hasToString("cat"); + } + + @Test + public void superClassToSub() { + var animal = QAnimal.animal; + var cat = new QCat(animal.getMetadata()); + + assertThat(cat.getType()).isEqualTo(Cat.class); + // assertEquals(Cat.class.getSimpleName(), cat.getEntityName()); + assertThat(cat).hasToString("animal"); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/UniqueResultsTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/UniqueResultsTest.java new file mode 100644 index 0000000000..5fdf898578 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/UniqueResultsTest.java @@ -0,0 +1,79 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.jpa.domain.Cat; +import com.querydsl.jpa.domain.QCat; +import com.querydsl.jpa.hibernate.HibernateQuery; +import com.querydsl.jpa.testutil.HibernateTestRunner; +import org.hibernate.Session; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; + +@Ignore +@RunWith(HibernateTestRunner.class) +public class UniqueResultsTest implements HibernateTest { + + private Session session; + + @Test + public void test() { + session.save(new Cat("Bob1", 1)); + session.save(new Cat("Bob2", 2)); + session.save(new Cat("Bob3", 3)); + + assertThat( + query() + .from(QCat.cat) + .orderBy(QCat.cat.name.asc()) + .offset(0) + .limit(1) + .select(QCat.cat.id) + .fetchOne()) + .isEqualTo(Integer.valueOf(1)); + assertThat( + query() + .from(QCat.cat) + .orderBy(QCat.cat.name.asc()) + .offset(1) + .limit(1) + .select(QCat.cat.id) + .fetchOne()) + .isEqualTo(Integer.valueOf(2)); + assertThat( + query() + .from(QCat.cat) + .orderBy(QCat.cat.name.asc()) + .offset(2) + .limit(1) + .select(QCat.cat.id) + .fetchOne()) + .isEqualTo(Integer.valueOf(3)); + + assertThat(query().from(QCat.cat).select(QCat.cat.count()).fetchOne()) + .isEqualTo(Long.valueOf(3)); + } + + private HibernateQuery query() { + return new HibernateQuery(session); + } + + @Override + public void setSession(Session session) { + this.session = session; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Account.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Account.java new file mode 100644 index 0000000000..e949efd4c8 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Account.java @@ -0,0 +1,51 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; + +import com.querydsl.core.annotations.QueryInit; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.persistence.Transient; +import java.io.Serializable; +import org.junit.Test; + +/** The Class Account. */ +@SuppressWarnings("serial") +@Entity +@Table(name = "account_") +public class Account implements Serializable { + + @Transient public int transientField; + + @Id long id; + + @ManyToOne + @QueryInit("pid") + Person owner; + + @Embedded EmbeddedType embeddedData; + + @Test + public void test() { + assertThatExceptionOfType(Exception.class) + .isThrownBy(() -> QAccount.class.getField("serialVersionUID")); + assertThatExceptionOfType(Exception.class) + .isThrownBy(() -> QAccount.class.getField("transientField")); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Animal.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Animal.java new file mode 100644 index 0000000000..7b4d013080 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Animal.java @@ -0,0 +1,145 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import java.util.Date; + +/** The Class Animal. */ +@Entity +@Table(name = "animal_") +@DiscriminatorValue("A") +public class Animal { + private boolean alive; + + @Temporal(TemporalType.TIMESTAMP) + private java.util.Date birthdate; + + private int weight, toes; + + // needed for JPA tests + private double bodyWeight; + + private float floatProperty; + + private Color color; + + // @Temporal(TemporalType.DATE) + private java.sql.Date dateField; + + @Id private int id; + + private String name; + + private java.sql.Time timeField; + + public Animal() {} + + public Animal(int id) { + setId(id); + } + + public java.util.Date getBirthdate() { + return new Date(birthdate.getTime()); + } + + public double getBodyWeight() { + return bodyWeight; + } + + public Color getColor() { + return color; + } + + public java.sql.Date getDateField() { + return new java.sql.Date(dateField.getTime()); + } + + public int getId() { + return id; + } + + public String getName() { + return name; + } + + public java.sql.Time getTimeField() { + return timeField; + } + + public int getToes() { + return toes; + } + + public int getWeight() { + return weight; + } + + public boolean isAlive() { + return alive; + } + + public void setAlive(boolean alive) { + this.alive = alive; + } + + public void setBirthdate(java.util.Date birthdate) { + this.birthdate = new java.util.Date(birthdate.getTime()); + } + + public void setBodyWeight(double bodyWeight) { + this.bodyWeight = bodyWeight; + } + + public void setColor(Color color) { + this.color = color; + } + + public void setDateField(java.sql.Date dateField) { + this.dateField = new java.sql.Date(dateField.getTime()); + } + + public void setId(int id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + + public void setTimeField(java.sql.Time timeField) { + this.timeField = timeField; + } + + public void setToes(int toes) { + this.toes = toes; + } + + public void setWeight(int weight) { + this.weight = weight; + } + + public float getFloatProperty() { + return floatProperty; + } + + public void setFloatProperty(float floatProperty) { + this.floatProperty = floatProperty; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/AuditLog.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/AuditLog.java new file mode 100644 index 0000000000..2008e7005f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/AuditLog.java @@ -0,0 +1,28 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +/** The Class AuditLog. */ +@Entity +@Table(name = "auditlog_") +public class AuditLog { + @Id int id; + + @ManyToOne Item item; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Author.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Author.java new file mode 100644 index 0000000000..b523e7c2e0 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Author.java @@ -0,0 +1,49 @@ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.OrderBy; +import jakarta.persistence.Table; +import java.io.Serializable; +import java.util.Set; + +@Entity +@Table(name = "author_") +public class Author implements Serializable { + + private static final long serialVersionUID = -1893968697250846661L; + + @Id @GeneratedValue private Long id; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @OneToMany(mappedBy = "author") + @OrderBy("title") + private Set books; + + public Set getBooks() { + return books; + } + + public void setBooks(Set books) { + this.books = books; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Bar.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Bar.java new file mode 100644 index 0000000000..864419cd7c --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Bar.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; + +/** The Class Bar. */ +@Entity +@Table(name = "bar_") +public class Bar { + @Temporal(TemporalType.DATE) + java.util.Date date; + + @Id int id; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Book.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Book.java new file mode 100644 index 0000000000..e11852fd50 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Book.java @@ -0,0 +1,48 @@ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import java.io.Serializable; + +@Entity +@Table(name = "book_") +public class Book implements Serializable { + + private static final long serialVersionUID = -9029792723035681319L; + + @Id @GeneratedValue private Long id; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + private String title; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + @ManyToOne + @JoinColumn(name = "AUTHOR_ID") + private Author author; + + public Author getAuthor() { + return author; + } + + public void setAuthor(Author author) { + this.author = author; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Calendar.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Calendar.java new file mode 100644 index 0000000000..4806120147 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Calendar.java @@ -0,0 +1,37 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.MapKeyColumn; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import java.io.Serializable; +import java.util.Map; + +/** The Class Calendar. */ +@SuppressWarnings("serial") +@Entity +@Table(name = "calendar_") +public class Calendar implements Serializable { + @ElementCollection + @Temporal(TemporalType.DATE) + @MapKeyColumn(name = "holidays_key") + Map holidays; + + @Id int id; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Cat.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Cat.java new file mode 100644 index 0000000000..95cff5e591 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Cat.java @@ -0,0 +1,123 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.Entity; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.OrderColumn; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** The Class Cat. */ +@Entity +@DiscriminatorValue("C") +public class Cat extends Animal { + + private int breed; + + private Color eyecolor; + + @OneToMany + @JoinTable( + name = "kittens", + joinColumns = @JoinColumn(name = "cat_id"), + inverseJoinColumns = @JoinColumn(name = "kitten_id")) + @OrderColumn(name = "ind") + private List kittens = new ArrayList<>(); + + @OneToMany + @JoinTable( + name = "kittens_set", + joinColumns = @JoinColumn(name = "cat_id"), + inverseJoinColumns = @JoinColumn(name = "kitten_id")) + private Set kittensSet; + + // @OneToMany + // @JoinTable(name="kittens_array") + // @IndexColumn(name = "arrayIndex") + // private Cat[] kittensArray = new Cat[0]; + + @ManyToOne private Cat mate; + + public Cat() {} + + public Cat(int id) { + setId(id); + } + + public Cat(String name, int id) { + setId(id); + setName(name); + } + + public Cat(String name, int id, Color color) { + setId(id); + setName(name); + setColor(color); + } + + public Cat(String name, int id, List k) { + setId(id); + setName(name); + kittens.addAll(k); + } + + public Cat(String name, int id, double bodyWeight) { + this(name, id); + setBodyWeight(bodyWeight); + setFloatProperty((float) bodyWeight); + } + + public int getBreed() { + return breed; + } + + public Color getEyecolor() { + return eyecolor; + } + + public List getKittens() { + return kittens; + } + + public Cat getMate() { + return mate; + } + + // public Cat[] getKittensArray() { + // return kittensArray; + // } + + public void addKitten(Cat kitten) { + kittens.add(kitten); + // kittensArray = new Cat[]{kitten}; + } + + public Set getKittensSet() { + return kittensSet; + } + + public void setKittensSet(Set kittensSet) { + this.kittensSet = kittensSet; + } + + public void setMate(Cat mate) { + this.mate = mate; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/CatSummary.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/CatSummary.java new file mode 100644 index 0000000000..8e232feee4 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/CatSummary.java @@ -0,0 +1,33 @@ +package com.querydsl.jpa.domain; + +import com.querydsl.core.annotations.QueryProjection; + +public class CatSummary { + + private long breeders; + + private boolean hasEyeColoredCat; + + @QueryProjection + public CatSummary(long breeders, boolean hasEyeColoredCat) { + super(); + this.breeders = breeders; + this.hasEyeColoredCat = hasEyeColoredCat; + } + + public long getBreeders() { + return breeders; + } + + public void setBreeders(long breeders) { + this.breeders = breeders; + } + + public boolean isHasEyeColoredCat() { + return hasEyeColoredCat; + } + + public void setHasEyeColoredCat(boolean hasEyeColoredCat) { + this.hasEyeColoredCat = hasEyeColoredCat; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Catalog.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Catalog.java new file mode 100644 index 0000000000..01ef8c4c79 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Catalog.java @@ -0,0 +1,35 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import java.util.Date; +import java.util.Set; + +/** The Class Catalog. */ +@Entity +@Table(name = "catalog_") +public class Catalog { + @Temporal(TemporalType.DATE) + Date effectiveDate; + + @Id int id; + + @OneToMany Set prices; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Child.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Child.java new file mode 100644 index 0000000000..7b10e7aa51 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Child.java @@ -0,0 +1,13 @@ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; + +@Entity(name = "Child2") +public class Child { + + @Id int id; + + @ManyToOne Parent parent; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Color.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Color.java new file mode 100644 index 0000000000..f64982a900 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Color.java @@ -0,0 +1,20 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +/** The Enum Color. */ +public enum Color { + BLACK, + TABBY +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Company.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Company.java new file mode 100644 index 0000000000..d1b14628e0 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Company.java @@ -0,0 +1,52 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import java.util.List; + +/** The Class Company. */ +@Entity +@Table(name = "company_") +public class Company { + + public enum Rating { + A, + AA, + AAA + } + + @Enumerated public Rating ratingOrdinal; + + @Enumerated(EnumType.STRING) + public Rating ratingString; + + @ManyToOne public Employee ceo; + + @OneToMany public List departments; + + @Id public int id; + + public String name; + + @Column(name = "official_name") + public String officialName; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Customer.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Customer.java new file mode 100644 index 0000000000..6b249f2822 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Customer.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +/** The Class Customer. */ +@Entity +@Table(name = "customer_") +public class Customer { + @ManyToOne Order currentOrder; + + @Id int id; + + @ManyToOne Name name; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Department.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Department.java new file mode 100644 index 0000000000..763681e7eb --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Department.java @@ -0,0 +1,34 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import java.util.List; + +/** The Class Department. */ +@Entity +@Table(name = "department_") +public class Department { + @ManyToOne Company company; + + @OneToMany List employees; + + @Id int id; + + String name; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Document.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Document.java new file mode 100644 index 0000000000..93c23ccac8 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Document.java @@ -0,0 +1,33 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import java.util.Date; + +/** The Class Document. */ +@Entity +@Table(name = "document_") +public class Document { + @Id int id; + + String name; + + @Temporal(TemporalType.DATE) + Date validTo; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Dolphin.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Dolphin.java new file mode 100644 index 0000000000..dac2149ed6 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Dolphin.java @@ -0,0 +1,6 @@ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; + +@Entity +public class Dolphin extends Mammal {} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Domain.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Domain.java new file mode 100644 index 0000000000..3da0a654a5 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Domain.java @@ -0,0 +1,95 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import com.querydsl.jpa.domain4.BookID; +import com.querydsl.jpa.domain4.BookMark; +import com.querydsl.jpa.domain4.BookVersion; +import com.querydsl.jpa.domain4.Library; +import com.querydsl.jpa.domain5.MyEmbeddedAttribute; +import com.querydsl.jpa.domain5.MyEntity; +import com.querydsl.jpa.domain5.MyMappedSuperclass; +import com.querydsl.jpa.domain5.MyOtherEntity; +import java.util.Arrays; +import java.util.List; + +public final class Domain { + + private Domain() {} + + public static final List> classes = + Arrays.>asList( + Account.class, + Animal.class, + Author.class, + AuditLog.class, + Bar.class, + Book.class, + Calendar.class, + Cat.class, + Catalog.class, + Child.class, + Color.class, + Company.class, + Customer.class, + Department.class, + Document.class, + DomesticCat.class, + Dolphin.class, + EmbeddedType.class, + Employee.class, + Entity1.class, + Entity2.class, + Family.class, + Foo.class, + Formula.class, + Group.class, + Human.class, + InheritedProperties.class, + Item.class, + Location.class, + Mammal.class, + Name.class, + Named.class, + NameList.class, + Nationality.class, + Novel.class, + Numeric.class, + Order.class, + Parameter.class, + Parent.class, + Payment.class, + PaymentStatus.class, + Person.class, + PersonId.class, + Player.class, + Price.class, + Product.class, + Show.class, + SimpleTypes.class, + Status.class, + StatusChange.class, + Store.class, + Superclass.class, + User.class, + World.class, + BookID.class, + BookMark.class, + BookVersion.class, + Library.class, + MyEmbeddedAttribute.class, + MyEntity.class, + MyMappedSuperclass.class, + MyOtherEntity.class); +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/DomesticCat.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/DomesticCat.java new file mode 100644 index 0000000000..cae968dba8 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/DomesticCat.java @@ -0,0 +1,22 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.Entity; + +/** The Class DomesticCat. */ +@Entity +@DiscriminatorValue("DC") +public class DomesticCat extends Cat {} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/DoubleProjection.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/DoubleProjection.java new file mode 100644 index 0000000000..801eae160f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/DoubleProjection.java @@ -0,0 +1,13 @@ +package com.querydsl.jpa.domain; + +import com.querydsl.core.annotations.QueryProjection; + +public class DoubleProjection { + + public double val; + + @QueryProjection + public DoubleProjection(double val) { + this.val = val; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/EmbeddedType.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/EmbeddedType.java new file mode 100644 index 0000000000..13d6c0fd1d --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/EmbeddedType.java @@ -0,0 +1,24 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Embeddable; +import java.io.Serializable; + +@SuppressWarnings("serial") +@Embeddable +public class EmbeddedType implements Serializable { + + String someData; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Employee.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Employee.java new file mode 100644 index 0000000000..136189b5a0 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Employee.java @@ -0,0 +1,45 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; +import java.util.Collection; +import java.util.HashSet; + +/** The Class Employee. */ +@Entity +@Table(name = "employee_") +public class Employee { + @ManyToOne public Company company; + + @OneToOne public User user; + + public String firstName, lastName; + + @Id public int id; + + @Enumerated(EnumType.STRING) + @Column(name = "jobfunction") + @ElementCollection(fetch = FetchType.EAGER) + public Collection jobFunctions = new HashSet<>(); +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Entity1.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Entity1.java new file mode 100644 index 0000000000..e41b41eb90 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Entity1.java @@ -0,0 +1,18 @@ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; + +@Entity +public class Entity1 { + + public Entity1() {} + + public Entity1(int id) { + this.id = id; + } + + @Id public int id; + + public String property; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Entity2.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Entity2.java new file mode 100644 index 0000000000..c8a9b6f981 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Entity2.java @@ -0,0 +1,15 @@ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; + +@Entity +public class Entity2 extends Entity1 { + + public Entity2() {} + + public Entity2(int id) { + this.id = id; + } + + public String property2; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/EvilType.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/EvilType.java new file mode 100644 index 0000000000..be60be805a --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/EvilType.java @@ -0,0 +1,42 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +/** The Class EvilType. */ +@Entity +@Table(name = "eviltype_") +public class EvilType { + + @ManyToOne + @JoinColumn(name = "_asc") + EvilType asc; + + @ManyToOne + @JoinColumn(name = "_desc") + EvilType desc; + + @Id int id; + + @ManyToOne(fetch = FetchType.LAZY) + EvilType isnull, isnotnull, get, getType, getMetadata; + @ManyToOne(fetch = FetchType.LAZY) + EvilType toString, hashCode, getClass, notify, notifyAll, wait; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Family.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Family.java new file mode 100644 index 0000000000..2a6e42d9e5 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Family.java @@ -0,0 +1,23 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import com.querydsl.core.annotations.QueryProjection; + +/** The Class Family. */ +public class Family { + + @QueryProjection + public Family(Cat mother, Cat mate, Cat offspr) {} +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/FloatProjection.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/FloatProjection.java new file mode 100644 index 0000000000..11fa801cd7 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/FloatProjection.java @@ -0,0 +1,13 @@ +package com.querydsl.jpa.domain; + +import com.querydsl.core.annotations.QueryProjection; + +public class FloatProjection { + + public float val; + + @QueryProjection + public FloatProjection(float val) { + this.val = val; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Foo.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Foo.java new file mode 100644 index 0000000000..ac02b55520 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Foo.java @@ -0,0 +1,44 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.CollectionTable; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import java.util.List; + +/** The Class Foo. */ +@Entity +@Table(name = "foo_") +public class Foo { + public String bar; + + @Id + // @GeneratedValue(strategy=GenerationType.AUTO) + public int id; + + @ElementCollection + @CollectionTable( + name = "foo_names", + joinColumns = {@JoinColumn(name = "foo_id")}) + public List names; + + @Temporal(TemporalType.DATE) + public java.util.Date startDate; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/FooDTO.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/FooDTO.java new file mode 100644 index 0000000000..121cf5440f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/FooDTO.java @@ -0,0 +1,40 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import com.querydsl.core.annotations.QueryProjection; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Id; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import java.util.List; + +public class FooDTO { + String bar; + + @Id int id; + + @ElementCollection List names; + + @Temporal(TemporalType.DATE) + java.util.Date startDate; + + public FooDTO() {} + + @QueryProjection + public FooDTO(long l) {} + + @QueryProjection + public FooDTO(long l, long r) {} +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Formula.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Formula.java new file mode 100644 index 0000000000..578a2d988e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Formula.java @@ -0,0 +1,36 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +/** The Class Formula. */ +@Entity +@Table(name = "formula_") +public class Formula { + @Id int id; + + @ManyToOne Parameter parameter; + + public int getId() { + return id; + } + + public Parameter getParameter() { + return parameter; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Group.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Group.java new file mode 100644 index 0000000000..870be70c4c --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Group.java @@ -0,0 +1,26 @@ +/* + * Copyright 2016, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +@Entity +@Table(name = "group_") +public class Group { + @Id int id; + + String name; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Human.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Human.java new file mode 100644 index 0000000000..1747789524 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Human.java @@ -0,0 +1,11 @@ +package com.querydsl.jpa.domain; + +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import java.util.Collection; + +@Entity +public class Human extends Mammal { + + @ElementCollection Collection hairs; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/InheritedProperties.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/InheritedProperties.java new file mode 100644 index 0000000000..5bc4cb0677 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/InheritedProperties.java @@ -0,0 +1,26 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +@Entity +@Table(name = "inheritedproperties_") +public class InheritedProperties extends Superclass { + @Id long id; + + String classProperty; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Item.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Item.java new file mode 100644 index 0000000000..c3928f5c89 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Item.java @@ -0,0 +1,28 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +/** The Class Item. */ +@Entity +@Table(name = "item_") +public class Item { + @Id long id; + + @ManyToOne Product product; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/JobFunction.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/JobFunction.java new file mode 100644 index 0000000000..5ad92ac1bf --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/JobFunction.java @@ -0,0 +1,21 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +public enum JobFunction { + MANAGER, + CODER, + CONSULTANT, + CONTROLLER; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Location.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Location.java new file mode 100644 index 0000000000..5ebb81e08c --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Location.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +/** The Class Location. */ +@Entity(name = "Location2") +@Table(name = "location_") +public class Location { + @Id long id; + + String name; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Mammal.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Mammal.java new file mode 100644 index 0000000000..8f120a1ae1 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Mammal.java @@ -0,0 +1,10 @@ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; + +@Entity +public class Mammal { + + @Id Long id; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Name.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Name.java new file mode 100644 index 0000000000..d1f56b2644 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Name.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +/** The Class Name. */ +@Entity +@Table(name = "name_") +public class Name { + String firstName, lastName, nickName; + + @Id long id; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/NameList.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/NameList.java new file mode 100644 index 0000000000..229660bba6 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/NameList.java @@ -0,0 +1,29 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.util.Collection; + +/** The Class NameList. */ +@Entity +@Table(name = "namelist_") +public class NameList { + @Id long id; + + @ElementCollection Collection names; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Named.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Named.java new file mode 100644 index 0000000000..93e5204618 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Named.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +/** The Class Named. */ +@Entity +@Table(name = "named_") +public class Named { + @Id long id; + + String name; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Nationality.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Nationality.java new file mode 100644 index 0000000000..1503a5ef1f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Nationality.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import java.io.Serializable; + +/** The Class Nationality. */ +@SuppressWarnings("serial") +@Entity +@Table(name = "nationality_") +public class Nationality implements Serializable { + @ManyToOne Calendar calendar; + + @Id long id; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Novel.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Novel.java new file mode 100644 index 0000000000..c52d2c98ae --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Novel.java @@ -0,0 +1,9 @@ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; + +@Entity +public class Novel extends Book { + + private static final long serialVersionUID = 4711598115423737544L; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Numeric.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Numeric.java new file mode 100644 index 0000000000..698ce7cce2 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Numeric.java @@ -0,0 +1,37 @@ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.io.Serializable; +import java.math.BigDecimal; + +@Entity +@Table(name = "numeric_") +public class Numeric implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id @GeneratedValue private Long id; + + @Column(name = "value_") + private BigDecimal value; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public BigDecimal getValue() { + return value; + } + + public void setValue(BigDecimal value) { + this.value = value; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Order.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Order.java new file mode 100644 index 0000000000..8a9832cb95 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Order.java @@ -0,0 +1,55 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.MapKey; +import jakarta.persistence.OneToMany; +import jakarta.persistence.OrderColumn; +import jakarta.persistence.Table; +import java.util.List; +import java.util.Map; + +/** The Class Order. */ +@Entity +@Table(name = "order_") +public class Order { + @ManyToOne Customer customer; + + @ElementCollection + @OrderColumn(name = "_index") + List deliveredItemIndices; + + @Id long id; + + @OneToMany + @OrderColumn(name = "_index") + List items; + + @OneToMany + @JoinTable(name = "LineItems") + @OrderColumn(name = "_index") + List lineItems; + + @OneToMany + @JoinTable(name = "LineItems2") + @MapKey(name = "id") + Map lineItemsMap; + + boolean paid; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Parameter.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Parameter.java new file mode 100644 index 0000000000..5853ab153e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Parameter.java @@ -0,0 +1,25 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +/** The Class Parameter. */ +@Entity +@Table(name = "parameter_") +public class Parameter { + @Id long id; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Parent.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Parent.java new file mode 100644 index 0000000000..318e912a34 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Parent.java @@ -0,0 +1,15 @@ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import java.util.Set; + +@Entity(name = "Parent2") +public class Parent { + + @Id int id; + + @OneToMany(mappedBy = "parent") + Set children; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Payment.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Payment.java new file mode 100644 index 0000000000..e9d0617f45 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Payment.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Enumerated; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import java.util.Collection; + +/** The Class Payment. */ +@Entity +public class Payment extends Item { + @ManyToOne Status currentStatus, status; + + @Enumerated PaymentStatus paymentStatus; + + @OneToMany Collection statusChanges; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/PaymentStatus.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/PaymentStatus.java new file mode 100644 index 0000000000..98df9a7850 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/PaymentStatus.java @@ -0,0 +1,19 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +/** The Enum PaymentStatus. */ +public enum PaymentStatus { + AWAITING_APPROVAL +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Person.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Person.java new file mode 100644 index 0000000000..be8b947956 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Person.java @@ -0,0 +1,42 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import com.querydsl.core.annotations.QueryInit; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import java.io.Serializable; + +/** The Class Person. */ +@SuppressWarnings("serial") +@Entity +@Table(name = "person_") +public class Person implements Serializable { + @Temporal(TemporalType.DATE) + java.util.Date birthDay; + + @Id long i; + + @ManyToOne PersonId pid; + + String name; + + @ManyToOne + @QueryInit("calendar") + Nationality nationality; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/PersonId.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/PersonId.java new file mode 100644 index 0000000000..76be08b3b1 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/PersonId.java @@ -0,0 +1,31 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.io.Serializable; + +/** The Class PersonId. */ +@SuppressWarnings("serial") +@Entity +@Table(name = "personid_") +public class PersonId implements Serializable { + String country; + + @Id long id; + + int medicareNumber; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Player.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Player.java new file mode 100644 index 0000000000..c71693e143 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Player.java @@ -0,0 +1,29 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.util.List; + +/** The Class Player. */ +@Entity +@Table(name = "player_") +public class Player { + @Id long id; + + @ElementCollection List scores; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Price.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Price.java new file mode 100644 index 0000000000..fb89368173 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Price.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +/** The Class Price. */ +@Entity +@Table(name = "price_") +public class Price { + long amount; + + @Id long id; + + @ManyToOne Product product; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Product.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Product.java new file mode 100644 index 0000000000..9ec91290c8 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Product.java @@ -0,0 +1,23 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; + +/** The Class Product. */ +@Entity +public class Product extends Item { + // @Id long id; + String name; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Show.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Show.java new file mode 100644 index 0000000000..e799c0fd44 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Show.java @@ -0,0 +1,42 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.MapKeyColumn; +import jakarta.persistence.Table; +import java.util.Map; + +/** The Class Show. */ +@Entity +@Table(name = "show_") +public class Show { + + @Id long id; + + @ElementCollection + @MapKeyColumn(name = "acts_key") + public Map acts; + + @ManyToOne public Show parent; + + public Show() {} + + public Show(int id) { + this.id = id; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/SimpleTypes.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/SimpleTypes.java new file mode 100644 index 0000000000..605a5931e5 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/SimpleTypes.java @@ -0,0 +1,71 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import java.math.BigDecimal; +import java.util.Date; +import java.util.Locale; + +@Entity +@Table(name = "simpletypes_") +public class SimpleTypes { + transient int test; + @Id long id; + + BigDecimal bigDecimal; + + Byte bbyte; + + byte bbyte2; + + Character cchar; + + char cchar2; + + Double ddouble; + + double ddouble2; + + Float ffloat; + + float ffloat2; + + Integer iint; + + int iint2; + + Locale llocale; + + Long llong; + + long llong2; + + String sstring; + + @Temporal(TemporalType.DATE) + Date date; + + // @Temporal(TemporalType.TIME) + java.sql.Time time; + + // @Temporal(TemporalType.TIMESTAMP) + java.sql.Timestamp timestamp; + + byte[] byteArray; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Status.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Status.java new file mode 100644 index 0000000000..1b6e814e5b --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Status.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +/** The Class Status. */ +@Entity +@Table(name = "status_") +public class Status { + @Id long id; + + String name; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/StatusChange.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/StatusChange.java new file mode 100644 index 0000000000..da9166a1a5 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/StatusChange.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; + +/** The Class StatusChange. */ +@Entity +@Table(name = "statuschange_") +public class StatusChange { + @Id long id; + + @Temporal(TemporalType.TIMESTAMP) + java.util.Date timeStamp; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Store.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Store.java new file mode 100644 index 0000000000..3d8ae58ff3 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Store.java @@ -0,0 +1,32 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import java.util.List; + +/** The Class Store. */ +@Entity +@Table(name = "store_") +public class Store { + @OneToMany List customers; + + @Id long id; + + @ManyToOne Location location; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Superclass.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Superclass.java new file mode 100644 index 0000000000..88ae954ce9 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/Superclass.java @@ -0,0 +1,34 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import com.querydsl.core.annotations.PropertyType; +import com.querydsl.core.annotations.QueryType; +import jakarta.persistence.MappedSuperclass; + +@MappedSuperclass +public class Superclass { + String superclassProperty; + + @QueryType(PropertyType.SIMPLE) + private String stringAsSimple; + + public String getStringAsSimple() { + return stringAsSimple; + } + + public void setStringAsSimple(String stringAsSimple) { + this.stringAsSimple = stringAsSimple; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/User.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/User.java new file mode 100644 index 0000000000..606b3d9d0c --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/User.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +/** The Class User. */ +@Entity +@Table(name = "user_") +public class User { + @ManyToOne Company company; + + @Id long id; + + String userName, firstName, lastName; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/World.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/World.java new file mode 100644 index 0000000000..4705430f3a --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/World.java @@ -0,0 +1,14 @@ +package com.querydsl.jpa.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import java.util.Set; + +@Entity +public class World { + + @Id Long id; + + @OneToMany Set mammals; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/package-info.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/package-info.java new file mode 100644 index 0000000000..397aa5d374 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/package-info.java @@ -0,0 +1,4 @@ +@Config(listAccessors = true, mapAccessors = true) +package com.querydsl.jpa.domain; + +import com.querydsl.core.annotations.Config; diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SAccount_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SAccount_.java new file mode 100644 index 0000000000..5c6988a25c --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SAccount_.java @@ -0,0 +1,66 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SAccount_ is a Querydsl query type for SAccount_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SAccount_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -2128134054; + + public static final SAccount_ account_ = new SAccount_("account_"); + + public final NumberPath id = createNumber("id", Long.class); + + public final NumberPath ownerI = createNumber("ownerI", Long.class); + + public final StringPath somedata = createString("somedata"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey account_OWNERIFK = + createForeignKey(ownerI, "I"); + + public SAccount_(String variable) { + super(SAccount_.class, forVariable(variable), "null", "account_"); + addMetadata(); + } + + public SAccount_(String variable, String schema, String table) { + super(SAccount_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SAccount_(String variable, String schema) { + super(SAccount_.class, forVariable(variable), schema, "account_"); + addMetadata(); + } + + public SAccount_(Path path) { + super(path.getType(), path.getMetadata(), "null", "account_"); + addMetadata(); + } + + public SAccount_(PathMetadata metadata) { + super(SAccount_.class, metadata, "null", "account_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + ownerI, ColumnMetadata.named("OWNER_I").withIndex(3).ofType(Types.BIGINT).withSize(19)); + addMetadata( + somedata, + ColumnMetadata.named("SOMEDATA").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SAnimal_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SAnimal_.java new file mode 100644 index 0000000000..50748d3cb0 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SAnimal_.java @@ -0,0 +1,136 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.BooleanPath; +import com.querydsl.core.types.dsl.DatePath; +import com.querydsl.core.types.dsl.DateTimePath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.core.types.dsl.TimePath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SAnimal_ is a Querydsl query type for SAnimal_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SAnimal_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 2052848731; + + public static final SAnimal_ animal_ = new SAnimal_("animal_"); + + public final BooleanPath alive = createBoolean("alive"); + + public final DateTimePath birthdate = + createDateTime("birthdate", java.sql.Timestamp.class); + + public final NumberPath bodyweight = createNumber("bodyweight", Double.class); + + public final NumberPath breed = createNumber("breed", Integer.class); + + public final NumberPath color = createNumber("color", Integer.class); + + public final DatePath datefield = createDate("datefield", java.sql.Date.class); + + public final StringPath dtype = createString("dtype"); + + public final NumberPath eyecolor = createNumber("eyecolor", Integer.class); + + public final NumberPath floatproperty = createNumber("floatproperty", Float.class); + + public final NumberPath id = createNumber("id", Integer.class); + + public final NumberPath mateId = createNumber("mateId", Integer.class); + + public final StringPath name = createString("name"); + + public final TimePath timefield = createTime("timefield", java.sql.Time.class); + + public final NumberPath toes = createNumber("toes", Integer.class); + + public final NumberPath weight = createNumber("weight", Integer.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey animal_MATEIDFK = + createForeignKey(mateId, "ID"); + + public final com.querydsl.sql.ForeignKey _animal_MATEIDFK = + createInvForeignKey(id, "MATE_ID"); + + public final com.querydsl.sql.ForeignKey _kittensCatIdFK = + createInvForeignKey(id, "cat_id"); + + public final com.querydsl.sql.ForeignKey _kittensKittenIdFK = + createInvForeignKey(id, "kitten_id"); + + public final com.querydsl.sql.ForeignKey _kittensSetCatIdFK = + createInvForeignKey(id, "cat_id"); + + public final com.querydsl.sql.ForeignKey _kittensSetKittenIdFK = + createInvForeignKey(id, "kitten_id"); + + public SAnimal_(String variable) { + super(SAnimal_.class, forVariable(variable), "null", "animal_"); + addMetadata(); + } + + public SAnimal_(String variable, String schema, String table) { + super(SAnimal_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SAnimal_(String variable, String schema) { + super(SAnimal_.class, forVariable(variable), schema, "animal_"); + addMetadata(); + } + + public SAnimal_(Path path) { + super(path.getType(), path.getMetadata(), "null", "animal_"); + addMetadata(); + } + + public SAnimal_(PathMetadata metadata) { + super(SAnimal_.class, metadata, "null", "animal_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata(alive, ColumnMetadata.named("ALIVE").withIndex(3).ofType(Types.BIT).withSize(1)); + addMetadata( + birthdate, + ColumnMetadata.named("BIRTHDATE").withIndex(4).ofType(Types.TIMESTAMP).withSize(19)); + addMetadata( + bodyweight, + ColumnMetadata.named("BODYWEIGHT").withIndex(5).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + breed, ColumnMetadata.named("BREED").withIndex(13).ofType(Types.INTEGER).withSize(10)); + addMetadata( + color, ColumnMetadata.named("COLOR").withIndex(6).ofType(Types.INTEGER).withSize(10)); + addMetadata( + datefield, ColumnMetadata.named("DATEFIELD").withIndex(7).ofType(Types.DATE).withSize(10)); + addMetadata( + dtype, ColumnMetadata.named("DTYPE").withIndex(2).ofType(Types.VARCHAR).withSize(31)); + addMetadata( + eyecolor, + ColumnMetadata.named("EYECOLOR").withIndex(14).ofType(Types.INTEGER).withSize(10)); + addMetadata( + floatproperty, + ColumnMetadata.named("FLOATPROPERTY").withIndex(8).ofType(Types.REAL).withSize(12)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata( + mateId, ColumnMetadata.named("MATE_ID").withIndex(15).ofType(Types.INTEGER).withSize(10)); + addMetadata( + name, ColumnMetadata.named("NAME").withIndex(9).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + timefield, ColumnMetadata.named("TIMEFIELD").withIndex(10).ofType(Types.TIME).withSize(8)); + addMetadata( + toes, ColumnMetadata.named("TOES").withIndex(11).ofType(Types.INTEGER).withSize(10)); + addMetadata( + weight, ColumnMetadata.named("WEIGHT").withIndex(12).ofType(Types.INTEGER).withSize(10)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SAuditlog_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SAuditlog_.java new file mode 100644 index 0000000000..2c907fb8b8 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SAuditlog_.java @@ -0,0 +1,60 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SAuditlog_ is a Querydsl query type for SAuditlog_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SAuditlog_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 472909934; + + public static final SAuditlog_ auditlog_ = new SAuditlog_("auditlog_"); + + public final NumberPath id = createNumber("id", Integer.class); + + public final NumberPath itemId = createNumber("itemId", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey auditlog_ITEMIDFK = + createForeignKey(itemId, "ID"); + + public SAuditlog_(String variable) { + super(SAuditlog_.class, forVariable(variable), "null", "auditlog_"); + addMetadata(); + } + + public SAuditlog_(String variable, String schema, String table) { + super(SAuditlog_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SAuditlog_(String variable, String schema) { + super(SAuditlog_.class, forVariable(variable), schema, "auditlog_"); + addMetadata(); + } + + public SAuditlog_(Path path) { + super(path.getType(), path.getMetadata(), "null", "auditlog_"); + addMetadata(); + } + + public SAuditlog_(PathMetadata metadata) { + super(SAuditlog_.class, metadata, "null", "auditlog_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata( + itemId, ColumnMetadata.named("ITEM_ID").withIndex(2).ofType(Types.BIGINT).withSize(19)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SAuthor_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SAuthor_.java new file mode 100644 index 0000000000..278bea5c96 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SAuthor_.java @@ -0,0 +1,61 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SAuthor_ is a Querydsl query type for SAuthor_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SAuthor_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -2031691092; + + public static final SAuthor_ author_ = new SAuthor_("author_"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath name = createString("name"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _book_AUTHORIDFK = + createInvForeignKey(id, "AUTHOR_ID"); + + public SAuthor_(String variable) { + super(SAuthor_.class, forVariable(variable), "null", "author_"); + addMetadata(); + } + + public SAuthor_(String variable, String schema, String table) { + super(SAuthor_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SAuthor_(String variable, String schema) { + super(SAuthor_.class, forVariable(variable), schema, "author_"); + addMetadata(); + } + + public SAuthor_(Path path) { + super(path.getType(), path.getMetadata(), "null", "author_"); + addMetadata(); + } + + public SAuthor_(PathMetadata metadata) { + super(SAuthor_.class, metadata, "null", "author_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + name, ColumnMetadata.named("NAME").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SBar_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SBar_.java new file mode 100644 index 0000000000..1a4d60997b --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SBar_.java @@ -0,0 +1,57 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DatePath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SBar_ is a Querydsl query type for SBar_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SBar_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1493110580; + + public static final SBar_ bar_ = new SBar_("bar_"); + + public final DatePath date = createDate("date", java.sql.Date.class); + + public final NumberPath id = createNumber("id", Integer.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public SBar_(String variable) { + super(SBar_.class, forVariable(variable), "null", "bar_"); + addMetadata(); + } + + public SBar_(String variable, String schema, String table) { + super(SBar_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SBar_(String variable, String schema) { + super(SBar_.class, forVariable(variable), schema, "bar_"); + addMetadata(); + } + + public SBar_(Path path) { + super(path.getType(), path.getMetadata(), "null", "bar_"); + addMetadata(); + } + + public SBar_(PathMetadata metadata) { + super(SBar_.class, metadata, "null", "bar_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata(date, ColumnMetadata.named("DATE").withIndex(2).ofType(Types.DATE).withSize(10)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SBookBookmarks.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SBookBookmarks.java new file mode 100644 index 0000000000..da813fc0da --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SBookBookmarks.java @@ -0,0 +1,76 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import java.util.Arrays; +import javax.annotation.processing.Generated; + +/** SBookBookmarks is a Querydsl query type for SBookBookmarks */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SBookBookmarks extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1405496716; + + public static final SBookBookmarks bookBookmarks = new SBookBookmarks("book_bookmarks"); + + public final NumberPath bookidIdentity = createNumber("bookidIdentity", Long.class); + + public final NumberPath bookMarksORDER = createNumber("bookMarksORDER", Integer.class); + + public final StringPath comment = createString("comment"); + + public final NumberPath libraryIdentity = createNumber("libraryIdentity", Long.class); + + public final NumberPath page = createNumber("page", Long.class); + + public final com.querydsl.sql.ForeignKey bookBookmarksBOOKIDIDENTITYFK = + createForeignKey( + Arrays.asList(bookidIdentity, libraryIdentity), + Arrays.asList("BOOKID_IDENTITY", "LIBRARY_IDENTITY")); + + public SBookBookmarks(String variable) { + super(SBookBookmarks.class, forVariable(variable), "null", "book_bookmarks"); + addMetadata(); + } + + public SBookBookmarks(String variable, String schema, String table) { + super(SBookBookmarks.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SBookBookmarks(String variable, String schema) { + super(SBookBookmarks.class, forVariable(variable), schema, "book_bookmarks"); + addMetadata(); + } + + public SBookBookmarks(Path path) { + super(path.getType(), path.getMetadata(), "null", "book_bookmarks"); + addMetadata(); + } + + public SBookBookmarks(PathMetadata metadata) { + super(SBookBookmarks.class, metadata, "null", "book_bookmarks"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + bookidIdentity, + ColumnMetadata.named("BOOKID_IDENTITY").withIndex(4).ofType(Types.BIGINT).withSize(19)); + addMetadata( + bookMarksORDER, + ColumnMetadata.named("bookMarks_ORDER").withIndex(5).ofType(Types.INTEGER).withSize(10)); + addMetadata( + comment, ColumnMetadata.named("COMMENT").withIndex(1).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + libraryIdentity, + ColumnMetadata.named("LIBRARY_IDENTITY").withIndex(3).ofType(Types.BIGINT).withSize(19)); + addMetadata(page, ColumnMetadata.named("PAGE").withIndex(2).ofType(Types.BIGINT).withSize(19)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SBook_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SBook_.java new file mode 100644 index 0000000000..00137cc6df --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SBook_.java @@ -0,0 +1,69 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SBook_ is a Querydsl query type for SBook_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SBook_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -957797618; + + public static final SBook_ book_ = new SBook_("book_"); + + public final NumberPath authorId = createNumber("authorId", Long.class); + + public final StringPath dtype = createString("dtype"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath title = createString("title"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey book_AUTHORIDFK = + createForeignKey(authorId, "ID"); + + public SBook_(String variable) { + super(SBook_.class, forVariable(variable), "null", "book_"); + addMetadata(); + } + + public SBook_(String variable, String schema, String table) { + super(SBook_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SBook_(String variable, String schema) { + super(SBook_.class, forVariable(variable), schema, "book_"); + addMetadata(); + } + + public SBook_(Path path) { + super(path.getType(), path.getMetadata(), "null", "book_"); + addMetadata(); + } + + public SBook_(PathMetadata metadata) { + super(SBook_.class, metadata, "null", "book_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + authorId, ColumnMetadata.named("AUTHOR_ID").withIndex(4).ofType(Types.BIGINT).withSize(19)); + addMetadata( + dtype, ColumnMetadata.named("DTYPE").withIndex(2).ofType(Types.VARCHAR).withSize(31)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + title, ColumnMetadata.named("TITLE").withIndex(3).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SBookid_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SBookid_.java new file mode 100644 index 0000000000..f046aceb4e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SBookid_.java @@ -0,0 +1,57 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SBookid_ is a Querydsl query type for SBookid_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SBookid_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -1320496749; + + public static final SBookid_ bookid_ = new SBookid_("bookid_"); + + public final NumberPath identity = createNumber("identity", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(identity); + + public final com.querydsl.sql.ForeignKey _bookversion_BOOKIDIDENTITYFK = + createInvForeignKey(identity, "BOOKID_IDENTITY"); + + public SBookid_(String variable) { + super(SBookid_.class, forVariable(variable), "null", "bookid_"); + addMetadata(); + } + + public SBookid_(String variable, String schema, String table) { + super(SBookid_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SBookid_(String variable, String schema) { + super(SBookid_.class, forVariable(variable), schema, "bookid_"); + addMetadata(); + } + + public SBookid_(Path path) { + super(path.getType(), path.getMetadata(), "null", "bookid_"); + addMetadata(); + } + + public SBookid_(PathMetadata metadata) { + super(SBookid_.class, metadata, "null", "bookid_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + identity, + ColumnMetadata.named("IDENTITY").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SBookversion_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SBookversion_.java new file mode 100644 index 0000000000..de5461c1b0 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SBookversion_.java @@ -0,0 +1,90 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import java.util.Arrays; +import javax.annotation.processing.Generated; + +/** SBookversion_ is a Querydsl query type for SBookversion_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SBookversion_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -823148296; + + public static final SBookversion_ bookversion_ = new SBookversion_("bookversion_"); + + public final NumberPath bookidIdentity = createNumber("bookidIdentity", Long.class); + + public final StringPath description = createString("description"); + + public final NumberPath libraryIdentity = createNumber("libraryIdentity", Long.class); + + public final StringPath name = createString("name"); + + public final com.querydsl.sql.PrimaryKey primary = + createPrimaryKey(bookidIdentity, libraryIdentity); + + public final com.querydsl.sql.ForeignKey bookversion_BOOKIDIDENTITYFK = + createForeignKey(bookidIdentity, "IDENTITY"); + + public final com.querydsl.sql.ForeignKey bookversion_LIBRARYIDENTITYFK = + createForeignKey(libraryIdentity, "IDENTITY"); + + public final com.querydsl.sql.ForeignKey _bookBookmarksBOOKIDIDENTITYFK = + createInvForeignKey( + Arrays.asList(bookidIdentity, libraryIdentity), + Arrays.asList("BOOKID_IDENTITY", "LIBRARY_IDENTITY")); + + public SBookversion_(String variable) { + super(SBookversion_.class, forVariable(variable), "null", "bookversion_"); + addMetadata(); + } + + public SBookversion_(String variable, String schema, String table) { + super(SBookversion_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SBookversion_(String variable, String schema) { + super(SBookversion_.class, forVariable(variable), schema, "bookversion_"); + addMetadata(); + } + + public SBookversion_(Path path) { + super(path.getType(), path.getMetadata(), "null", "bookversion_"); + addMetadata(); + } + + public SBookversion_(PathMetadata metadata) { + super(SBookversion_.class, metadata, "null", "bookversion_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + bookidIdentity, + ColumnMetadata.named("BOOKID_IDENTITY") + .withIndex(3) + .ofType(Types.BIGINT) + .withSize(19) + .notNull()); + addMetadata( + description, + ColumnMetadata.named("DESCRIPTION").withIndex(1).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + libraryIdentity, + ColumnMetadata.named("LIBRARY_IDENTITY") + .withIndex(4) + .ofType(Types.BIGINT) + .withSize(19) + .notNull()); + addMetadata( + name, ColumnMetadata.named("NAME").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCalendarHOLIDAYS.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCalendarHOLIDAYS.java new file mode 100644 index 0000000000..affeef674e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCalendarHOLIDAYS.java @@ -0,0 +1,67 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DatePath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SCalendarHOLIDAYS is a Querydsl query type for SCalendarHOLIDAYS */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SCalendarHOLIDAYS extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1042099425; + + public static final SCalendarHOLIDAYS CalendarHOLIDAYS = + new SCalendarHOLIDAYS("Calendar_HOLIDAYS"); + + public final NumberPath calendarID = createNumber("calendarID", Integer.class); + + public final DatePath holidays = createDate("holidays", java.sql.Date.class); + + public final StringPath holidaysKey = createString("holidaysKey"); + + public final com.querydsl.sql.ForeignKey calendarHOLIDAYSCalendarIDFK = + createForeignKey(calendarID, "ID"); + + public SCalendarHOLIDAYS(String variable) { + super(SCalendarHOLIDAYS.class, forVariable(variable), "null", "Calendar_HOLIDAYS"); + addMetadata(); + } + + public SCalendarHOLIDAYS(String variable, String schema, String table) { + super(SCalendarHOLIDAYS.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SCalendarHOLIDAYS(String variable, String schema) { + super(SCalendarHOLIDAYS.class, forVariable(variable), schema, "Calendar_HOLIDAYS"); + addMetadata(); + } + + public SCalendarHOLIDAYS(Path path) { + super(path.getType(), path.getMetadata(), "null", "Calendar_HOLIDAYS"); + addMetadata(); + } + + public SCalendarHOLIDAYS(PathMetadata metadata) { + super(SCalendarHOLIDAYS.class, metadata, "null", "Calendar_HOLIDAYS"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + calendarID, + ColumnMetadata.named("Calendar_ID").withIndex(1).ofType(Types.INTEGER).withSize(10)); + addMetadata( + holidays, ColumnMetadata.named("HOLIDAYS").withIndex(2).ofType(Types.DATE).withSize(10)); + addMetadata( + holidaysKey, + ColumnMetadata.named("holidays_key").withIndex(3).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCalendar_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCalendar_.java new file mode 100644 index 0000000000..11f6e6b0a5 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCalendar_.java @@ -0,0 +1,59 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SCalendar_ is a Querydsl query type for SCalendar_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SCalendar_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -953714343; + + public static final SCalendar_ calendar_ = new SCalendar_("calendar_"); + + public final NumberPath id = createNumber("id", Integer.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _calendarHOLIDAYSCalendarIDFK = + createInvForeignKey(id, "Calendar_ID"); + + public final com.querydsl.sql.ForeignKey _nationality_CALENDARIDFK = + createInvForeignKey(id, "CALENDAR_ID"); + + public SCalendar_(String variable) { + super(SCalendar_.class, forVariable(variable), "null", "calendar_"); + addMetadata(); + } + + public SCalendar_(String variable, String schema, String table) { + super(SCalendar_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SCalendar_(String variable, String schema) { + super(SCalendar_.class, forVariable(variable), schema, "calendar_"); + addMetadata(); + } + + public SCalendar_(Path path) { + super(path.getType(), path.getMetadata(), "null", "calendar_"); + addMetadata(); + } + + public SCalendar_(PathMetadata metadata) { + super(SCalendar_.class, metadata, "null", "calendar_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCatalog_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCatalog_.java new file mode 100644 index 0000000000..9cd3946afd --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCatalog_.java @@ -0,0 +1,63 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DatePath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SCatalog_ is a Querydsl query type for SCatalog_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SCatalog_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 55977966; + + public static final SCatalog_ catalog_ = new SCatalog_("catalog_"); + + public final DatePath effectivedate = + createDate("effectivedate", java.sql.Date.class); + + public final NumberPath id = createNumber("id", Integer.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _catalog_price_CatalogIDFK = + createInvForeignKey(id, "Catalog_ID"); + + public SCatalog_(String variable) { + super(SCatalog_.class, forVariable(variable), "null", "catalog_"); + addMetadata(); + } + + public SCatalog_(String variable, String schema, String table) { + super(SCatalog_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SCatalog_(String variable, String schema) { + super(SCatalog_.class, forVariable(variable), schema, "catalog_"); + addMetadata(); + } + + public SCatalog_(Path path) { + super(path.getType(), path.getMetadata(), "null", "catalog_"); + addMetadata(); + } + + public SCatalog_(PathMetadata metadata) { + super(SCatalog_.class, metadata, "null", "catalog_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + effectivedate, + ColumnMetadata.named("EFFECTIVEDATE").withIndex(2).ofType(Types.DATE).withSize(10)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCatalog_price_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCatalog_price_.java new file mode 100644 index 0000000000..8a7f37e2f6 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCatalog_price_.java @@ -0,0 +1,70 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SCatalog_price_ is a Querydsl query type for SCatalog_price_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SCatalog_price_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -1317112412; + + public static final SCatalog_price_ catalog_price_ = new SCatalog_price_("catalog__price_"); + + public final NumberPath catalogID = createNumber("catalogID", Integer.class); + + public final NumberPath pricesID = createNumber("pricesID", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = + createPrimaryKey(catalogID, pricesID); + + public final com.querydsl.sql.ForeignKey catalog_price_CatalogIDFK = + createForeignKey(catalogID, "ID"); + + public final com.querydsl.sql.ForeignKey catalog_price_pricesIDFK = + createForeignKey(pricesID, "ID"); + + public SCatalog_price_(String variable) { + super(SCatalog_price_.class, forVariable(variable), "null", "catalog__price_"); + addMetadata(); + } + + public SCatalog_price_(String variable, String schema, String table) { + super(SCatalog_price_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SCatalog_price_(String variable, String schema) { + super(SCatalog_price_.class, forVariable(variable), schema, "catalog__price_"); + addMetadata(); + } + + public SCatalog_price_(Path path) { + super(path.getType(), path.getMetadata(), "null", "catalog__price_"); + addMetadata(); + } + + public SCatalog_price_(PathMetadata metadata) { + super(SCatalog_price_.class, metadata, "null", "catalog__price_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + catalogID, + ColumnMetadata.named("Catalog_ID") + .withIndex(1) + .ofType(Types.INTEGER) + .withSize(10) + .notNull()); + addMetadata( + pricesID, + ColumnMetadata.named("prices_ID").withIndex(2).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCategory_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCategory_.java new file mode 100644 index 0000000000..5c08dd9828 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCategory_.java @@ -0,0 +1,113 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DateTimePath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SCategory_ is a Querydsl query type for SCategory_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SCategory_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1845227417; + + public static final SCategory_ category_ = new SCategory_("category_"); + + public final StringPath categorydescription = createString("categorydescription"); + + public final StringPath categoryname = createString("categoryname"); + + public final NumberPath createdby = createNumber("createdby", Double.class); + + public final DateTimePath creationdate = + createDateTime("creationdate", java.sql.Timestamp.class); + + public final DateTimePath deletedate = + createDateTime("deletedate", java.sql.Timestamp.class); + + public final NumberPath deletedby = createNumber("deletedby", Double.class); + + public final NumberPath id = createNumber("id", Long.class); + + public final DateTimePath modificationdate = + createDateTime("modificationdate", java.sql.Timestamp.class); + + public final NumberPath modifiedby = createNumber("modifiedby", Double.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _category_category_childIdFK = + createInvForeignKey(id, "childId"); + + public final com.querydsl.sql.ForeignKey _category_category_parentIdFK = + createInvForeignKey(id, "parentId"); + + public final com.querydsl.sql.ForeignKey + _category_categoryprop_CategoryIDFK = createInvForeignKey(id, "Category_ID"); + + public final com.querydsl.sql.ForeignKey + _userprop_category_childCategoriesIDFK = createInvForeignKey(id, "childCategories_ID"); + + public SCategory_(String variable) { + super(SCategory_.class, forVariable(variable), "null", "category_"); + addMetadata(); + } + + public SCategory_(String variable, String schema, String table) { + super(SCategory_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SCategory_(String variable, String schema) { + super(SCategory_.class, forVariable(variable), schema, "category_"); + addMetadata(); + } + + public SCategory_(Path path) { + super(path.getType(), path.getMetadata(), "null", "category_"); + addMetadata(); + } + + public SCategory_(PathMetadata metadata) { + super(SCategory_.class, metadata, "null", "category_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + categorydescription, + ColumnMetadata.named("CATEGORYDESCRIPTION") + .withIndex(2) + .ofType(Types.VARCHAR) + .withSize(255)); + addMetadata( + categoryname, + ColumnMetadata.named("CATEGORYNAME").withIndex(3).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + createdby, + ColumnMetadata.named("CREATEDBY").withIndex(4).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + creationdate, + ColumnMetadata.named("CREATIONDATE").withIndex(5).ofType(Types.TIMESTAMP).withSize(19)); + addMetadata( + deletedate, + ColumnMetadata.named("DELETEDATE").withIndex(6).ofType(Types.TIMESTAMP).withSize(19)); + addMetadata( + deletedby, + ColumnMetadata.named("DELETEDBY").withIndex(7).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + modificationdate, + ColumnMetadata.named("MODIFICATIONDATE").withIndex(8).ofType(Types.TIMESTAMP).withSize(19)); + addMetadata( + modifiedby, + ColumnMetadata.named("MODIFIEDBY").withIndex(9).ofType(Types.DOUBLE).withSize(22)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCategory_category_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCategory_category_.java new file mode 100644 index 0000000000..a55d2ceea9 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCategory_category_.java @@ -0,0 +1,67 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SCategory_category_ is a Querydsl query type for SCategory_category_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SCategory_category_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 171601832; + + public static final SCategory_category_ category_category_ = + new SCategory_category_("category__category_"); + + public final NumberPath childId = createNumber("childId", Long.class); + + public final NumberPath parentId = createNumber("parentId", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = + createPrimaryKey(childId, parentId); + + public final com.querydsl.sql.ForeignKey category_category_childIdFK = + createForeignKey(childId, "ID"); + + public final com.querydsl.sql.ForeignKey category_category_parentIdFK = + createForeignKey(parentId, "ID"); + + public SCategory_category_(String variable) { + super(SCategory_category_.class, forVariable(variable), "null", "category__category_"); + addMetadata(); + } + + public SCategory_category_(String variable, String schema, String table) { + super(SCategory_category_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SCategory_category_(String variable, String schema) { + super(SCategory_category_.class, forVariable(variable), schema, "category__category_"); + addMetadata(); + } + + public SCategory_category_(Path path) { + super(path.getType(), path.getMetadata(), "null", "category__category_"); + addMetadata(); + } + + public SCategory_category_(PathMetadata metadata) { + super(SCategory_category_.class, metadata, "null", "category__category_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + childId, + ColumnMetadata.named("childId").withIndex(2).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + parentId, + ColumnMetadata.named("parentId").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCategory_categoryprop_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCategory_categoryprop_.java new file mode 100644 index 0000000000..070529d468 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCategory_categoryprop_.java @@ -0,0 +1,76 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SCategory_categoryprop_ is a Querydsl query type for SCategory_categoryprop_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SCategory_categoryprop_ + extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -2083558363; + + public static final SCategory_categoryprop_ category_categoryprop_ = + new SCategory_categoryprop_("category__categoryprop_"); + + public final NumberPath categoryID = createNumber("categoryID", Long.class); + + public final NumberPath propertiesID = createNumber("propertiesID", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = + createPrimaryKey(categoryID, propertiesID); + + public final com.querydsl.sql.ForeignKey category_categoryprop_CategoryIDFK = + createForeignKey(categoryID, "ID"); + + public final com.querydsl.sql.ForeignKey category_categoryprop_propertiesIDFK = + createForeignKey(propertiesID, "ID"); + + public SCategory_categoryprop_(String variable) { + super(SCategory_categoryprop_.class, forVariable(variable), "null", "category__categoryprop_"); + addMetadata(); + } + + public SCategory_categoryprop_(String variable, String schema, String table) { + super(SCategory_categoryprop_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SCategory_categoryprop_(String variable, String schema) { + super(SCategory_categoryprop_.class, forVariable(variable), schema, "category__categoryprop_"); + addMetadata(); + } + + public SCategory_categoryprop_(Path path) { + super(path.getType(), path.getMetadata(), "null", "category__categoryprop_"); + addMetadata(); + } + + public SCategory_categoryprop_(PathMetadata metadata) { + super(SCategory_categoryprop_.class, metadata, "null", "category__categoryprop_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + categoryID, + ColumnMetadata.named("Category_ID") + .withIndex(1) + .ofType(Types.BIGINT) + .withSize(19) + .notNull()); + addMetadata( + propertiesID, + ColumnMetadata.named("properties_ID") + .withIndex(2) + .ofType(Types.BIGINT) + .withSize(19) + .notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCategoryprop_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCategoryprop_.java new file mode 100644 index 0000000000..012583a03b --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCategoryprop_.java @@ -0,0 +1,75 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SCategoryprop_ is a Querydsl query type for SCategoryprop_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SCategoryprop_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 704482198; + + public static final SCategoryprop_ categoryprop_ = new SCategoryprop_("categoryprop_"); + + public final NumberPath categoryid = createNumber("categoryid", Long.class); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath propname = createString("propname"); + + public final StringPath propvalue = createString("propvalue"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey + _category_categoryprop_propertiesIDFK = createInvForeignKey(id, "properties_ID"); + + public final com.querydsl.sql.ForeignKey + _userprop_categoryprop_propertiesIDFK = createInvForeignKey(id, "properties_ID"); + + public SCategoryprop_(String variable) { + super(SCategoryprop_.class, forVariable(variable), "null", "categoryprop_"); + addMetadata(); + } + + public SCategoryprop_(String variable, String schema, String table) { + super(SCategoryprop_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SCategoryprop_(String variable, String schema) { + super(SCategoryprop_.class, forVariable(variable), schema, "categoryprop_"); + addMetadata(); + } + + public SCategoryprop_(Path path) { + super(path.getType(), path.getMetadata(), "null", "categoryprop_"); + addMetadata(); + } + + public SCategoryprop_(PathMetadata metadata) { + super(SCategoryprop_.class, metadata, "null", "categoryprop_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + categoryid, + ColumnMetadata.named("CATEGORYID").withIndex(2).ofType(Types.BIGINT).withSize(19)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + propname, + ColumnMetadata.named("PROPNAME").withIndex(3).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + propvalue, + ColumnMetadata.named("PROPVALUE").withIndex(4).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SChild2.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SChild2.java new file mode 100644 index 0000000000..61a2a0f01a --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SChild2.java @@ -0,0 +1,61 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SChild2 is a Querydsl query type for SChild2 */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SChild2 extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 395031838; + + public static final SChild2 child2 = new SChild2("CHILD2"); + + public final NumberPath id = createNumber("id", Integer.class); + + public final NumberPath parentId = createNumber("parentId", Integer.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey child2ParentIdFk = + createForeignKey(parentId, "ID"); + + public SChild2(String variable) { + super(SChild2.class, forVariable(variable), "null", "CHILD2"); + addMetadata(); + } + + public SChild2(String variable, String schema, String table) { + super(SChild2.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SChild2(String variable, String schema) { + super(SChild2.class, forVariable(variable), schema, "CHILD2"); + addMetadata(); + } + + public SChild2(Path path) { + super(path.getType(), path.getMetadata(), "null", "CHILD2"); + addMetadata(); + } + + public SChild2(PathMetadata metadata) { + super(SChild2.class, metadata, "null", "CHILD2"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata( + parentId, + ColumnMetadata.named("PARENT_ID").withIndex(2).ofType(Types.INTEGER).withSize(10)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCompany_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCompany_.java new file mode 100644 index 0000000000..7e0a451965 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCompany_.java @@ -0,0 +1,92 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SCompany_ is a Querydsl query type for SCompany_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SCompany_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -590751734; + + public static final SCompany_ company_ = new SCompany_("company_"); + + public final NumberPath ceoId = createNumber("ceoId", Integer.class); + + public final NumberPath id = createNumber("id", Integer.class); + + public final StringPath name = createString("name"); + + public final StringPath officialName = createString("officialName"); + + public final NumberPath ratingordinal = createNumber("ratingordinal", Integer.class); + + public final StringPath ratingstring = createString("ratingstring"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey company_CEOIDFK = + createForeignKey(ceoId, "ID"); + + public final com.querydsl.sql.ForeignKey _company_department_CompanyIDFK = + createInvForeignKey(id, "Company_ID"); + + public final com.querydsl.sql.ForeignKey _department_COMPANYIDFK = + createInvForeignKey(id, "COMPANY_ID"); + + public final com.querydsl.sql.ForeignKey _employee_COMPANYIDFK = + createInvForeignKey(id, "COMPANY_ID"); + + public final com.querydsl.sql.ForeignKey _user_COMPANYIDFK = + createInvForeignKey(id, "COMPANY_ID"); + + public SCompany_(String variable) { + super(SCompany_.class, forVariable(variable), "null", "company_"); + addMetadata(); + } + + public SCompany_(String variable, String schema, String table) { + super(SCompany_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SCompany_(String variable, String schema) { + super(SCompany_.class, forVariable(variable), schema, "company_"); + addMetadata(); + } + + public SCompany_(Path path) { + super(path.getType(), path.getMetadata(), "null", "company_"); + addMetadata(); + } + + public SCompany_(PathMetadata metadata) { + super(SCompany_.class, metadata, "null", "company_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + ceoId, ColumnMetadata.named("CEO_ID").withIndex(6).ofType(Types.INTEGER).withSize(10)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata( + name, ColumnMetadata.named("NAME").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + officialName, + ColumnMetadata.named("official_name").withIndex(3).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + ratingordinal, + ColumnMetadata.named("RATINGORDINAL").withIndex(4).ofType(Types.INTEGER).withSize(10)); + addMetadata( + ratingstring, + ColumnMetadata.named("RATINGSTRING").withIndex(5).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCompany_department_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCompany_department_.java new file mode 100644 index 0000000000..011afb8577 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCompany_department_.java @@ -0,0 +1,76 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SCompany_department_ is a Querydsl query type for SCompany_department_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SCompany_department_ + extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -884357885; + + public static final SCompany_department_ company_department_ = + new SCompany_department_("company__department_"); + + public final NumberPath companyID = createNumber("companyID", Integer.class); + + public final NumberPath departmentsID = createNumber("departmentsID", Integer.class); + + public final com.querydsl.sql.PrimaryKey primary = + createPrimaryKey(companyID, departmentsID); + + public final com.querydsl.sql.ForeignKey company_department_CompanyIDFK = + createForeignKey(companyID, "ID"); + + public final com.querydsl.sql.ForeignKey company_department_departmentsIDFK = + createForeignKey(departmentsID, "ID"); + + public SCompany_department_(String variable) { + super(SCompany_department_.class, forVariable(variable), "null", "company__department_"); + addMetadata(); + } + + public SCompany_department_(String variable, String schema, String table) { + super(SCompany_department_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SCompany_department_(String variable, String schema) { + super(SCompany_department_.class, forVariable(variable), schema, "company__department_"); + addMetadata(); + } + + public SCompany_department_(Path path) { + super(path.getType(), path.getMetadata(), "null", "company__department_"); + addMetadata(); + } + + public SCompany_department_(PathMetadata metadata) { + super(SCompany_department_.class, metadata, "null", "company__department_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + companyID, + ColumnMetadata.named("Company_ID") + .withIndex(1) + .ofType(Types.INTEGER) + .withSize(10) + .notNull()); + addMetadata( + departmentsID, + ColumnMetadata.named("departments_ID") + .withIndex(2) + .ofType(Types.INTEGER) + .withSize(10) + .notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCustomer_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCustomer_.java new file mode 100644 index 0000000000..5bcb8ad3d3 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SCustomer_.java @@ -0,0 +1,74 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SCustomer_ is a Querydsl query type for SCustomer_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SCustomer_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1890945209; + + public static final SCustomer_ customer_ = new SCustomer_("customer_"); + + public final NumberPath currentorderId = createNumber("currentorderId", Long.class); + + public final NumberPath id = createNumber("id", Integer.class); + + public final NumberPath nameId = createNumber("nameId", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey customer_CURRENTORDERIDFK = + createForeignKey(currentorderId, "ID"); + + public final com.querydsl.sql.ForeignKey customer_NAMEIDFK = + createForeignKey(nameId, "ID"); + + public final com.querydsl.sql.ForeignKey _order_CUSTOMERIDFK = + createInvForeignKey(id, "CUSTOMER_ID"); + + public final com.querydsl.sql.ForeignKey _store_customer_customersIDFK = + createInvForeignKey(id, "customers_ID"); + + public SCustomer_(String variable) { + super(SCustomer_.class, forVariable(variable), "null", "customer_"); + addMetadata(); + } + + public SCustomer_(String variable, String schema, String table) { + super(SCustomer_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SCustomer_(String variable, String schema) { + super(SCustomer_.class, forVariable(variable), schema, "customer_"); + addMetadata(); + } + + public SCustomer_(Path path) { + super(path.getType(), path.getMetadata(), "null", "customer_"); + addMetadata(); + } + + public SCustomer_(PathMetadata metadata) { + super(SCustomer_.class, metadata, "null", "customer_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + currentorderId, + ColumnMetadata.named("CURRENTORDER_ID").withIndex(2).ofType(Types.BIGINT).withSize(19)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata( + nameId, ColumnMetadata.named("NAME_ID").withIndex(3).ofType(Types.BIGINT).withSize(19)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDateTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDateTest.java new file mode 100644 index 0000000000..75bff9e7be --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDateTest.java @@ -0,0 +1,51 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DatePath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SDateTest is a Querydsl query type for SDateTest */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SDateTest extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1801758184; + + public static final SDateTest dateTest1 = new SDateTest("DATE_TEST"); + + public final DatePath dateTest = createDate("dateTest", java.sql.Date.class); + + public SDateTest(String variable) { + super(SDateTest.class, forVariable(variable), "null", "DATE_TEST"); + addMetadata(); + } + + public SDateTest(String variable, String schema, String table) { + super(SDateTest.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SDateTest(String variable, String schema) { + super(SDateTest.class, forVariable(variable), schema, "DATE_TEST"); + addMetadata(); + } + + public SDateTest(Path path) { + super(path.getType(), path.getMetadata(), "null", "DATE_TEST"); + addMetadata(); + } + + public SDateTest(PathMetadata metadata) { + super(SDateTest.class, metadata, "null", "DATE_TEST"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + dateTest, ColumnMetadata.named("DATE_TEST").withIndex(1).ofType(Types.DATE).withSize(10)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDepartment_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDepartment_.java new file mode 100644 index 0000000000..923758024d --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDepartment_.java @@ -0,0 +1,72 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SDepartment_ is a Querydsl query type for SDepartment_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SDepartment_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -1571818043; + + public static final SDepartment_ department_ = new SDepartment_("department_"); + + public final NumberPath companyId = createNumber("companyId", Integer.class); + + public final NumberPath id = createNumber("id", Integer.class); + + public final StringPath name = createString("name"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey department_COMPANYIDFK = + createForeignKey(companyId, "ID"); + + public final com.querydsl.sql.ForeignKey + _company_department_departmentsIDFK = createInvForeignKey(id, "departments_ID"); + + public final com.querydsl.sql.ForeignKey + _department_employee_DepartmentIDFK = createInvForeignKey(id, "Department_ID"); + + public SDepartment_(String variable) { + super(SDepartment_.class, forVariable(variable), "null", "department_"); + addMetadata(); + } + + public SDepartment_(String variable, String schema, String table) { + super(SDepartment_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SDepartment_(String variable, String schema) { + super(SDepartment_.class, forVariable(variable), schema, "department_"); + addMetadata(); + } + + public SDepartment_(Path path) { + super(path.getType(), path.getMetadata(), "null", "department_"); + addMetadata(); + } + + public SDepartment_(PathMetadata metadata) { + super(SDepartment_.class, metadata, "null", "department_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + companyId, + ColumnMetadata.named("COMPANY_ID").withIndex(3).ofType(Types.INTEGER).withSize(10)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata( + name, ColumnMetadata.named("NAME").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDepartment_employee_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDepartment_employee_.java new file mode 100644 index 0000000000..3846999e34 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDepartment_employee_.java @@ -0,0 +1,76 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SDepartment_employee_ is a Querydsl query type for SDepartment_employee_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SDepartment_employee_ + extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1771153228; + + public static final SDepartment_employee_ department_employee_ = + new SDepartment_employee_("department__employee_"); + + public final NumberPath departmentID = createNumber("departmentID", Integer.class); + + public final NumberPath employeesID = createNumber("employeesID", Integer.class); + + public final com.querydsl.sql.PrimaryKey primary = + createPrimaryKey(departmentID, employeesID); + + public final com.querydsl.sql.ForeignKey department_employee_DepartmentIDFK = + createForeignKey(departmentID, "ID"); + + public final com.querydsl.sql.ForeignKey department_employee_employeesIDFK = + createForeignKey(employeesID, "ID"); + + public SDepartment_employee_(String variable) { + super(SDepartment_employee_.class, forVariable(variable), "null", "department__employee_"); + addMetadata(); + } + + public SDepartment_employee_(String variable, String schema, String table) { + super(SDepartment_employee_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SDepartment_employee_(String variable, String schema) { + super(SDepartment_employee_.class, forVariable(variable), schema, "department__employee_"); + addMetadata(); + } + + public SDepartment_employee_(Path path) { + super(path.getType(), path.getMetadata(), "null", "department__employee_"); + addMetadata(); + } + + public SDepartment_employee_(PathMetadata metadata) { + super(SDepartment_employee_.class, metadata, "null", "department__employee_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + departmentID, + ColumnMetadata.named("Department_ID") + .withIndex(1) + .ofType(Types.INTEGER) + .withSize(10) + .notNull()); + addMetadata( + employeesID, + ColumnMetadata.named("employees_ID") + .withIndex(2) + .ofType(Types.INTEGER) + .withSize(10) + .notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDocument2_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDocument2_.java new file mode 100644 index 0000000000..e03158fb80 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDocument2_.java @@ -0,0 +1,120 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DateTimePath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SDocument2_ is a Querydsl query type for SDocument2_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SDocument2_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -743997616; + + public static final SDocument2_ document2_ = new SDocument2_("document2_"); + + public final NumberPath createdby = createNumber("createdby", Double.class); + + public final DateTimePath creationdate = + createDateTime("creationdate", java.sql.Timestamp.class); + + public final NumberPath deletedby = createNumber("deletedby", Double.class); + + public final DateTimePath deleteddate = + createDateTime("deleteddate", java.sql.Timestamp.class); + + public final StringPath documentbody = createString("documentbody"); + + public final NumberPath documentstatus = createNumber("documentstatus", Double.class); + + public final StringPath documentsummary = createString("documentsummary"); + + public final StringPath documenttitle = createString("documenttitle"); + + public final NumberPath documentversion = createNumber("documentversion", Double.class); + + public final NumberPath entryid = createNumber("entryid", Double.class); + + public final NumberPath id = createNumber("id", Long.class); + + public final DateTimePath modificationdate = + createDateTime("modificationdate", java.sql.Timestamp.class); + + public final NumberPath modifiedby = createNumber("modifiedby", Double.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public SDocument2_(String variable) { + super(SDocument2_.class, forVariable(variable), "null", "document2_"); + addMetadata(); + } + + public SDocument2_(String variable, String schema, String table) { + super(SDocument2_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SDocument2_(String variable, String schema) { + super(SDocument2_.class, forVariable(variable), schema, "document2_"); + addMetadata(); + } + + public SDocument2_(Path path) { + super(path.getType(), path.getMetadata(), "null", "document2_"); + addMetadata(); + } + + public SDocument2_(PathMetadata metadata) { + super(SDocument2_.class, metadata, "null", "document2_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + createdby, + ColumnMetadata.named("CREATEDBY").withIndex(2).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + creationdate, + ColumnMetadata.named("CREATIONDATE").withIndex(3).ofType(Types.TIMESTAMP).withSize(19)); + addMetadata( + deletedby, + ColumnMetadata.named("DELETEDBY").withIndex(4).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + deleteddate, + ColumnMetadata.named("DELETEDDATE").withIndex(5).ofType(Types.TIMESTAMP).withSize(19)); + addMetadata( + documentbody, + ColumnMetadata.named("DOCUMENTBODY").withIndex(6).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + documentstatus, + ColumnMetadata.named("DOCUMENTSTATUS").withIndex(7).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + documentsummary, + ColumnMetadata.named("DOCUMENTSUMMARY").withIndex(8).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + documenttitle, + ColumnMetadata.named("DOCUMENTTITLE").withIndex(9).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + documentversion, + ColumnMetadata.named("DOCUMENTVERSION").withIndex(10).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + entryid, ColumnMetadata.named("ENTRYID").withIndex(11).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + modificationdate, + ColumnMetadata.named("MODIFICATIONDATE") + .withIndex(12) + .ofType(Types.TIMESTAMP) + .withSize(19)); + addMetadata( + modifiedby, + ColumnMetadata.named("MODIFIEDBY").withIndex(13).ofType(Types.DOUBLE).withSize(22)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDocument_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDocument_.java new file mode 100644 index 0000000000..691ced15a1 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDocument_.java @@ -0,0 +1,63 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DatePath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SDocument_ is a Querydsl query type for SDocument_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SDocument_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1222926108; + + public static final SDocument_ document_ = new SDocument_("document_"); + + public final NumberPath id = createNumber("id", Integer.class); + + public final StringPath name = createString("name"); + + public final DatePath validto = createDate("validto", java.sql.Date.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public SDocument_(String variable) { + super(SDocument_.class, forVariable(variable), "null", "document_"); + addMetadata(); + } + + public SDocument_(String variable, String schema, String table) { + super(SDocument_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SDocument_(String variable, String schema) { + super(SDocument_.class, forVariable(variable), schema, "document_"); + addMetadata(); + } + + public SDocument_(Path path) { + super(path.getType(), path.getMetadata(), "null", "document_"); + addMetadata(); + } + + public SDocument_(PathMetadata metadata) { + super(SDocument_.class, metadata, "null", "document_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata( + name, ColumnMetadata.named("NAME").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + validto, ColumnMetadata.named("VALIDTO").withIndex(3).ofType(Types.DATE).withSize(10)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDocumentprop_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDocumentprop_.java new file mode 100644 index 0000000000..99102ffad7 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SDocumentprop_.java @@ -0,0 +1,74 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SDocumentprop_ is a Querydsl query type for SDocumentprop_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SDocumentprop_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1951170969; + + public static final SDocumentprop_ documentprop_ = new SDocumentprop_("documentprop_"); + + public final NumberPath documentid = createNumber("documentid", Double.class); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath propname = createString("propname"); + + public final StringPath propvalue = createString("propvalue"); + + public final StringPath propvaluedetails = createString("propvaluedetails"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public SDocumentprop_(String variable) { + super(SDocumentprop_.class, forVariable(variable), "null", "documentprop_"); + addMetadata(); + } + + public SDocumentprop_(String variable, String schema, String table) { + super(SDocumentprop_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SDocumentprop_(String variable, String schema) { + super(SDocumentprop_.class, forVariable(variable), schema, "documentprop_"); + addMetadata(); + } + + public SDocumentprop_(Path path) { + super(path.getType(), path.getMetadata(), "null", "documentprop_"); + addMetadata(); + } + + public SDocumentprop_(PathMetadata metadata) { + super(SDocumentprop_.class, metadata, "null", "documentprop_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + documentid, + ColumnMetadata.named("DOCUMENTID").withIndex(2).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + propname, + ColumnMetadata.named("PROPNAME").withIndex(3).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + propvalue, + ColumnMetadata.named("PROPVALUE").withIndex(4).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + propvaluedetails, + ColumnMetadata.named("PROPVALUEDETAILS").withIndex(5).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SEmployee.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SEmployee.java new file mode 100644 index 0000000000..b727da2001 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SEmployee.java @@ -0,0 +1,88 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DatePath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.core.types.dsl.TimePath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SEmployee is a Querydsl query type for SEmployee */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SEmployee extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1202481974; + + public static final SEmployee employee = new SEmployee("EMPLOYEE"); + + public final DatePath datefield = createDate("datefield", java.sql.Date.class); + + public final StringPath firstname = createString("firstname"); + + public final NumberPath id = createNumber("id", Integer.class); + + public final StringPath lastname = createString("lastname"); + + public final NumberPath salary = createNumber("salary", Long.class); + + public final NumberPath superiorId = createNumber("superiorId", Integer.class); + + public final TimePath timefield = createTime("timefield", java.sql.Time.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey superiorFk = + createForeignKey(superiorId, "ID"); + + public final com.querydsl.sql.ForeignKey _superiorFk = + createInvForeignKey(id, "SUPERIOR_ID"); + + public SEmployee(String variable) { + super(SEmployee.class, forVariable(variable), "null", "EMPLOYEE"); + addMetadata(); + } + + public SEmployee(String variable, String schema, String table) { + super(SEmployee.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SEmployee(String variable, String schema) { + super(SEmployee.class, forVariable(variable), schema, "EMPLOYEE"); + addMetadata(); + } + + public SEmployee(Path path) { + super(path.getType(), path.getMetadata(), "null", "EMPLOYEE"); + addMetadata(); + } + + public SEmployee(PathMetadata metadata) { + super(SEmployee.class, metadata, "null", "EMPLOYEE"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + datefield, ColumnMetadata.named("DATEFIELD").withIndex(5).ofType(Types.DATE).withSize(10)); + addMetadata( + firstname, + ColumnMetadata.named("FIRSTNAME").withIndex(2).ofType(Types.VARCHAR).withSize(50)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata( + lastname, ColumnMetadata.named("LASTNAME").withIndex(3).ofType(Types.VARCHAR).withSize(50)); + addMetadata( + salary, ColumnMetadata.named("SALARY").withIndex(4).ofType(Types.DECIMAL).withSize(10)); + addMetadata( + superiorId, + ColumnMetadata.named("SUPERIOR_ID").withIndex(7).ofType(Types.INTEGER).withSize(10)); + addMetadata( + timefield, ColumnMetadata.named("TIMEFIELD").withIndex(6).ofType(Types.TIME).withSize(8)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SEmployeeJOBFUNCTIONS.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SEmployeeJOBFUNCTIONS.java new file mode 100644 index 0000000000..a4701b4089 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SEmployeeJOBFUNCTIONS.java @@ -0,0 +1,63 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SEmployeeJOBFUNCTIONS is a Querydsl query type for SEmployeeJOBFUNCTIONS */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SEmployeeJOBFUNCTIONS + extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -40205644; + + public static final SEmployeeJOBFUNCTIONS EmployeeJOBFUNCTIONS = + new SEmployeeJOBFUNCTIONS("Employee_JOBFUNCTIONS"); + + public final NumberPath employeeID = createNumber("employeeID", Integer.class); + + public final StringPath jobfunction = createString("jobfunction"); + + public final com.querydsl.sql.ForeignKey employeeJOBFUNCTIONSEmployeeIDFK = + createForeignKey(employeeID, "ID"); + + public SEmployeeJOBFUNCTIONS(String variable) { + super(SEmployeeJOBFUNCTIONS.class, forVariable(variable), "null", "Employee_JOBFUNCTIONS"); + addMetadata(); + } + + public SEmployeeJOBFUNCTIONS(String variable, String schema, String table) { + super(SEmployeeJOBFUNCTIONS.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SEmployeeJOBFUNCTIONS(String variable, String schema) { + super(SEmployeeJOBFUNCTIONS.class, forVariable(variable), schema, "Employee_JOBFUNCTIONS"); + addMetadata(); + } + + public SEmployeeJOBFUNCTIONS(Path path) { + super(path.getType(), path.getMetadata(), "null", "Employee_JOBFUNCTIONS"); + addMetadata(); + } + + public SEmployeeJOBFUNCTIONS(PathMetadata metadata) { + super(SEmployeeJOBFUNCTIONS.class, metadata, "null", "Employee_JOBFUNCTIONS"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + employeeID, + ColumnMetadata.named("Employee_ID").withIndex(1).ofType(Types.INTEGER).withSize(10)); + addMetadata( + jobfunction, + ColumnMetadata.named("jobfunction").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SEmployee_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SEmployee_.java new file mode 100644 index 0000000000..23b6761476 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SEmployee_.java @@ -0,0 +1,88 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SEmployee_ is a Querydsl query type for SEmployee_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SEmployee_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -1377764375; + + public static final SEmployee_ employee_ = new SEmployee_("employee_"); + + public final NumberPath companyId = createNumber("companyId", Integer.class); + + public final StringPath firstname = createString("firstname"); + + public final NumberPath id = createNumber("id", Integer.class); + + public final StringPath lastname = createString("lastname"); + + public final NumberPath userId = createNumber("userId", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey employee_COMPANYIDFK = + createForeignKey(companyId, "ID"); + + public final com.querydsl.sql.ForeignKey employee_USERIDFK = + createForeignKey(userId, "ID"); + + public final com.querydsl.sql.ForeignKey + _employeeJOBFUNCTIONSEmployeeIDFK = createInvForeignKey(id, "Employee_ID"); + + public final com.querydsl.sql.ForeignKey _company_CEOIDFK = + createInvForeignKey(id, "CEO_ID"); + + public final com.querydsl.sql.ForeignKey + _department_employee_employeesIDFK = createInvForeignKey(id, "employees_ID"); + + public SEmployee_(String variable) { + super(SEmployee_.class, forVariable(variable), "null", "employee_"); + addMetadata(); + } + + public SEmployee_(String variable, String schema, String table) { + super(SEmployee_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SEmployee_(String variable, String schema) { + super(SEmployee_.class, forVariable(variable), schema, "employee_"); + addMetadata(); + } + + public SEmployee_(Path path) { + super(path.getType(), path.getMetadata(), "null", "employee_"); + addMetadata(); + } + + public SEmployee_(PathMetadata metadata) { + super(SEmployee_.class, metadata, "null", "employee_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + companyId, + ColumnMetadata.named("COMPANY_ID").withIndex(4).ofType(Types.INTEGER).withSize(10)); + addMetadata( + firstname, + ColumnMetadata.named("FIRSTNAME").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata( + lastname, + ColumnMetadata.named("LASTNAME").withIndex(3).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + userId, ColumnMetadata.named("USER_ID").withIndex(5).ofType(Types.BIGINT).withSize(19)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SEntity1.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SEntity1.java new file mode 100644 index 0000000000..d01f882706 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SEntity1.java @@ -0,0 +1,68 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SEntity1 is a Querydsl query type for SEntity1 */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SEntity1 extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1317954342; + + public static final SEntity1 entity1 = new SEntity1("ENTITY1"); + + public final StringPath dtype = createString("dtype"); + + public final NumberPath id = createNumber("id", Integer.class); + + public final StringPath property = createString("property"); + + public final StringPath property2 = createString("property2"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public SEntity1(String variable) { + super(SEntity1.class, forVariable(variable), "null", "ENTITY1"); + addMetadata(); + } + + public SEntity1(String variable, String schema, String table) { + super(SEntity1.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SEntity1(String variable, String schema) { + super(SEntity1.class, forVariable(variable), schema, "ENTITY1"); + addMetadata(); + } + + public SEntity1(Path path) { + super(path.getType(), path.getMetadata(), "null", "ENTITY1"); + addMetadata(); + } + + public SEntity1(PathMetadata metadata) { + super(SEntity1.class, metadata, "null", "ENTITY1"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + dtype, ColumnMetadata.named("DTYPE").withIndex(2).ofType(Types.VARCHAR).withSize(31)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata( + property, + ColumnMetadata.named("PROPERTY").withIndex(3).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + property2, + ColumnMetadata.named("PROPERTY2").withIndex(4).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SEviltype_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SEviltype_.java new file mode 100644 index 0000000000..365d464322 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SEviltype_.java @@ -0,0 +1,191 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SEviltype_ is a Querydsl query type for SEviltype_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SEviltype_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -490303543; + + public static final SEviltype_ eviltype_ = new SEviltype_("eviltype_"); + + public final NumberPath _asc = createNumber("_asc", Integer.class); + + public final NumberPath _desc = createNumber("_desc", Integer.class); + + public final NumberPath getclassId = createNumber("getclassId", Integer.class); + + public final NumberPath getId = createNumber("getId", Integer.class); + + public final NumberPath getmetadataId = createNumber("getmetadataId", Integer.class); + + public final NumberPath gettypeId = createNumber("gettypeId", Integer.class); + + public final NumberPath hashcodeId = createNumber("hashcodeId", Integer.class); + + public final NumberPath id = createNumber("id", Integer.class); + + public final NumberPath isnotnullId = createNumber("isnotnullId", Integer.class); + + public final NumberPath isnullId = createNumber("isnullId", Integer.class); + + public final NumberPath notifyallId = createNumber("notifyallId", Integer.class); + + public final NumberPath notifyId = createNumber("notifyId", Integer.class); + + public final NumberPath tostringId = createNumber("tostringId", Integer.class); + + public final NumberPath waitId = createNumber("waitId", Integer.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey eviltype_GETCLASSIDFK = + createForeignKey(getclassId, "ID"); + + public final com.querydsl.sql.ForeignKey eviltype_GETMETADATAIDFK = + createForeignKey(getmetadataId, "ID"); + + public final com.querydsl.sql.ForeignKey eviltype_GETTYPEIDFK = + createForeignKey(gettypeId, "ID"); + + public final com.querydsl.sql.ForeignKey eviltype_GETIDFK = + createForeignKey(getId, "ID"); + + public final com.querydsl.sql.ForeignKey eviltype_HASHCODEIDFK = + createForeignKey(hashcodeId, "ID"); + + public final com.querydsl.sql.ForeignKey eviltype_ISNOTNULLIDFK = + createForeignKey(isnotnullId, "ID"); + + public final com.querydsl.sql.ForeignKey eviltype_ISNULLIDFK = + createForeignKey(isnullId, "ID"); + + public final com.querydsl.sql.ForeignKey eviltype_NOTIFYALLIDFK = + createForeignKey(notifyallId, "ID"); + + public final com.querydsl.sql.ForeignKey eviltype_NOTIFYIDFK = + createForeignKey(notifyId, "ID"); + + public final com.querydsl.sql.ForeignKey eviltype_TOSTRINGIDFK = + createForeignKey(tostringId, "ID"); + + public final com.querydsl.sql.ForeignKey eviltype_WAITIDFK = + createForeignKey(waitId, "ID"); + + public final com.querydsl.sql.ForeignKey eviltype_AscFK = + createForeignKey(_asc, "ID"); + + public final com.querydsl.sql.ForeignKey eviltype_DescFK = + createForeignKey(_desc, "ID"); + + public final com.querydsl.sql.ForeignKey _eviltype_GETCLASSIDFK = + createInvForeignKey(id, "GETCLASS_ID"); + + public final com.querydsl.sql.ForeignKey _eviltype_GETMETADATAIDFK = + createInvForeignKey(id, "GETMETADATA_ID"); + + public final com.querydsl.sql.ForeignKey _eviltype_GETTYPEIDFK = + createInvForeignKey(id, "GETTYPE_ID"); + + public final com.querydsl.sql.ForeignKey _eviltype_GETIDFK = + createInvForeignKey(id, "GET_ID"); + + public final com.querydsl.sql.ForeignKey _eviltype_HASHCODEIDFK = + createInvForeignKey(id, "HASHCODE_ID"); + + public final com.querydsl.sql.ForeignKey _eviltype_ISNOTNULLIDFK = + createInvForeignKey(id, "ISNOTNULL_ID"); + + public final com.querydsl.sql.ForeignKey _eviltype_ISNULLIDFK = + createInvForeignKey(id, "ISNULL_ID"); + + public final com.querydsl.sql.ForeignKey _eviltype_NOTIFYALLIDFK = + createInvForeignKey(id, "NOTIFYALL_ID"); + + public final com.querydsl.sql.ForeignKey _eviltype_NOTIFYIDFK = + createInvForeignKey(id, "NOTIFY_ID"); + + public final com.querydsl.sql.ForeignKey _eviltype_TOSTRINGIDFK = + createInvForeignKey(id, "TOSTRING_ID"); + + public final com.querydsl.sql.ForeignKey _eviltype_WAITIDFK = + createInvForeignKey(id, "WAIT_ID"); + + public final com.querydsl.sql.ForeignKey _eviltype_AscFK = + createInvForeignKey(id, "_asc"); + + public final com.querydsl.sql.ForeignKey _eviltype_DescFK = + createInvForeignKey(id, "_desc"); + + public SEviltype_(String variable) { + super(SEviltype_.class, forVariable(variable), "null", "eviltype_"); + addMetadata(); + } + + public SEviltype_(String variable, String schema, String table) { + super(SEviltype_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SEviltype_(String variable, String schema) { + super(SEviltype_.class, forVariable(variable), schema, "eviltype_"); + addMetadata(); + } + + public SEviltype_(Path path) { + super(path.getType(), path.getMetadata(), "null", "eviltype_"); + addMetadata(); + } + + public SEviltype_(PathMetadata metadata) { + super(SEviltype_.class, metadata, "null", "eviltype_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata(_asc, ColumnMetadata.named("_asc").withIndex(2).ofType(Types.INTEGER).withSize(10)); + addMetadata( + _desc, ColumnMetadata.named("_desc").withIndex(3).ofType(Types.INTEGER).withSize(10)); + addMetadata( + getclassId, + ColumnMetadata.named("GETCLASS_ID").withIndex(5).ofType(Types.INTEGER).withSize(10)); + addMetadata( + getId, ColumnMetadata.named("GET_ID").withIndex(4).ofType(Types.INTEGER).withSize(10)); + addMetadata( + getmetadataId, + ColumnMetadata.named("GETMETADATA_ID").withIndex(6).ofType(Types.INTEGER).withSize(10)); + addMetadata( + gettypeId, + ColumnMetadata.named("GETTYPE_ID").withIndex(7).ofType(Types.INTEGER).withSize(10)); + addMetadata( + hashcodeId, + ColumnMetadata.named("HASHCODE_ID").withIndex(8).ofType(Types.INTEGER).withSize(10)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata( + isnotnullId, + ColumnMetadata.named("ISNOTNULL_ID").withIndex(9).ofType(Types.INTEGER).withSize(10)); + addMetadata( + isnullId, + ColumnMetadata.named("ISNULL_ID").withIndex(10).ofType(Types.INTEGER).withSize(10)); + addMetadata( + notifyallId, + ColumnMetadata.named("NOTIFYALL_ID").withIndex(12).ofType(Types.INTEGER).withSize(10)); + addMetadata( + notifyId, + ColumnMetadata.named("NOTIFY_ID").withIndex(11).ofType(Types.INTEGER).withSize(10)); + addMetadata( + tostringId, + ColumnMetadata.named("TOSTRING_ID").withIndex(13).ofType(Types.INTEGER).withSize(10)); + addMetadata( + waitId, ColumnMetadata.named("WAIT_ID").withIndex(14).ofType(Types.INTEGER).withSize(10)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SFooNames.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SFooNames.java new file mode 100644 index 0000000000..06195d729a --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SFooNames.java @@ -0,0 +1,58 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SFooNames is a Querydsl query type for SFooNames */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SFooNames extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 368569002; + + public static final SFooNames fooNames = new SFooNames("foo_names"); + + public final NumberPath fooId = createNumber("fooId", Integer.class); + + public final StringPath names = createString("names"); + + public final com.querydsl.sql.ForeignKey fooNamesFooIdFK = createForeignKey(fooId, "ID"); + + public SFooNames(String variable) { + super(SFooNames.class, forVariable(variable), "null", "foo_names"); + addMetadata(); + } + + public SFooNames(String variable, String schema, String table) { + super(SFooNames.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SFooNames(String variable, String schema) { + super(SFooNames.class, forVariable(variable), schema, "foo_names"); + addMetadata(); + } + + public SFooNames(Path path) { + super(path.getType(), path.getMetadata(), "null", "foo_names"); + addMetadata(); + } + + public SFooNames(PathMetadata metadata) { + super(SFooNames.class, metadata, "null", "foo_names"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + fooId, ColumnMetadata.named("foo_id").withIndex(1).ofType(Types.INTEGER).withSize(10)); + addMetadata( + names, ColumnMetadata.named("NAMES").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SFoo_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SFoo_.java new file mode 100644 index 0000000000..e1113a1e47 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SFoo_.java @@ -0,0 +1,65 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DatePath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SFoo_ is a Querydsl query type for SFoo_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SFoo_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1493243105; + + public static final SFoo_ foo_ = new SFoo_("foo_"); + + public final StringPath bar = createString("bar"); + + public final NumberPath id = createNumber("id", Integer.class); + + public final DatePath startdate = createDate("startdate", java.sql.Date.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _fooNamesFooIdFK = + createInvForeignKey(id, "foo_id"); + + public SFoo_(String variable) { + super(SFoo_.class, forVariable(variable), "null", "foo_"); + addMetadata(); + } + + public SFoo_(String variable, String schema, String table) { + super(SFoo_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SFoo_(String variable, String schema) { + super(SFoo_.class, forVariable(variable), schema, "foo_"); + addMetadata(); + } + + public SFoo_(Path path) { + super(path.getType(), path.getMetadata(), "null", "foo_"); + addMetadata(); + } + + public SFoo_(PathMetadata metadata) { + super(SFoo_.class, metadata, "null", "foo_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata(bar, ColumnMetadata.named("BAR").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata( + startdate, ColumnMetadata.named("STARTDATE").withIndex(3).ofType(Types.DATE).withSize(10)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SFormula_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SFormula_.java new file mode 100644 index 0000000000..e54df077d4 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SFormula_.java @@ -0,0 +1,61 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SFormula_ is a Querydsl query type for SFormula_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SFormula_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 483680321; + + public static final SFormula_ formula_ = new SFormula_("formula_"); + + public final NumberPath id = createNumber("id", Integer.class); + + public final NumberPath parameterId = createNumber("parameterId", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey formula_PARAMETERIDFK = + createForeignKey(parameterId, "ID"); + + public SFormula_(String variable) { + super(SFormula_.class, forVariable(variable), "null", "formula_"); + addMetadata(); + } + + public SFormula_(String variable, String schema, String table) { + super(SFormula_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SFormula_(String variable, String schema) { + super(SFormula_.class, forVariable(variable), schema, "formula_"); + addMetadata(); + } + + public SFormula_(Path path) { + super(path.getType(), path.getMetadata(), "null", "formula_"); + addMetadata(); + } + + public SFormula_(PathMetadata metadata) { + super(SFormula_.class, metadata, "null", "formula_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata( + parameterId, + ColumnMetadata.named("PARAMETER_ID").withIndex(2).ofType(Types.BIGINT).withSize(19)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SGeneratedKeys.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SGeneratedKeys.java new file mode 100644 index 0000000000..b0f9364f91 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SGeneratedKeys.java @@ -0,0 +1,57 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SGeneratedKeys is a Querydsl query type for SGeneratedKeys */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SGeneratedKeys extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 2097474715; + + public static final SGeneratedKeys generatedKeys = new SGeneratedKeys("GENERATED_KEYS"); + + public final NumberPath id = createNumber("id", Integer.class); + + public final StringPath name = createString("name"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public SGeneratedKeys(String variable) { + super(SGeneratedKeys.class, forVariable(variable), "null", "GENERATED_KEYS"); + addMetadata(); + } + + public SGeneratedKeys(String variable, String schema, String table) { + super(SGeneratedKeys.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SGeneratedKeys(String variable, String schema) { + super(SGeneratedKeys.class, forVariable(variable), schema, "GENERATED_KEYS"); + addMetadata(); + } + + public SGeneratedKeys(Path path) { + super(path.getType(), path.getMetadata(), "null", "GENERATED_KEYS"); + addMetadata(); + } + + public SGeneratedKeys(PathMetadata metadata) { + super(SGeneratedKeys.class, metadata, "null", "GENERATED_KEYS"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata(name, ColumnMetadata.named("NAME").withIndex(2).ofType(Types.VARCHAR).withSize(30)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SGroup_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SGroup_.java new file mode 100644 index 0000000000..85bfd9cff4 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SGroup_.java @@ -0,0 +1,58 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SGroup_ is a Querydsl query type for SGroup_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SGroup_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 518971464; + + public static final SGroup_ group_ = new SGroup_("group_"); + + public final NumberPath id = createNumber("id", Integer.class); + + public final StringPath name = createString("name"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public SGroup_(String variable) { + super(SGroup_.class, forVariable(variable), "null", "group_"); + addMetadata(); + } + + public SGroup_(String variable, String schema, String table) { + super(SGroup_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SGroup_(String variable, String schema) { + super(SGroup_.class, forVariable(variable), schema, "group_"); + addMetadata(); + } + + public SGroup_(Path path) { + super(path.getType(), path.getMetadata(), "null", "group_"); + addMetadata(); + } + + public SGroup_(PathMetadata metadata) { + super(SGroup_.class, metadata, "null", "group_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata( + name, ColumnMetadata.named("NAME").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SHumanHAIRS.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SHumanHAIRS.java new file mode 100644 index 0000000000..fd7c8f8146 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SHumanHAIRS.java @@ -0,0 +1,58 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SHumanHAIRS is a Querydsl query type for SHumanHAIRS */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SHumanHAIRS extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 188619308; + + public static final SHumanHAIRS HumanHAIRS = new SHumanHAIRS("Human_HAIRS"); + + public final NumberPath hairs = createNumber("hairs", Integer.class); + + public final NumberPath humanID = createNumber("humanID", Long.class); + + public final com.querydsl.sql.ForeignKey humanHAIRSHumanIDFK = + createForeignKey(humanID, "ID"); + + public SHumanHAIRS(String variable) { + super(SHumanHAIRS.class, forVariable(variable), "null", "Human_HAIRS"); + addMetadata(); + } + + public SHumanHAIRS(String variable, String schema, String table) { + super(SHumanHAIRS.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SHumanHAIRS(String variable, String schema) { + super(SHumanHAIRS.class, forVariable(variable), schema, "Human_HAIRS"); + addMetadata(); + } + + public SHumanHAIRS(Path path) { + super(path.getType(), path.getMetadata(), "null", "Human_HAIRS"); + addMetadata(); + } + + public SHumanHAIRS(PathMetadata metadata) { + super(SHumanHAIRS.class, metadata, "null", "Human_HAIRS"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + hairs, ColumnMetadata.named("HAIRS").withIndex(2).ofType(Types.INTEGER).withSize(10)); + addMetadata( + humanID, ColumnMetadata.named("Human_ID").withIndex(1).ofType(Types.BIGINT).withSize(19)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SInheritedproperties_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SInheritedproperties_.java new file mode 100644 index 0000000000..8fa8bfd02d --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SInheritedproperties_.java @@ -0,0 +1,74 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SInheritedproperties_ is a Querydsl query type for SInheritedproperties_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SInheritedproperties_ + extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -515155206; + + public static final SInheritedproperties_ inheritedproperties_ = + new SInheritedproperties_("inheritedproperties_"); + + public final StringPath classproperty = createString("classproperty"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath stringassimple = createString("stringassimple"); + + public final StringPath superclassproperty = createString("superclassproperty"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public SInheritedproperties_(String variable) { + super(SInheritedproperties_.class, forVariable(variable), "null", "inheritedproperties_"); + addMetadata(); + } + + public SInheritedproperties_(String variable, String schema, String table) { + super(SInheritedproperties_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SInheritedproperties_(String variable, String schema) { + super(SInheritedproperties_.class, forVariable(variable), schema, "inheritedproperties_"); + addMetadata(); + } + + public SInheritedproperties_(Path path) { + super(path.getType(), path.getMetadata(), "null", "inheritedproperties_"); + addMetadata(); + } + + public SInheritedproperties_(PathMetadata metadata) { + super(SInheritedproperties_.class, metadata, "null", "inheritedproperties_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + classproperty, + ColumnMetadata.named("CLASSPROPERTY").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + stringassimple, + ColumnMetadata.named("STRINGASSIMPLE").withIndex(3).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + superclassproperty, + ColumnMetadata.named("SUPERCLASSPROPERTY") + .withIndex(4) + .ofType(Types.VARCHAR) + .withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SItem_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SItem_.java new file mode 100644 index 0000000000..35eb066b88 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SItem_.java @@ -0,0 +1,111 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SItem_ is a Querydsl query type for SItem_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SItem_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -951193564; + + public static final SItem_ item_ = new SItem_("item_"); + + public final NumberPath currentstatusId = createNumber("currentstatusId", Long.class); + + public final StringPath dtype = createString("dtype"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath name = createString("name"); + + public final NumberPath paymentstatus = createNumber("paymentstatus", Integer.class); + + public final NumberPath productId = createNumber("productId", Long.class); + + public final NumberPath statusId = createNumber("statusId", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey item_CURRENTSTATUSIDFK = + createForeignKey(currentstatusId, "ID"); + + public final com.querydsl.sql.ForeignKey item_PRODUCTIDFK = + createForeignKey(productId, "ID"); + + public final com.querydsl.sql.ForeignKey item_STATUSIDFK = + createForeignKey(statusId, "ID"); + + public final com.querydsl.sql.ForeignKey _lineItems2LineItemsMapIDFK = + createInvForeignKey(id, "lineItemsMap_ID"); + + public final com.querydsl.sql.ForeignKey _lineItemsLineItemsIDFK = + createInvForeignKey(id, "lineItems_ID"); + + public final com.querydsl.sql.ForeignKey _auditlog_ITEMIDFK = + createInvForeignKey(id, "ITEM_ID"); + + public final com.querydsl.sql.ForeignKey _item_PRODUCTIDFK = + createInvForeignKey(id, "PRODUCT_ID"); + + public final com.querydsl.sql.ForeignKey _item_statuschange_PaymentIDFK = + createInvForeignKey(id, "Payment_ID"); + + public final com.querydsl.sql.ForeignKey _order_item_itemsIDFK = + createInvForeignKey(id, "items_ID"); + + public final com.querydsl.sql.ForeignKey _price_PRODUCTIDFK = + createInvForeignKey(id, "PRODUCT_ID"); + + public SItem_(String variable) { + super(SItem_.class, forVariable(variable), "null", "item_"); + addMetadata(); + } + + public SItem_(String variable, String schema, String table) { + super(SItem_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SItem_(String variable, String schema) { + super(SItem_.class, forVariable(variable), schema, "item_"); + addMetadata(); + } + + public SItem_(Path path) { + super(path.getType(), path.getMetadata(), "null", "item_"); + addMetadata(); + } + + public SItem_(PathMetadata metadata) { + super(SItem_.class, metadata, "null", "item_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + currentstatusId, + ColumnMetadata.named("CURRENTSTATUS_ID").withIndex(6).ofType(Types.BIGINT).withSize(19)); + addMetadata( + dtype, ColumnMetadata.named("DTYPE").withIndex(2).ofType(Types.VARCHAR).withSize(31)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + name, ColumnMetadata.named("NAME").withIndex(4).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + paymentstatus, + ColumnMetadata.named("PAYMENTSTATUS").withIndex(5).ofType(Types.INTEGER).withSize(10)); + addMetadata( + productId, + ColumnMetadata.named("PRODUCT_ID").withIndex(3).ofType(Types.BIGINT).withSize(19)); + addMetadata( + statusId, ColumnMetadata.named("STATUS_ID").withIndex(7).ofType(Types.BIGINT).withSize(19)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SItem_statuschange_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SItem_statuschange_.java new file mode 100644 index 0000000000..69fcbae237 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SItem_statuschange_.java @@ -0,0 +1,75 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SItem_statuschange_ is a Querydsl query type for SItem_statuschange_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SItem_statuschange_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1154189529; + + public static final SItem_statuschange_ item_statuschange_ = + new SItem_statuschange_("item__statuschange_"); + + public final NumberPath paymentID = createNumber("paymentID", Long.class); + + public final NumberPath statusChangesID = createNumber("statusChangesID", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = + createPrimaryKey(paymentID, statusChangesID); + + public final com.querydsl.sql.ForeignKey item_statuschange_PaymentIDFK = + createForeignKey(paymentID, "ID"); + + public final com.querydsl.sql.ForeignKey item_statuschange_statusChangesIDFK = + createForeignKey(statusChangesID, "ID"); + + public SItem_statuschange_(String variable) { + super(SItem_statuschange_.class, forVariable(variable), "null", "item__statuschange_"); + addMetadata(); + } + + public SItem_statuschange_(String variable, String schema, String table) { + super(SItem_statuschange_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SItem_statuschange_(String variable, String schema) { + super(SItem_statuschange_.class, forVariable(variable), schema, "item__statuschange_"); + addMetadata(); + } + + public SItem_statuschange_(Path path) { + super(path.getType(), path.getMetadata(), "null", "item__statuschange_"); + addMetadata(); + } + + public SItem_statuschange_(PathMetadata metadata) { + super(SItem_statuschange_.class, metadata, "null", "item__statuschange_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + paymentID, + ColumnMetadata.named("Payment_ID") + .withIndex(1) + .ofType(Types.BIGINT) + .withSize(19) + .notNull()); + addMetadata( + statusChangesID, + ColumnMetadata.named("statusChanges_ID") + .withIndex(2) + .ofType(Types.BIGINT) + .withSize(19) + .notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SKittens.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SKittens.java new file mode 100644 index 0000000000..775de1012f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SKittens.java @@ -0,0 +1,71 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SKittens is a Querydsl query type for SKittens */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SKittens extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -2089790908; + + public static final SKittens kittens = new SKittens("kittens"); + + public final NumberPath catId = createNumber("catId", Integer.class); + + public final NumberPath ind = createNumber("ind", Integer.class); + + public final NumberPath kittenId = createNumber("kittenId", Integer.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(catId, kittenId); + + public final com.querydsl.sql.ForeignKey kittensCatIdFK = createForeignKey(catId, "ID"); + + public final com.querydsl.sql.ForeignKey kittensKittenIdFK = + createForeignKey(kittenId, "ID"); + + public SKittens(String variable) { + super(SKittens.class, forVariable(variable), "null", "kittens"); + addMetadata(); + } + + public SKittens(String variable, String schema, String table) { + super(SKittens.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SKittens(String variable, String schema) { + super(SKittens.class, forVariable(variable), schema, "kittens"); + addMetadata(); + } + + public SKittens(Path path) { + super(path.getType(), path.getMetadata(), "null", "kittens"); + addMetadata(); + } + + public SKittens(PathMetadata metadata) { + super(SKittens.class, metadata, "null", "kittens"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + catId, + ColumnMetadata.named("cat_id").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata(ind, ColumnMetadata.named("ind").withIndex(3).ofType(Types.INTEGER).withSize(10)); + addMetadata( + kittenId, + ColumnMetadata.named("kitten_id") + .withIndex(2) + .ofType(Types.INTEGER) + .withSize(10) + .notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SKittensSet.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SKittensSet.java new file mode 100644 index 0000000000..c958b3246a --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SKittensSet.java @@ -0,0 +1,69 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SKittensSet is a Querydsl query type for SKittensSet */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SKittensSet extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -1409901698; + + public static final SKittensSet kittensSet = new SKittensSet("kittens_set"); + + public final NumberPath catId = createNumber("catId", Integer.class); + + public final NumberPath kittenId = createNumber("kittenId", Integer.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(catId, kittenId); + + public final com.querydsl.sql.ForeignKey kittensSetCatIdFK = + createForeignKey(catId, "ID"); + + public final com.querydsl.sql.ForeignKey kittensSetKittenIdFK = + createForeignKey(kittenId, "ID"); + + public SKittensSet(String variable) { + super(SKittensSet.class, forVariable(variable), "null", "kittens_set"); + addMetadata(); + } + + public SKittensSet(String variable, String schema, String table) { + super(SKittensSet.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SKittensSet(String variable, String schema) { + super(SKittensSet.class, forVariable(variable), schema, "kittens_set"); + addMetadata(); + } + + public SKittensSet(Path path) { + super(path.getType(), path.getMetadata(), "null", "kittens_set"); + addMetadata(); + } + + public SKittensSet(PathMetadata metadata) { + super(SKittensSet.class, metadata, "null", "kittens_set"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + catId, + ColumnMetadata.named("cat_id").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata( + kittenId, + ColumnMetadata.named("kitten_id") + .withIndex(2) + .ofType(Types.INTEGER) + .withSize(10) + .notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SLibrary_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SLibrary_.java new file mode 100644 index 0000000000..97b67c8ed8 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SLibrary_.java @@ -0,0 +1,57 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SLibrary_ is a Querydsl query type for SLibrary_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SLibrary_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 866514828; + + public static final SLibrary_ library_ = new SLibrary_("library_"); + + public final NumberPath identity = createNumber("identity", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(identity); + + public final com.querydsl.sql.ForeignKey _bookversion_LIBRARYIDENTITYFK = + createInvForeignKey(identity, "LIBRARY_IDENTITY"); + + public SLibrary_(String variable) { + super(SLibrary_.class, forVariable(variable), "null", "library_"); + addMetadata(); + } + + public SLibrary_(String variable, String schema, String table) { + super(SLibrary_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SLibrary_(String variable, String schema) { + super(SLibrary_.class, forVariable(variable), schema, "library_"); + addMetadata(); + } + + public SLibrary_(Path path) { + super(path.getType(), path.getMetadata(), "null", "library_"); + addMetadata(); + } + + public SLibrary_(PathMetadata metadata) { + super(SLibrary_.class, metadata, "null", "library_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + identity, + ColumnMetadata.named("IDENTITY").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SLineItems.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SLineItems.java new file mode 100644 index 0000000000..f0fbe2c220 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SLineItems.java @@ -0,0 +1,74 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SLineItems is a Querydsl query type for SLineItems */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SLineItems extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -1537004380; + + public static final SLineItems LineItems = new SLineItems("LineItems"); + + public final NumberPath _index = createNumber("_index", Integer.class); + + public final NumberPath lineItemsID = createNumber("lineItemsID", Long.class); + + public final NumberPath orderID = createNumber("orderID", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = + createPrimaryKey(orderID, lineItemsID); + + public final com.querydsl.sql.ForeignKey lineItemsOrderIDFK = + createForeignKey(orderID, "ID"); + + public final com.querydsl.sql.ForeignKey lineItemsLineItemsIDFK = + createForeignKey(lineItemsID, "ID"); + + public SLineItems(String variable) { + super(SLineItems.class, forVariable(variable), "null", "LineItems"); + addMetadata(); + } + + public SLineItems(String variable, String schema, String table) { + super(SLineItems.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SLineItems(String variable, String schema) { + super(SLineItems.class, forVariable(variable), schema, "LineItems"); + addMetadata(); + } + + public SLineItems(Path path) { + super(path.getType(), path.getMetadata(), "null", "LineItems"); + addMetadata(); + } + + public SLineItems(PathMetadata metadata) { + super(SLineItems.class, metadata, "null", "LineItems"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + _index, ColumnMetadata.named("_index").withIndex(3).ofType(Types.INTEGER).withSize(10)); + addMetadata( + lineItemsID, + ColumnMetadata.named("lineItems_ID") + .withIndex(2) + .ofType(Types.BIGINT) + .withSize(19) + .notNull()); + addMetadata( + orderID, + ColumnMetadata.named("Order_ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SLineItems2.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SLineItems2.java new file mode 100644 index 0000000000..8a66c4acd0 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SLineItems2.java @@ -0,0 +1,70 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SLineItems2 is a Querydsl query type for SLineItems2 */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SLineItems2 extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -402495474; + + public static final SLineItems2 LineItems2 = new SLineItems2("LineItems2"); + + public final NumberPath lineItemsMapID = createNumber("lineItemsMapID", Long.class); + + public final NumberPath orderID = createNumber("orderID", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = + createPrimaryKey(orderID, lineItemsMapID); + + public final com.querydsl.sql.ForeignKey lineItems2OrderIDFK = + createForeignKey(orderID, "ID"); + + public final com.querydsl.sql.ForeignKey lineItems2LineItemsMapIDFK = + createForeignKey(lineItemsMapID, "ID"); + + public SLineItems2(String variable) { + super(SLineItems2.class, forVariable(variable), "null", "LineItems2"); + addMetadata(); + } + + public SLineItems2(String variable, String schema, String table) { + super(SLineItems2.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SLineItems2(String variable, String schema) { + super(SLineItems2.class, forVariable(variable), schema, "LineItems2"); + addMetadata(); + } + + public SLineItems2(Path path) { + super(path.getType(), path.getMetadata(), "null", "LineItems2"); + addMetadata(); + } + + public SLineItems2(PathMetadata metadata) { + super(SLineItems2.class, metadata, "null", "LineItems2"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + lineItemsMapID, + ColumnMetadata.named("lineItemsMap_ID") + .withIndex(2) + .ofType(Types.BIGINT) + .withSize(19) + .notNull()); + addMetadata( + orderID, + ColumnMetadata.named("Order_ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SLocation_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SLocation_.java new file mode 100644 index 0000000000..9d06ab6690 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SLocation_.java @@ -0,0 +1,61 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SLocation_ is a Querydsl query type for SLocation_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SLocation_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -917806142; + + public static final SLocation_ location_ = new SLocation_("location_"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath name = createString("name"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _store_LOCATIONIDFK = + createInvForeignKey(id, "LOCATION_ID"); + + public SLocation_(String variable) { + super(SLocation_.class, forVariable(variable), "null", "location_"); + addMetadata(); + } + + public SLocation_(String variable, String schema, String table) { + super(SLocation_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SLocation_(String variable, String schema) { + super(SLocation_.class, forVariable(variable), schema, "location_"); + addMetadata(); + } + + public SLocation_(Path path) { + super(path.getType(), path.getMetadata(), "null", "location_"); + addMetadata(); + } + + public SLocation_(PathMetadata metadata) { + super(SLocation_.class, metadata, "null", "location_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + name, ColumnMetadata.named("NAME").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SMammal.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SMammal.java new file mode 100644 index 0000000000..c2bd95dcca --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SMammal.java @@ -0,0 +1,64 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SMammal is a Querydsl query type for SMammal */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SMammal extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 674978791; + + public static final SMammal mammal = new SMammal("MAMMAL"); + + public final StringPath dtype = createString("dtype"); + + public final NumberPath id = createNumber("id", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _humanHAIRSHumanIDFK = + createInvForeignKey(id, "Human_ID"); + + public final com.querydsl.sql.ForeignKey _wORLDMAMMALMammalsIDFK = + createInvForeignKey(id, "mammals_ID"); + + public SMammal(String variable) { + super(SMammal.class, forVariable(variable), "null", "MAMMAL"); + addMetadata(); + } + + public SMammal(String variable, String schema, String table) { + super(SMammal.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SMammal(String variable, String schema) { + super(SMammal.class, forVariable(variable), schema, "MAMMAL"); + addMetadata(); + } + + public SMammal(Path path) { + super(path.getType(), path.getMetadata(), "null", "MAMMAL"); + addMetadata(); + } + + public SMammal(PathMetadata metadata) { + super(SMammal.class, metadata, "null", "MAMMAL"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + dtype, ColumnMetadata.named("DTYPE").withIndex(2).ofType(Types.VARCHAR).withSize(31)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SMyentity.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SMyentity.java new file mode 100644 index 0000000000..5c9dce741a --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SMyentity.java @@ -0,0 +1,65 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SMyentity is a Querydsl query type for SMyentity */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SMyentity extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -287734505; + + public static final SMyentity myentity = new SMyentity("MYENTITY"); + + public final NumberPath attributewithinitproblemId = + createNumber("attributewithinitproblemId", Integer.class); + + public final NumberPath id = createNumber("id", Integer.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey myentityAttributewithinitproblemIdFk = + createForeignKey(attributewithinitproblemId, "ID"); + + public SMyentity(String variable) { + super(SMyentity.class, forVariable(variable), "null", "MYENTITY"); + addMetadata(); + } + + public SMyentity(String variable, String schema, String table) { + super(SMyentity.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SMyentity(String variable, String schema) { + super(SMyentity.class, forVariable(variable), schema, "MYENTITY"); + addMetadata(); + } + + public SMyentity(Path path) { + super(path.getType(), path.getMetadata(), "null", "MYENTITY"); + addMetadata(); + } + + public SMyentity(PathMetadata metadata) { + super(SMyentity.class, metadata, "null", "MYENTITY"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + attributewithinitproblemId, + ColumnMetadata.named("ATTRIBUTEWITHINITPROBLEM_ID") + .withIndex(2) + .ofType(Types.INTEGER) + .withSize(10)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SMyotherentity.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SMyotherentity.java new file mode 100644 index 0000000000..606b113d23 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SMyotherentity.java @@ -0,0 +1,56 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SMyotherentity is a Querydsl query type for SMyotherentity */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SMyotherentity extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -19540417; + + public static final SMyotherentity myotherentity = new SMyotherentity("MYOTHERENTITY"); + + public final NumberPath id = createNumber("id", Integer.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _myentityAttributewithinitproblemIdFk = + createInvForeignKey(id, "ATTRIBUTEWITHINITPROBLEM_ID"); + + public SMyotherentity(String variable) { + super(SMyotherentity.class, forVariable(variable), "null", "MYOTHERENTITY"); + addMetadata(); + } + + public SMyotherentity(String variable, String schema, String table) { + super(SMyotherentity.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SMyotherentity(String variable, String schema) { + super(SMyotherentity.class, forVariable(variable), schema, "MYOTHERENTITY"); + addMetadata(); + } + + public SMyotherentity(Path path) { + super(path.getType(), path.getMetadata(), "null", "MYOTHERENTITY"); + addMetadata(); + } + + public SMyotherentity(PathMetadata metadata) { + super(SMyotherentity.class, metadata, "null", "MYOTHERENTITY"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNameListNAMES.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNameListNAMES.java new file mode 100644 index 0000000000..e8054342ad --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNameListNAMES.java @@ -0,0 +1,60 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SNameListNAMES is a Querydsl query type for SNameListNAMES */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SNameListNAMES extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1866941303; + + public static final SNameListNAMES NameListNAMES = new SNameListNAMES("NameList_NAMES"); + + public final NumberPath nameListID = createNumber("nameListID", Long.class); + + public final StringPath names = createString("names"); + + public final com.querydsl.sql.ForeignKey nameListNAMESNameListIDFK = + createForeignKey(nameListID, "ID"); + + public SNameListNAMES(String variable) { + super(SNameListNAMES.class, forVariable(variable), "null", "NameList_NAMES"); + addMetadata(); + } + + public SNameListNAMES(String variable, String schema, String table) { + super(SNameListNAMES.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SNameListNAMES(String variable, String schema) { + super(SNameListNAMES.class, forVariable(variable), schema, "NameList_NAMES"); + addMetadata(); + } + + public SNameListNAMES(Path path) { + super(path.getType(), path.getMetadata(), "null", "NameList_NAMES"); + addMetadata(); + } + + public SNameListNAMES(PathMetadata metadata) { + super(SNameListNAMES.class, metadata, "null", "NameList_NAMES"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + nameListID, + ColumnMetadata.named("NameList_ID").withIndex(1).ofType(Types.BIGINT).withSize(19)); + addMetadata( + names, ColumnMetadata.named("NAMES").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SName_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SName_.java new file mode 100644 index 0000000000..48e987156f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SName_.java @@ -0,0 +1,72 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SName_ is a Querydsl query type for SName_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SName_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -947134548; + + public static final SName_ name_ = new SName_("name_"); + + public final StringPath firstname = createString("firstname"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath lastname = createString("lastname"); + + public final StringPath nickname = createString("nickname"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _customer_NAMEIDFK = + createInvForeignKey(id, "NAME_ID"); + + public SName_(String variable) { + super(SName_.class, forVariable(variable), "null", "name_"); + addMetadata(); + } + + public SName_(String variable, String schema, String table) { + super(SName_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SName_(String variable, String schema) { + super(SName_.class, forVariable(variable), schema, "name_"); + addMetadata(); + } + + public SName_(Path path) { + super(path.getType(), path.getMetadata(), "null", "name_"); + addMetadata(); + } + + public SName_(PathMetadata metadata) { + super(SName_.class, metadata, "null", "name_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + firstname, + ColumnMetadata.named("FIRSTNAME").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + lastname, + ColumnMetadata.named("LASTNAME").withIndex(3).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + nickname, + ColumnMetadata.named("NICKNAME").withIndex(4).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNamed_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNamed_.java new file mode 100644 index 0000000000..b537c7585b --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNamed_.java @@ -0,0 +1,58 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SNamed_ is a Querydsl query type for SNamed_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SNamed_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 703600334; + + public static final SNamed_ named_ = new SNamed_("named_"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath name = createString("name"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public SNamed_(String variable) { + super(SNamed_.class, forVariable(variable), "null", "named_"); + addMetadata(); + } + + public SNamed_(String variable, String schema, String table) { + super(SNamed_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SNamed_(String variable, String schema) { + super(SNamed_.class, forVariable(variable), schema, "named_"); + addMetadata(); + } + + public SNamed_(Path path) { + super(path.getType(), path.getMetadata(), "null", "named_"); + addMetadata(); + } + + public SNamed_(PathMetadata metadata) { + super(SNamed_.class, metadata, "null", "named_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + name, ColumnMetadata.named("NAME").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNamelist_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNamelist_.java new file mode 100644 index 0000000000..20c3409947 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNamelist_.java @@ -0,0 +1,56 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SNamelist_ is a Querydsl query type for SNamelist_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SNamelist_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1524945998; + + public static final SNamelist_ namelist_ = new SNamelist_("namelist_"); + + public final NumberPath id = createNumber("id", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _nameListNAMESNameListIDFK = + createInvForeignKey(id, "NameList_ID"); + + public SNamelist_(String variable) { + super(SNamelist_.class, forVariable(variable), "null", "namelist_"); + addMetadata(); + } + + public SNamelist_(String variable, String schema, String table) { + super(SNamelist_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SNamelist_(String variable, String schema) { + super(SNamelist_.class, forVariable(variable), schema, "namelist_"); + addMetadata(); + } + + public SNamelist_(Path path) { + super(path.getType(), path.getMetadata(), "null", "namelist_"); + addMetadata(); + } + + public SNamelist_(PathMetadata metadata) { + super(SNamelist_.class, metadata, "null", "namelist_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNationality_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNationality_.java new file mode 100644 index 0000000000..04f8f98f52 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNationality_.java @@ -0,0 +1,64 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SNationality_ is a Querydsl query type for SNationality_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SNationality_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -1959593301; + + public static final SNationality_ nationality_ = new SNationality_("nationality_"); + + public final NumberPath calendarId = createNumber("calendarId", Integer.class); + + public final NumberPath id = createNumber("id", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey nationality_CALENDARIDFK = + createForeignKey(calendarId, "ID"); + + public final com.querydsl.sql.ForeignKey _person_NATIONALITYIDFK = + createInvForeignKey(id, "NATIONALITY_ID"); + + public SNationality_(String variable) { + super(SNationality_.class, forVariable(variable), "null", "nationality_"); + addMetadata(); + } + + public SNationality_(String variable, String schema, String table) { + super(SNationality_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SNationality_(String variable, String schema) { + super(SNationality_.class, forVariable(variable), schema, "nationality_"); + addMetadata(); + } + + public SNationality_(Path path) { + super(path.getType(), path.getMetadata(), "null", "nationality_"); + addMetadata(); + } + + public SNationality_(PathMetadata metadata) { + super(SNationality_.class, metadata, "null", "nationality_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + calendarId, + ColumnMetadata.named("CALENDAR_ID").withIndex(2).ofType(Types.INTEGER).withSize(10)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNumberTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNumberTest.java new file mode 100644 index 0000000000..d80d87fe16 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNumberTest.java @@ -0,0 +1,50 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.BooleanPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SNumberTest is a Querydsl query type for SNumberTest */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SNumberTest extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -321238525; + + public static final SNumberTest numberTest = new SNumberTest("NUMBER_TEST"); + + public final BooleanPath col1 = createBoolean("col1"); + + public SNumberTest(String variable) { + super(SNumberTest.class, forVariable(variable), "null", "NUMBER_TEST"); + addMetadata(); + } + + public SNumberTest(String variable, String schema, String table) { + super(SNumberTest.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SNumberTest(String variable, String schema) { + super(SNumberTest.class, forVariable(variable), schema, "NUMBER_TEST"); + addMetadata(); + } + + public SNumberTest(Path path) { + super(path.getType(), path.getMetadata(), "null", "NUMBER_TEST"); + addMetadata(); + } + + public SNumberTest(PathMetadata metadata) { + super(SNumberTest.class, metadata, "null", "NUMBER_TEST"); + addMetadata(); + } + + public void addMetadata() { + addMetadata(col1, ColumnMetadata.named("col1").withIndex(1).ofType(Types.BIT).withSize(1)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNumeric_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNumeric_.java new file mode 100644 index 0000000000..1a1dcc939d --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SNumeric_.java @@ -0,0 +1,58 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SNumeric_ is a Querydsl query type for SNumeric_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SNumeric_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -1874277510; + + public static final SNumeric_ numeric_ = new SNumeric_("numeric_"); + + public final NumberPath id = createNumber("id", Long.class); + + public final NumberPath value_ = + createNumber("value_", java.math.BigInteger.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public SNumeric_(String variable) { + super(SNumeric_.class, forVariable(variable), "null", "numeric_"); + addMetadata(); + } + + public SNumeric_(String variable, String schema, String table) { + super(SNumeric_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SNumeric_(String variable, String schema) { + super(SNumeric_.class, forVariable(variable), schema, "numeric_"); + addMetadata(); + } + + public SNumeric_(Path path) { + super(path.getType(), path.getMetadata(), "null", "numeric_"); + addMetadata(); + } + + public SNumeric_(PathMetadata metadata) { + super(SNumeric_.class, metadata, "null", "numeric_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + value_, ColumnMetadata.named("value_").withIndex(2).ofType(Types.DECIMAL).withSize(38)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SOrderDELIVEREDITEMINDICES.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SOrderDELIVEREDITEMINDICES.java new file mode 100644 index 0000000000..d9e332884f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SOrderDELIVEREDITEMINDICES.java @@ -0,0 +1,77 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SOrderDELIVEREDITEMINDICES is a Querydsl query type for SOrderDELIVEREDITEMINDICES */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SOrderDELIVEREDITEMINDICES + extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1275589366; + + public static final SOrderDELIVEREDITEMINDICES OrderDELIVEREDITEMINDICES = + new SOrderDELIVEREDITEMINDICES("Order_DELIVEREDITEMINDICES"); + + public final NumberPath _index = createNumber("_index", Integer.class); + + public final NumberPath delivereditemindices = + createNumber("delivereditemindices", Integer.class); + + public final NumberPath orderID = createNumber("orderID", Long.class); + + public final com.querydsl.sql.ForeignKey orderDELIVEREDITEMINDICESOrderIDFK = + createForeignKey(orderID, "ID"); + + public SOrderDELIVEREDITEMINDICES(String variable) { + super( + SOrderDELIVEREDITEMINDICES.class, + forVariable(variable), + "null", + "Order_DELIVEREDITEMINDICES"); + addMetadata(); + } + + public SOrderDELIVEREDITEMINDICES(String variable, String schema, String table) { + super(SOrderDELIVEREDITEMINDICES.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SOrderDELIVEREDITEMINDICES(String variable, String schema) { + super( + SOrderDELIVEREDITEMINDICES.class, + forVariable(variable), + schema, + "Order_DELIVEREDITEMINDICES"); + addMetadata(); + } + + public SOrderDELIVEREDITEMINDICES(Path path) { + super(path.getType(), path.getMetadata(), "null", "Order_DELIVEREDITEMINDICES"); + addMetadata(); + } + + public SOrderDELIVEREDITEMINDICES(PathMetadata metadata) { + super(SOrderDELIVEREDITEMINDICES.class, metadata, "null", "Order_DELIVEREDITEMINDICES"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + _index, ColumnMetadata.named("_index").withIndex(3).ofType(Types.INTEGER).withSize(10)); + addMetadata( + delivereditemindices, + ColumnMetadata.named("DELIVEREDITEMINDICES") + .withIndex(2) + .ofType(Types.INTEGER) + .withSize(10)); + addMetadata( + orderID, ColumnMetadata.named("Order_ID").withIndex(1).ofType(Types.BIGINT).withSize(19)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SOrder_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SOrder_.java new file mode 100644 index 0000000000..9899e46958 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SOrder_.java @@ -0,0 +1,80 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.BooleanPath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SOrder_ is a Querydsl query type for SOrder_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SOrder_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 747661657; + + public static final SOrder_ order_ = new SOrder_("order_"); + + public final NumberPath customerId = createNumber("customerId", Integer.class); + + public final NumberPath id = createNumber("id", Long.class); + + public final BooleanPath paid = createBoolean("paid"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey order_CUSTOMERIDFK = + createForeignKey(customerId, "ID"); + + public final com.querydsl.sql.ForeignKey _lineItems2OrderIDFK = + createInvForeignKey(id, "Order_ID"); + + public final com.querydsl.sql.ForeignKey _lineItemsOrderIDFK = + createInvForeignKey(id, "Order_ID"); + + public final com.querydsl.sql.ForeignKey + _orderDELIVEREDITEMINDICESOrderIDFK = createInvForeignKey(id, "Order_ID"); + + public final com.querydsl.sql.ForeignKey _customer_CURRENTORDERIDFK = + createInvForeignKey(id, "CURRENTORDER_ID"); + + public final com.querydsl.sql.ForeignKey _order_item_OrderIDFK = + createInvForeignKey(id, "Order_ID"); + + public SOrder_(String variable) { + super(SOrder_.class, forVariable(variable), "null", "order_"); + addMetadata(); + } + + public SOrder_(String variable, String schema, String table) { + super(SOrder_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SOrder_(String variable, String schema) { + super(SOrder_.class, forVariable(variable), schema, "order_"); + addMetadata(); + } + + public SOrder_(Path path) { + super(path.getType(), path.getMetadata(), "null", "order_"); + addMetadata(); + } + + public SOrder_(PathMetadata metadata) { + super(SOrder_.class, metadata, "null", "order_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + customerId, + ColumnMetadata.named("CUSTOMER_ID").withIndex(3).ofType(Types.INTEGER).withSize(10)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata(paid, ColumnMetadata.named("PAID").withIndex(2).ofType(Types.BIT).withSize(1)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SOrder_item_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SOrder_item_.java new file mode 100644 index 0000000000..a91aa82835 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SOrder_item_.java @@ -0,0 +1,70 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SOrder_item_ is a Querydsl query type for SOrder_item_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SOrder_item_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -131699213; + + public static final SOrder_item_ order_item_ = new SOrder_item_("order__item_"); + + public final NumberPath _index = createNumber("_index", Integer.class); + + public final NumberPath itemsID = createNumber("itemsID", Long.class); + + public final NumberPath orderID = createNumber("orderID", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = + createPrimaryKey(orderID, itemsID); + + public final com.querydsl.sql.ForeignKey order_item_OrderIDFK = + createForeignKey(orderID, "ID"); + + public final com.querydsl.sql.ForeignKey order_item_itemsIDFK = + createForeignKey(itemsID, "ID"); + + public SOrder_item_(String variable) { + super(SOrder_item_.class, forVariable(variable), "null", "order__item_"); + addMetadata(); + } + + public SOrder_item_(String variable, String schema, String table) { + super(SOrder_item_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SOrder_item_(String variable, String schema) { + super(SOrder_item_.class, forVariable(variable), schema, "order__item_"); + addMetadata(); + } + + public SOrder_item_(Path path) { + super(path.getType(), path.getMetadata(), "null", "order__item_"); + addMetadata(); + } + + public SOrder_item_(PathMetadata metadata) { + super(SOrder_item_.class, metadata, "null", "order__item_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + _index, ColumnMetadata.named("_index").withIndex(3).ofType(Types.INTEGER).withSize(10)); + addMetadata( + itemsID, + ColumnMetadata.named("items_ID").withIndex(2).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + orderID, + ColumnMetadata.named("Order_ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SParameter_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SParameter_.java new file mode 100644 index 0000000000..8c8a71a573 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SParameter_.java @@ -0,0 +1,56 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SParameter_ is a Querydsl query type for SParameter_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SParameter_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 529679454; + + public static final SParameter_ parameter_ = new SParameter_("parameter_"); + + public final NumberPath id = createNumber("id", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _formula_PARAMETERIDFK = + createInvForeignKey(id, "PARAMETER_ID"); + + public SParameter_(String variable) { + super(SParameter_.class, forVariable(variable), "null", "parameter_"); + addMetadata(); + } + + public SParameter_(String variable, String schema, String table) { + super(SParameter_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SParameter_(String variable, String schema) { + super(SParameter_.class, forVariable(variable), schema, "parameter_"); + addMetadata(); + } + + public SParameter_(Path path) { + super(path.getType(), path.getMetadata(), "null", "parameter_"); + addMetadata(); + } + + public SParameter_(PathMetadata metadata) { + super(SParameter_.class, metadata, "null", "parameter_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SParent2.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SParent2.java new file mode 100644 index 0000000000..ced53dd8bc --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SParent2.java @@ -0,0 +1,56 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SParent2 is a Querydsl query type for SParent2 */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SParent2 extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 2116409152; + + public static final SParent2 parent2 = new SParent2("PARENT2"); + + public final NumberPath id = createNumber("id", Integer.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _child2ParentIdFk = + createInvForeignKey(id, "PARENT_ID"); + + public SParent2(String variable) { + super(SParent2.class, forVariable(variable), "null", "PARENT2"); + addMetadata(); + } + + public SParent2(String variable, String schema, String table) { + super(SParent2.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SParent2(String variable, String schema) { + super(SParent2.class, forVariable(variable), schema, "PARENT2"); + addMetadata(); + } + + public SParent2(Path path) { + super(path.getType(), path.getMetadata(), "null", "PARENT2"); + addMetadata(); + } + + public SParent2(PathMetadata metadata) { + super(SParent2.class, metadata, "null", "PARENT2"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SParent_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SParent_.java new file mode 100644 index 0000000000..0b5dd9ca81 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SParent_.java @@ -0,0 +1,63 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SParent_ is a Querydsl query type for SParent_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SParent_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 2116409197; + + public static final SParent_ parent_ = new SParent_("parent_"); + + public final StringPath childname = createString("childname"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath name = createString("name"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public SParent_(String variable) { + super(SParent_.class, forVariable(variable), "null", "parent_"); + addMetadata(); + } + + public SParent_(String variable, String schema, String table) { + super(SParent_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SParent_(String variable, String schema) { + super(SParent_.class, forVariable(variable), schema, "parent_"); + addMetadata(); + } + + public SParent_(Path path) { + super(path.getType(), path.getMetadata(), "null", "parent_"); + addMetadata(); + } + + public SParent_(PathMetadata metadata) { + super(SParent_.class, metadata, "null", "parent_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + childname, + ColumnMetadata.named("CHILDNAME").withIndex(3).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + name, ColumnMetadata.named("NAME").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SPerson_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SPerson_.java new file mode 100644 index 0000000000..d764371065 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SPerson_.java @@ -0,0 +1,81 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DatePath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SPerson_ is a Querydsl query type for SPerson_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SPerson_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -2063623646; + + public static final SPerson_ person_ = new SPerson_("person_"); + + public final DatePath birthday = createDate("birthday", java.sql.Date.class); + + public final NumberPath i = createNumber("i", Long.class); + + public final StringPath name = createString("name"); + + public final NumberPath nationalityId = createNumber("nationalityId", Long.class); + + public final NumberPath pidId = createNumber("pidId", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(i); + + public final com.querydsl.sql.ForeignKey person_NATIONALITYIDFK = + createForeignKey(nationalityId, "ID"); + + public final com.querydsl.sql.ForeignKey person_PIDIDFK = + createForeignKey(pidId, "ID"); + + public final com.querydsl.sql.ForeignKey _account_OWNERIFK = + createInvForeignKey(i, "OWNER_I"); + + public SPerson_(String variable) { + super(SPerson_.class, forVariable(variable), "null", "person_"); + addMetadata(); + } + + public SPerson_(String variable, String schema, String table) { + super(SPerson_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SPerson_(String variable, String schema) { + super(SPerson_.class, forVariable(variable), schema, "person_"); + addMetadata(); + } + + public SPerson_(Path path) { + super(path.getType(), path.getMetadata(), "null", "person_"); + addMetadata(); + } + + public SPerson_(PathMetadata metadata) { + super(SPerson_.class, metadata, "null", "person_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + birthday, ColumnMetadata.named("BIRTHDAY").withIndex(2).ofType(Types.DATE).withSize(10)); + addMetadata( + i, ColumnMetadata.named("I").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + name, ColumnMetadata.named("NAME").withIndex(3).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + nationalityId, + ColumnMetadata.named("NATIONALITY_ID").withIndex(4).ofType(Types.BIGINT).withSize(19)); + addMetadata( + pidId, ColumnMetadata.named("PID_ID").withIndex(5).ofType(Types.BIGINT).withSize(19)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SPersonid_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SPersonid_.java new file mode 100644 index 0000000000..2ed1e4e8aa --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SPersonid_.java @@ -0,0 +1,66 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SPersonid_ is a Querydsl query type for SPersonid_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SPersonid_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1132579751; + + public static final SPersonid_ personid_ = new SPersonid_("personid_"); + + public final StringPath country = createString("country"); + + public final NumberPath id = createNumber("id", Long.class); + + public final NumberPath medicarenumber = createNumber("medicarenumber", Integer.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _person_PIDIDFK = + createInvForeignKey(id, "PID_ID"); + + public SPersonid_(String variable) { + super(SPersonid_.class, forVariable(variable), "null", "personid_"); + addMetadata(); + } + + public SPersonid_(String variable, String schema, String table) { + super(SPersonid_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SPersonid_(String variable, String schema) { + super(SPersonid_.class, forVariable(variable), schema, "personid_"); + addMetadata(); + } + + public SPersonid_(Path path) { + super(path.getType(), path.getMetadata(), "null", "personid_"); + addMetadata(); + } + + public SPersonid_(PathMetadata metadata) { + super(SPersonid_.class, metadata, "null", "personid_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + country, ColumnMetadata.named("COUNTRY").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + medicarenumber, + ColumnMetadata.named("MEDICARENUMBER").withIndex(3).ofType(Types.INTEGER).withSize(10)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SPlayerSCORES.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SPlayerSCORES.java new file mode 100644 index 0000000000..5086ed1f36 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SPlayerSCORES.java @@ -0,0 +1,58 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SPlayerSCORES is a Querydsl query type for SPlayerSCORES */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SPlayerSCORES extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -841435446; + + public static final SPlayerSCORES PlayerSCORES = new SPlayerSCORES("Player_SCORES"); + + public final NumberPath playerID = createNumber("playerID", Long.class); + + public final NumberPath scores = createNumber("scores", Integer.class); + + public final com.querydsl.sql.ForeignKey playerSCORESPlayerIDFK = + createForeignKey(playerID, "ID"); + + public SPlayerSCORES(String variable) { + super(SPlayerSCORES.class, forVariable(variable), "null", "Player_SCORES"); + addMetadata(); + } + + public SPlayerSCORES(String variable, String schema, String table) { + super(SPlayerSCORES.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SPlayerSCORES(String variable, String schema) { + super(SPlayerSCORES.class, forVariable(variable), schema, "Player_SCORES"); + addMetadata(); + } + + public SPlayerSCORES(Path path) { + super(path.getType(), path.getMetadata(), "null", "Player_SCORES"); + addMetadata(); + } + + public SPlayerSCORES(PathMetadata metadata) { + super(SPlayerSCORES.class, metadata, "null", "Player_SCORES"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + playerID, ColumnMetadata.named("Player_ID").withIndex(1).ofType(Types.BIGINT).withSize(19)); + addMetadata( + scores, ColumnMetadata.named("SCORES").withIndex(2).ofType(Types.INTEGER).withSize(10)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SPlayer_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SPlayer_.java new file mode 100644 index 0000000000..0d5111e5b4 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SPlayer_.java @@ -0,0 +1,56 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SPlayer_ is a Querydsl query type for SPlayer_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SPlayer_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -1878750186; + + public static final SPlayer_ player_ = new SPlayer_("player_"); + + public final NumberPath id = createNumber("id", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _playerSCORESPlayerIDFK = + createInvForeignKey(id, "Player_ID"); + + public SPlayer_(String variable) { + super(SPlayer_.class, forVariable(variable), "null", "player_"); + addMetadata(); + } + + public SPlayer_(String variable, String schema, String table) { + super(SPlayer_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SPlayer_(String variable, String schema) { + super(SPlayer_.class, forVariable(variable), schema, "player_"); + addMetadata(); + } + + public SPlayer_(Path path) { + super(path.getType(), path.getMetadata(), "null", "player_"); + addMetadata(); + } + + public SPlayer_(PathMetadata metadata) { + super(SPlayer_.class, metadata, "null", "player_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SPrice_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SPrice_.java new file mode 100644 index 0000000000..0d145263a0 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SPrice_.java @@ -0,0 +1,68 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SPrice_ is a Querydsl query type for SPrice_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SPrice_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 776437438; + + public static final SPrice_ price_ = new SPrice_("price_"); + + public final NumberPath amount = createNumber("amount", Long.class); + + public final NumberPath id = createNumber("id", Long.class); + + public final NumberPath productId = createNumber("productId", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey price_PRODUCTIDFK = + createForeignKey(productId, "ID"); + + public final com.querydsl.sql.ForeignKey _catalog_price_pricesIDFK = + createInvForeignKey(id, "prices_ID"); + + public SPrice_(String variable) { + super(SPrice_.class, forVariable(variable), "null", "price_"); + addMetadata(); + } + + public SPrice_(String variable, String schema, String table) { + super(SPrice_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SPrice_(String variable, String schema) { + super(SPrice_.class, forVariable(variable), schema, "price_"); + addMetadata(); + } + + public SPrice_(Path path) { + super(path.getType(), path.getMetadata(), "null", "price_"); + addMetadata(); + } + + public SPrice_(PathMetadata metadata) { + super(SPrice_.class, metadata, "null", "price_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + amount, ColumnMetadata.named("AMOUNT").withIndex(2).ofType(Types.BIGINT).withSize(19)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + productId, + ColumnMetadata.named("PRODUCT_ID").withIndex(3).ofType(Types.BIGINT).withSize(19)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SSequence.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SSequence.java new file mode 100644 index 0000000000..709045f0c0 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SSequence.java @@ -0,0 +1,61 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SSequence is a Querydsl query type for SSequence */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SSequence extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1358560329; + + public static final SSequence sequence = new SSequence("SEQUENCE"); + + public final NumberPath seqCount = + createNumber("seqCount", java.math.BigInteger.class); + + public final StringPath seqName = createString("seqName"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(seqName); + + public SSequence(String variable) { + super(SSequence.class, forVariable(variable), "null", "SEQUENCE"); + addMetadata(); + } + + public SSequence(String variable, String schema, String table) { + super(SSequence.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SSequence(String variable, String schema) { + super(SSequence.class, forVariable(variable), schema, "SEQUENCE"); + addMetadata(); + } + + public SSequence(Path path) { + super(path.getType(), path.getMetadata(), "null", "SEQUENCE"); + addMetadata(); + } + + public SSequence(PathMetadata metadata) { + super(SSequence.class, metadata, "null", "SEQUENCE"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + seqCount, + ColumnMetadata.named("SEQ_COUNT").withIndex(2).ofType(Types.DECIMAL).withSize(38)); + addMetadata( + seqName, + ColumnMetadata.named("SEQ_NAME").withIndex(1).ofType(Types.VARCHAR).withSize(50).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SShapes.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SShapes.java new file mode 100644 index 0000000000..978bd8ff6f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SShapes.java @@ -0,0 +1,59 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.SimplePath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SShapes is a Querydsl query type for SShapes */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SShapes extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 852863866; + + public static final SShapes shapes = new SShapes("SHAPES"); + + public final SimplePath geometry = createSimple("geometry", byte[].class); + + public final NumberPath id = createNumber("id", Integer.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public SShapes(String variable) { + super(SShapes.class, forVariable(variable), "null", "SHAPES"); + addMetadata(); + } + + public SShapes(String variable, String schema, String table) { + super(SShapes.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SShapes(String variable, String schema) { + super(SShapes.class, forVariable(variable), schema, "SHAPES"); + addMetadata(); + } + + public SShapes(Path path) { + super(path.getType(), path.getMetadata(), "null", "SHAPES"); + addMetadata(); + } + + public SShapes(PathMetadata metadata) { + super(SShapes.class, metadata, "null", "SHAPES"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + geometry, + ColumnMetadata.named("GEOMETRY").withIndex(2).ofType(Types.BINARY).withSize(65535)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SShowACTS.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SShowACTS.java new file mode 100644 index 0000000000..fe12dc37a9 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SShowACTS.java @@ -0,0 +1,63 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SShowACTS is a Querydsl query type for SShowACTS */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SShowACTS extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -330421466; + + public static final SShowACTS ShowACTS = new SShowACTS("Show_ACTS"); + + public final StringPath acts = createString("acts"); + + public final StringPath actsKey = createString("actsKey"); + + public final NumberPath showID = createNumber("showID", Long.class); + + public final com.querydsl.sql.ForeignKey showACTSShowIDFK = + createForeignKey(showID, "ID"); + + public SShowACTS(String variable) { + super(SShowACTS.class, forVariable(variable), "null", "Show_ACTS"); + addMetadata(); + } + + public SShowACTS(String variable, String schema, String table) { + super(SShowACTS.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SShowACTS(String variable, String schema) { + super(SShowACTS.class, forVariable(variable), schema, "Show_ACTS"); + addMetadata(); + } + + public SShowACTS(Path path) { + super(path.getType(), path.getMetadata(), "null", "Show_ACTS"); + addMetadata(); + } + + public SShowACTS(PathMetadata metadata) { + super(SShowACTS.class, metadata, "null", "Show_ACTS"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + acts, ColumnMetadata.named("ACTS").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + actsKey, ColumnMetadata.named("acts_key").withIndex(3).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + showID, ColumnMetadata.named("Show_ID").withIndex(1).ofType(Types.BIGINT).withSize(19)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SShow_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SShow_.java new file mode 100644 index 0000000000..d05968d87c --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SShow_.java @@ -0,0 +1,66 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SShow_ is a Querydsl query type for SShow_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SShow_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -942305926; + + public static final SShow_ show_ = new SShow_("show_"); + + public final NumberPath id = createNumber("id", Long.class); + + public final NumberPath parentId = createNumber("parentId", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey show_PARENTIDFK = + createForeignKey(parentId, "ID"); + + public final com.querydsl.sql.ForeignKey _showACTSShowIDFK = + createInvForeignKey(id, "Show_ID"); + + public final com.querydsl.sql.ForeignKey _show_PARENTIDFK = + createInvForeignKey(id, "PARENT_ID"); + + public SShow_(String variable) { + super(SShow_.class, forVariable(variable), "null", "show_"); + addMetadata(); + } + + public SShow_(String variable, String schema, String table) { + super(SShow_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SShow_(String variable, String schema) { + super(SShow_.class, forVariable(variable), schema, "show_"); + addMetadata(); + } + + public SShow_(Path path) { + super(path.getType(), path.getMetadata(), "null", "show_"); + addMetadata(); + } + + public SShow_(PathMetadata metadata) { + super(SShow_.class, metadata, "null", "show_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + parentId, ColumnMetadata.named("PARENT_ID").withIndex(2).ofType(Types.BIGINT).withSize(19)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SSimpletypes_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SSimpletypes_.java new file mode 100644 index 0000000000..065066af99 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SSimpletypes_.java @@ -0,0 +1,142 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DatePath; +import com.querydsl.core.types.dsl.DateTimePath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.SimplePath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.core.types.dsl.TimePath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SSimpletypes_ is a Querydsl query type for SSimpletypes_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SSimpletypes_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -971482176; + + public static final SSimpletypes_ simpletypes_ = new SSimpletypes_("simpletypes_"); + + public final NumberPath bbyte = createNumber("bbyte", Byte.class); + + public final NumberPath bbyte2 = createNumber("bbyte2", Byte.class); + + public final NumberPath bigdecimal = + createNumber("bigdecimal", java.math.BigInteger.class); + + public final SimplePath bytearray = createSimple("bytearray", byte[].class); + + public final StringPath cchar = createString("cchar"); + + public final StringPath cchar2 = createString("cchar2"); + + public final DatePath date = createDate("date", java.sql.Date.class); + + public final NumberPath ddouble = createNumber("ddouble", Double.class); + + public final NumberPath ddouble2 = createNumber("ddouble2", Double.class); + + public final NumberPath ffloat = createNumber("ffloat", Float.class); + + public final NumberPath ffloat2 = createNumber("ffloat2", Float.class); + + public final NumberPath id = createNumber("id", Long.class); + + public final NumberPath iint = createNumber("iint", Integer.class); + + public final NumberPath iint2 = createNumber("iint2", Integer.class); + + public final SimplePath llocale = createSimple("llocale", byte[].class); + + public final NumberPath llong = createNumber("llong", Long.class); + + public final NumberPath llong2 = createNumber("llong2", Long.class); + + public final StringPath sstring = createString("sstring"); + + public final TimePath time = createTime("time", java.sql.Time.class); + + public final DateTimePath timestamp = + createDateTime("timestamp", java.sql.Timestamp.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public SSimpletypes_(String variable) { + super(SSimpletypes_.class, forVariable(variable), "null", "simpletypes_"); + addMetadata(); + } + + public SSimpletypes_(String variable, String schema, String table) { + super(SSimpletypes_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SSimpletypes_(String variable, String schema) { + super(SSimpletypes_.class, forVariable(variable), schema, "simpletypes_"); + addMetadata(); + } + + public SSimpletypes_(Path path) { + super(path.getType(), path.getMetadata(), "null", "simpletypes_"); + addMetadata(); + } + + public SSimpletypes_(PathMetadata metadata) { + super(SSimpletypes_.class, metadata, "null", "simpletypes_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + bbyte, ColumnMetadata.named("BBYTE").withIndex(2).ofType(Types.TINYINT).withSize(3)); + addMetadata( + bbyte2, ColumnMetadata.named("BBYTE2").withIndex(3).ofType(Types.TINYINT).withSize(3)); + addMetadata( + bigdecimal, + ColumnMetadata.named("BIGDECIMAL").withIndex(4).ofType(Types.DECIMAL).withSize(38)); + addMetadata( + bytearray, + ColumnMetadata.named("BYTEARRAY") + .withIndex(5) + .ofType(Types.LONGVARBINARY) + .withSize(2147483647)); + addMetadata(cchar, ColumnMetadata.named("CCHAR").withIndex(6).ofType(Types.CHAR).withSize(1)); + addMetadata(cchar2, ColumnMetadata.named("CCHAR2").withIndex(7).ofType(Types.CHAR).withSize(1)); + addMetadata(date, ColumnMetadata.named("DATE").withIndex(8).ofType(Types.DATE).withSize(10)); + addMetadata( + ddouble, ColumnMetadata.named("DDOUBLE").withIndex(9).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + ddouble2, ColumnMetadata.named("DDOUBLE2").withIndex(10).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + ffloat, ColumnMetadata.named("FFLOAT").withIndex(11).ofType(Types.REAL).withSize(12)); + addMetadata( + ffloat2, ColumnMetadata.named("FFLOAT2").withIndex(12).ofType(Types.REAL).withSize(12)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + iint, ColumnMetadata.named("IINT").withIndex(13).ofType(Types.INTEGER).withSize(10)); + addMetadata( + iint2, ColumnMetadata.named("IINT2").withIndex(14).ofType(Types.INTEGER).withSize(10)); + addMetadata( + llocale, + ColumnMetadata.named("LLOCALE") + .withIndex(15) + .ofType(Types.LONGVARBINARY) + .withSize(2147483647)); + addMetadata( + llong, ColumnMetadata.named("LLONG").withIndex(16).ofType(Types.BIGINT).withSize(19)); + addMetadata( + llong2, ColumnMetadata.named("LLONG2").withIndex(17).ofType(Types.BIGINT).withSize(19)); + addMetadata( + sstring, ColumnMetadata.named("SSTRING").withIndex(18).ofType(Types.VARCHAR).withSize(255)); + addMetadata(time, ColumnMetadata.named("TIME").withIndex(19).ofType(Types.TIME).withSize(8)); + addMetadata( + timestamp, + ColumnMetadata.named("TIMESTAMP").withIndex(20).ofType(Types.TIMESTAMP).withSize(19)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SStatus_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SStatus_.java new file mode 100644 index 0000000000..22635c3665 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SStatus_.java @@ -0,0 +1,64 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SStatus_ is a Querydsl query type for SStatus_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SStatus_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1012660517; + + public static final SStatus_ status_ = new SStatus_("status_"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath name = createString("name"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _item_CURRENTSTATUSIDFK = + createInvForeignKey(id, "CURRENTSTATUS_ID"); + + public final com.querydsl.sql.ForeignKey _item_STATUSIDFK = + createInvForeignKey(id, "STATUS_ID"); + + public SStatus_(String variable) { + super(SStatus_.class, forVariable(variable), "null", "status_"); + addMetadata(); + } + + public SStatus_(String variable, String schema, String table) { + super(SStatus_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SStatus_(String variable, String schema) { + super(SStatus_.class, forVariable(variable), schema, "status_"); + addMetadata(); + } + + public SStatus_(Path path) { + super(path.getType(), path.getMetadata(), "null", "status_"); + addMetadata(); + } + + public SStatus_(PathMetadata metadata) { + super(SStatus_.class, metadata, "null", "status_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + name, ColumnMetadata.named("NAME").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SStatuschange_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SStatuschange_.java new file mode 100644 index 0000000000..4b352cb233 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SStatuschange_.java @@ -0,0 +1,63 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DateTimePath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SStatuschange_ is a Querydsl query type for SStatuschange_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SStatuschange_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1805594357; + + public static final SStatuschange_ statuschange_ = new SStatuschange_("statuschange_"); + + public final NumberPath id = createNumber("id", Long.class); + + public final DateTimePath timestamp = + createDateTime("timestamp", java.sql.Timestamp.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey + _item_statuschange_statusChangesIDFK = createInvForeignKey(id, "statusChanges_ID"); + + public SStatuschange_(String variable) { + super(SStatuschange_.class, forVariable(variable), "null", "statuschange_"); + addMetadata(); + } + + public SStatuschange_(String variable, String schema, String table) { + super(SStatuschange_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SStatuschange_(String variable, String schema) { + super(SStatuschange_.class, forVariable(variable), schema, "statuschange_"); + addMetadata(); + } + + public SStatuschange_(Path path) { + super(path.getType(), path.getMetadata(), "null", "statuschange_"); + addMetadata(); + } + + public SStatuschange_(PathMetadata metadata) { + super(SStatuschange_.class, metadata, "null", "statuschange_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + timestamp, + ColumnMetadata.named("TIMESTAMP").withIndex(2).ofType(Types.TIMESTAMP).withSize(19)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SStore_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SStore_.java new file mode 100644 index 0000000000..93184861c8 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SStore_.java @@ -0,0 +1,64 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SStore_ is a Querydsl query type for SStore_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SStore_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 864365094; + + public static final SStore_ store_ = new SStore_("store_"); + + public final NumberPath id = createNumber("id", Long.class); + + public final NumberPath locationId = createNumber("locationId", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey store_LOCATIONIDFK = + createForeignKey(locationId, "ID"); + + public final com.querydsl.sql.ForeignKey _store_customer_StoreIDFK = + createInvForeignKey(id, "Store_ID"); + + public SStore_(String variable) { + super(SStore_.class, forVariable(variable), "null", "store_"); + addMetadata(); + } + + public SStore_(String variable, String schema, String table) { + super(SStore_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SStore_(String variable, String schema) { + super(SStore_.class, forVariable(variable), schema, "store_"); + addMetadata(); + } + + public SStore_(Path path) { + super(path.getType(), path.getMetadata(), "null", "store_"); + addMetadata(); + } + + public SStore_(PathMetadata metadata) { + super(SStore_.class, metadata, "null", "store_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + locationId, + ColumnMetadata.named("LOCATION_ID").withIndex(2).ofType(Types.BIGINT).withSize(19)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SStore_customer_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SStore_customer_.java new file mode 100644 index 0000000000..d202b75878 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SStore_customer_.java @@ -0,0 +1,70 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SStore_customer_ is a Querydsl query type for SStore_customer_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SStore_customer_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -1583391525; + + public static final SStore_customer_ store_customer_ = new SStore_customer_("store__customer_"); + + public final NumberPath customersID = createNumber("customersID", Integer.class); + + public final NumberPath storeID = createNumber("storeID", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = + createPrimaryKey(storeID, customersID); + + public final com.querydsl.sql.ForeignKey store_customer_StoreIDFK = + createForeignKey(storeID, "ID"); + + public final com.querydsl.sql.ForeignKey store_customer_customersIDFK = + createForeignKey(customersID, "ID"); + + public SStore_customer_(String variable) { + super(SStore_customer_.class, forVariable(variable), "null", "store__customer_"); + addMetadata(); + } + + public SStore_customer_(String variable, String schema, String table) { + super(SStore_customer_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SStore_customer_(String variable, String schema) { + super(SStore_customer_.class, forVariable(variable), schema, "store__customer_"); + addMetadata(); + } + + public SStore_customer_(Path path) { + super(path.getType(), path.getMetadata(), "null", "store__customer_"); + addMetadata(); + } + + public SStore_customer_(PathMetadata metadata) { + super(SStore_customer_.class, metadata, "null", "store__customer_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + customersID, + ColumnMetadata.named("customers_ID") + .withIndex(2) + .ofType(Types.INTEGER) + .withSize(10) + .notNull()); + addMetadata( + storeID, + ColumnMetadata.named("Store_ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SSurvey.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SSurvey.java new file mode 100644 index 0000000000..3b23fd91f2 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SSurvey.java @@ -0,0 +1,61 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SSurvey is a Querydsl query type for SSurvey */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SSurvey extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 865381858; + + public static final SSurvey survey = new SSurvey("SURVEY"); + + public final NumberPath id = createNumber("id", Integer.class); + + public final StringPath name = createString("name"); + + public final StringPath name2 = createString("name2"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public SSurvey(String variable) { + super(SSurvey.class, forVariable(variable), "null", "SURVEY"); + addMetadata(); + } + + public SSurvey(String variable, String schema, String table) { + super(SSurvey.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SSurvey(String variable, String schema) { + super(SSurvey.class, forVariable(variable), schema, "SURVEY"); + addMetadata(); + } + + public SSurvey(Path path) { + super(path.getType(), path.getMetadata(), "null", "SURVEY"); + addMetadata(); + } + + public SSurvey(PathMetadata metadata) { + super(SSurvey.class, metadata, "null", "SURVEY"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.INTEGER).withSize(10).notNull()); + addMetadata(name, ColumnMetadata.named("NAME").withIndex(2).ofType(Types.VARCHAR).withSize(30)); + addMetadata( + name2, ColumnMetadata.named("NAME2").withIndex(3).ofType(Types.VARCHAR).withSize(30)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/STest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/STest.java new file mode 100644 index 0000000000..c2d4a75259 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/STest.java @@ -0,0 +1,51 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** STest is a Querydsl query type for STest */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class STest extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1493650714; + + public static final STest test = new STest("TEST"); + + public final StringPath name = createString("name"); + + public STest(String variable) { + super(STest.class, forVariable(variable), "null", "TEST"); + addMetadata(); + } + + public STest(String variable, String schema, String table) { + super(STest.class, forVariable(variable), schema, table); + addMetadata(); + } + + public STest(String variable, String schema) { + super(STest.class, forVariable(variable), schema, "TEST"); + addMetadata(); + } + + public STest(Path path) { + super(path.getType(), path.getMetadata(), "null", "TEST"); + addMetadata(); + } + + public STest(PathMetadata metadata) { + super(STest.class, metadata, "null", "TEST"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + name, ColumnMetadata.named("NAME").withIndex(1).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/STimeTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/STimeTest.java new file mode 100644 index 0000000000..e16517e797 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/STimeTest.java @@ -0,0 +1,51 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.TimePath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** STimeTest is a Querydsl query type for STimeTest */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class STimeTest extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -2068356729; + + public static final STimeTest timeTest1 = new STimeTest("TIME_TEST"); + + public final TimePath timeTest = createTime("timeTest", java.sql.Time.class); + + public STimeTest(String variable) { + super(STimeTest.class, forVariable(variable), "null", "TIME_TEST"); + addMetadata(); + } + + public STimeTest(String variable, String schema, String table) { + super(STimeTest.class, forVariable(variable), schema, table); + addMetadata(); + } + + public STimeTest(String variable, String schema) { + super(STimeTest.class, forVariable(variable), schema, "TIME_TEST"); + addMetadata(); + } + + public STimeTest(Path path) { + super(path.getType(), path.getMetadata(), "null", "TIME_TEST"); + addMetadata(); + } + + public STimeTest(PathMetadata metadata) { + super(STimeTest.class, metadata, "null", "TIME_TEST"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + timeTest, ColumnMetadata.named("TIME_TEST").withIndex(1).ofType(Types.TIME).withSize(8)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUser2_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUser2_.java new file mode 100644 index 0000000000..430dfff0c7 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUser2_.java @@ -0,0 +1,116 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DateTimePath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SUser2_ is a Querydsl query type for SUser2_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SUser2_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 920400384; + + public static final SUser2_ user2_ = new SUser2_("user2_"); + + public final NumberPath createdby = createNumber("createdby", Double.class); + + public final DateTimePath creationdate = + createDateTime("creationdate", java.sql.Timestamp.class); + + public final DateTimePath deletedate = + createDateTime("deletedate", java.sql.Timestamp.class); + + public final NumberPath deletedby = createNumber("deletedby", Double.class); + + public final NumberPath id = createNumber("id", Long.class); + + public final DateTimePath modificationdate = + createDateTime("modificationdate", java.sql.Timestamp.class); + + public final NumberPath modifiedby = createNumber("modifiedby", Double.class); + + public final StringPath useremail = createString("useremail"); + + public final StringPath userfirstname = createString("userfirstname"); + + public final StringPath userlastname = createString("userlastname"); + + public final StringPath username = createString("username"); + + public final StringPath userpassword = createString("userpassword"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _user2_userprop_User2IDFK = + createInvForeignKey(id, "User2_ID"); + + public SUser2_(String variable) { + super(SUser2_.class, forVariable(variable), "null", "user2_"); + addMetadata(); + } + + public SUser2_(String variable, String schema, String table) { + super(SUser2_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SUser2_(String variable, String schema) { + super(SUser2_.class, forVariable(variable), schema, "user2_"); + addMetadata(); + } + + public SUser2_(Path path) { + super(path.getType(), path.getMetadata(), "null", "user2_"); + addMetadata(); + } + + public SUser2_(PathMetadata metadata) { + super(SUser2_.class, metadata, "null", "user2_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + createdby, + ColumnMetadata.named("CREATEDBY").withIndex(2).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + creationdate, + ColumnMetadata.named("CREATIONDATE").withIndex(3).ofType(Types.TIMESTAMP).withSize(19)); + addMetadata( + deletedate, + ColumnMetadata.named("DELETEDATE").withIndex(4).ofType(Types.TIMESTAMP).withSize(19)); + addMetadata( + deletedby, + ColumnMetadata.named("DELETEDBY").withIndex(5).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + modificationdate, + ColumnMetadata.named("MODIFICATIONDATE").withIndex(6).ofType(Types.TIMESTAMP).withSize(19)); + addMetadata( + modifiedby, + ColumnMetadata.named("MODIFIEDBY").withIndex(7).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + useremail, + ColumnMetadata.named("USEREMAIL").withIndex(8).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + userfirstname, + ColumnMetadata.named("USERFIRSTNAME").withIndex(9).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + userlastname, + ColumnMetadata.named("USERLASTNAME").withIndex(10).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + username, + ColumnMetadata.named("USERNAME").withIndex(11).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + userpassword, + ColumnMetadata.named("USERPASSWORD").withIndex(12).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUser2_userprop_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUser2_userprop_.java new file mode 100644 index 0000000000..742b8ca3d6 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUser2_userprop_.java @@ -0,0 +1,70 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SUser2_userprop_ is a Querydsl query type for SUser2_userprop_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SUser2_userprop_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 770151025; + + public static final SUser2_userprop_ user2_userprop_ = new SUser2_userprop_("user2__userprop_"); + + public final NumberPath propertiesID = createNumber("propertiesID", Long.class); + + public final NumberPath user2ID = createNumber("user2ID", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = + createPrimaryKey(user2ID, propertiesID); + + public final com.querydsl.sql.ForeignKey user2_userprop_User2IDFK = + createForeignKey(user2ID, "ID"); + + public final com.querydsl.sql.ForeignKey user2_userprop_propertiesIDFK = + createForeignKey(propertiesID, "ID"); + + public SUser2_userprop_(String variable) { + super(SUser2_userprop_.class, forVariable(variable), "null", "user2__userprop_"); + addMetadata(); + } + + public SUser2_userprop_(String variable, String schema, String table) { + super(SUser2_userprop_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SUser2_userprop_(String variable, String schema) { + super(SUser2_userprop_.class, forVariable(variable), schema, "user2__userprop_"); + addMetadata(); + } + + public SUser2_userprop_(Path path) { + super(path.getType(), path.getMetadata(), "null", "user2__userprop_"); + addMetadata(); + } + + public SUser2_userprop_(PathMetadata metadata) { + super(SUser2_userprop_.class, metadata, "null", "user2__userprop_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + propertiesID, + ColumnMetadata.named("properties_ID") + .withIndex(2) + .ofType(Types.BIGINT) + .withSize(19) + .notNull()); + addMetadata( + user2ID, + ColumnMetadata.named("User2_ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUser_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUser_.java new file mode 100644 index 0000000000..1b25b9cc8f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUser_.java @@ -0,0 +1,80 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SUser_ is a Querydsl query type for SUser_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SUser_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -940140948; + + public static final SUser_ user_ = new SUser_("user_"); + + public final NumberPath companyId = createNumber("companyId", Integer.class); + + public final StringPath firstname = createString("firstname"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath lastname = createString("lastname"); + + public final StringPath username = createString("username"); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey user_COMPANYIDFK = + createForeignKey(companyId, "ID"); + + public final com.querydsl.sql.ForeignKey _employee_USERIDFK = + createInvForeignKey(id, "USER_ID"); + + public SUser_(String variable) { + super(SUser_.class, forVariable(variable), "null", "user_"); + addMetadata(); + } + + public SUser_(String variable, String schema, String table) { + super(SUser_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SUser_(String variable, String schema) { + super(SUser_.class, forVariable(variable), schema, "user_"); + addMetadata(); + } + + public SUser_(Path path) { + super(path.getType(), path.getMetadata(), "null", "user_"); + addMetadata(); + } + + public SUser_(PathMetadata metadata) { + super(SUser_.class, metadata, "null", "user_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + companyId, + ColumnMetadata.named("COMPANY_ID").withIndex(5).ofType(Types.INTEGER).withSize(10)); + addMetadata( + firstname, + ColumnMetadata.named("FIRSTNAME").withIndex(2).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + lastname, + ColumnMetadata.named("LASTNAME").withIndex(3).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + username, + ColumnMetadata.named("USERNAME").withIndex(4).ofType(Types.VARCHAR).withSize(255)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUserprop_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUserprop_.java new file mode 100644 index 0000000000..940137dd5d --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUserprop_.java @@ -0,0 +1,110 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DateTimePath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SUserprop_ is a Querydsl query type for SUserprop_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SUserprop_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 634556649; + + public static final SUserprop_ userprop_ = new SUserprop_("userprop_"); + + public final StringPath categorydescription = createString("categorydescription"); + + public final StringPath categoryname = createString("categoryname"); + + public final NumberPath createdby = createNumber("createdby", Double.class); + + public final DateTimePath creationdate = + createDateTime("creationdate", java.sql.Timestamp.class); + + public final DateTimePath deletedate = + createDateTime("deletedate", java.sql.Timestamp.class); + + public final NumberPath deletedby = createNumber("deletedby", Double.class); + + public final NumberPath id = createNumber("id", Long.class); + + public final DateTimePath modificationdate = + createDateTime("modificationdate", java.sql.Timestamp.class); + + public final NumberPath modifiedby = createNumber("modifiedby", Double.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _user2_userprop_propertiesIDFK = + createInvForeignKey(id, "properties_ID"); + + public final com.querydsl.sql.ForeignKey _userprop_category_UserPropIDFK = + createInvForeignKey(id, "UserProp_ID"); + + public final com.querydsl.sql.ForeignKey + _userprop_categoryprop_UserPropIDFK = createInvForeignKey(id, "UserProp_ID"); + + public SUserprop_(String variable) { + super(SUserprop_.class, forVariable(variable), "null", "userprop_"); + addMetadata(); + } + + public SUserprop_(String variable, String schema, String table) { + super(SUserprop_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SUserprop_(String variable, String schema) { + super(SUserprop_.class, forVariable(variable), schema, "userprop_"); + addMetadata(); + } + + public SUserprop_(Path path) { + super(path.getType(), path.getMetadata(), "null", "userprop_"); + addMetadata(); + } + + public SUserprop_(PathMetadata metadata) { + super(SUserprop_.class, metadata, "null", "userprop_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + categorydescription, + ColumnMetadata.named("CATEGORYDESCRIPTION") + .withIndex(2) + .ofType(Types.VARCHAR) + .withSize(255)); + addMetadata( + categoryname, + ColumnMetadata.named("CATEGORYNAME").withIndex(3).ofType(Types.VARCHAR).withSize(255)); + addMetadata( + createdby, + ColumnMetadata.named("CREATEDBY").withIndex(4).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + creationdate, + ColumnMetadata.named("CREATIONDATE").withIndex(5).ofType(Types.TIMESTAMP).withSize(19)); + addMetadata( + deletedate, + ColumnMetadata.named("DELETEDATE").withIndex(6).ofType(Types.TIMESTAMP).withSize(19)); + addMetadata( + deletedby, + ColumnMetadata.named("DELETEDBY").withIndex(7).ofType(Types.DOUBLE).withSize(22)); + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + addMetadata( + modificationdate, + ColumnMetadata.named("MODIFICATIONDATE").withIndex(8).ofType(Types.TIMESTAMP).withSize(19)); + addMetadata( + modifiedby, + ColumnMetadata.named("MODIFIEDBY").withIndex(9).ofType(Types.DOUBLE).withSize(22)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUserprop_category_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUserprop_category_.java new file mode 100644 index 0000000000..8b8f1d2578 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUserprop_category_.java @@ -0,0 +1,75 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SUserprop_category_ is a Querydsl query type for SUserprop_category_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SUserprop_category_ extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 1245464664; + + public static final SUserprop_category_ userprop_category_ = + new SUserprop_category_("userprop__category_"); + + public final NumberPath childCategoriesID = createNumber("childCategoriesID", Long.class); + + public final NumberPath userPropID = createNumber("userPropID", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = + createPrimaryKey(userPropID, childCategoriesID); + + public final com.querydsl.sql.ForeignKey userprop_category_UserPropIDFK = + createForeignKey(userPropID, "ID"); + + public final com.querydsl.sql.ForeignKey userprop_category_childCategoriesIDFK = + createForeignKey(childCategoriesID, "ID"); + + public SUserprop_category_(String variable) { + super(SUserprop_category_.class, forVariable(variable), "null", "userprop__category_"); + addMetadata(); + } + + public SUserprop_category_(String variable, String schema, String table) { + super(SUserprop_category_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SUserprop_category_(String variable, String schema) { + super(SUserprop_category_.class, forVariable(variable), schema, "userprop__category_"); + addMetadata(); + } + + public SUserprop_category_(Path path) { + super(path.getType(), path.getMetadata(), "null", "userprop__category_"); + addMetadata(); + } + + public SUserprop_category_(PathMetadata metadata) { + super(SUserprop_category_.class, metadata, "null", "userprop__category_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + childCategoriesID, + ColumnMetadata.named("childCategories_ID") + .withIndex(2) + .ofType(Types.BIGINT) + .withSize(19) + .notNull()); + addMetadata( + userPropID, + ColumnMetadata.named("UserProp_ID") + .withIndex(1) + .ofType(Types.BIGINT) + .withSize(19) + .notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUserprop_categoryprop_.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUserprop_categoryprop_.java new file mode 100644 index 0000000000..fcfa11e825 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SUserprop_categoryprop_.java @@ -0,0 +1,76 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SUserprop_categoryprop_ is a Querydsl query type for SUserprop_categoryprop_ */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SUserprop_categoryprop_ + extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -925537067; + + public static final SUserprop_categoryprop_ userprop_categoryprop_ = + new SUserprop_categoryprop_("userprop__categoryprop_"); + + public final NumberPath propertiesID = createNumber("propertiesID", Long.class); + + public final NumberPath userPropID = createNumber("userPropID", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = + createPrimaryKey(userPropID, propertiesID); + + public final com.querydsl.sql.ForeignKey userprop_categoryprop_UserPropIDFK = + createForeignKey(userPropID, "ID"); + + public final com.querydsl.sql.ForeignKey userprop_categoryprop_propertiesIDFK = + createForeignKey(propertiesID, "ID"); + + public SUserprop_categoryprop_(String variable) { + super(SUserprop_categoryprop_.class, forVariable(variable), "null", "userprop__categoryprop_"); + addMetadata(); + } + + public SUserprop_categoryprop_(String variable, String schema, String table) { + super(SUserprop_categoryprop_.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SUserprop_categoryprop_(String variable, String schema) { + super(SUserprop_categoryprop_.class, forVariable(variable), schema, "userprop__categoryprop_"); + addMetadata(); + } + + public SUserprop_categoryprop_(Path path) { + super(path.getType(), path.getMetadata(), "null", "userprop__categoryprop_"); + addMetadata(); + } + + public SUserprop_categoryprop_(PathMetadata metadata) { + super(SUserprop_categoryprop_.class, metadata, "null", "userprop__categoryprop_"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + propertiesID, + ColumnMetadata.named("properties_ID") + .withIndex(2) + .ofType(Types.BIGINT) + .withSize(19) + .notNull()); + addMetadata( + userPropID, + ColumnMetadata.named("UserProp_ID") + .withIndex(1) + .ofType(Types.BIGINT) + .withSize(19) + .notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SWorld.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SWorld.java new file mode 100644 index 0000000000..fc77723204 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SWorld.java @@ -0,0 +1,56 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SWorld is a Querydsl query type for SWorld */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SWorld extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -938400758; + + public static final SWorld world = new SWorld("WORLD"); + + public final NumberPath id = createNumber("id", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = createPrimaryKey(id); + + public final com.querydsl.sql.ForeignKey _wORLDMAMMALWorldIDFK = + createInvForeignKey(id, "World_ID"); + + public SWorld(String variable) { + super(SWorld.class, forVariable(variable), "null", "WORLD"); + addMetadata(); + } + + public SWorld(String variable, String schema, String table) { + super(SWorld.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SWorld(String variable, String schema) { + super(SWorld.class, forVariable(variable), schema, "WORLD"); + addMetadata(); + } + + public SWorld(Path path) { + super(path.getType(), path.getMetadata(), "null", "WORLD"); + addMetadata(); + } + + public SWorld(PathMetadata metadata) { + super(SWorld.class, metadata, "null", "WORLD"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + id, ColumnMetadata.named("ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SWorldMammal.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SWorldMammal.java new file mode 100644 index 0000000000..3f804a0b4d --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SWorldMammal.java @@ -0,0 +1,70 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SWorldMammal is a Querydsl query type for SWorldMammal */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SWorldMammal extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = -1315719671; + + public static final SWorldMammal worldMammal = new SWorldMammal("WORLD_MAMMAL"); + + public final NumberPath mammalsID = createNumber("mammalsID", Long.class); + + public final NumberPath worldID = createNumber("worldID", Long.class); + + public final com.querydsl.sql.PrimaryKey primary = + createPrimaryKey(worldID, mammalsID); + + public final com.querydsl.sql.ForeignKey wORLDMAMMALWorldIDFK = + createForeignKey(worldID, "ID"); + + public final com.querydsl.sql.ForeignKey wORLDMAMMALMammalsIDFK = + createForeignKey(mammalsID, "ID"); + + public SWorldMammal(String variable) { + super(SWorldMammal.class, forVariable(variable), "null", "WORLD_MAMMAL"); + addMetadata(); + } + + public SWorldMammal(String variable, String schema, String table) { + super(SWorldMammal.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SWorldMammal(String variable, String schema) { + super(SWorldMammal.class, forVariable(variable), schema, "WORLD_MAMMAL"); + addMetadata(); + } + + public SWorldMammal(Path path) { + super(path.getType(), path.getMetadata(), "null", "WORLD_MAMMAL"); + addMetadata(); + } + + public SWorldMammal(PathMetadata metadata) { + super(SWorldMammal.class, metadata, "null", "WORLD_MAMMAL"); + addMetadata(); + } + + public void addMetadata() { + addMetadata( + mammalsID, + ColumnMetadata.named("mammals_ID") + .withIndex(2) + .ofType(Types.BIGINT) + .withSize(19) + .notNull()); + addMetadata( + worldID, + ColumnMetadata.named("World_ID").withIndex(1).ofType(Types.BIGINT).withSize(19).notNull()); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SXmlTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SXmlTest.java new file mode 100644 index 0000000000..01eae96f78 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain/sql/SXmlTest.java @@ -0,0 +1,50 @@ +package com.querydsl.jpa.domain.sql; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.StringPath; +import com.querydsl.sql.ColumnMetadata; +import java.sql.Types; +import javax.annotation.processing.Generated; + +/** SXmlTest is a Querydsl query type for SXmlTest */ +@Generated("com.querydsl.sql.codegen.MetaDataSerializer") +public class SXmlTest extends com.querydsl.sql.RelationalPathBase { + + private static final long serialVersionUID = 963997633; + + public static final SXmlTest xmlTest = new SXmlTest("XML_TEST"); + + public final StringPath col = createString("col"); + + public SXmlTest(String variable) { + super(SXmlTest.class, forVariable(variable), "null", "XML_TEST"); + addMetadata(); + } + + public SXmlTest(String variable, String schema, String table) { + super(SXmlTest.class, forVariable(variable), schema, table); + addMetadata(); + } + + public SXmlTest(String variable, String schema) { + super(SXmlTest.class, forVariable(variable), schema, "XML_TEST"); + addMetadata(); + } + + public SXmlTest(Path path) { + super(path.getType(), path.getMetadata(), "null", "XML_TEST"); + addMetadata(); + } + + public SXmlTest(PathMetadata metadata) { + super(SXmlTest.class, metadata, "null", "XML_TEST"); + addMetadata(); + } + + public void addMetadata() { + addMetadata(col, ColumnMetadata.named("COL").withIndex(1).ofType(Types.VARCHAR).withSize(128)); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Category.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Category.java new file mode 100644 index 0000000000..564c0ee70e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Category.java @@ -0,0 +1,147 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain2; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import java.util.Date; +import java.util.Set; + +@Entity +@Table(name = "category_") +public class Category { + + @Id private long id; + + private String categoryName; + + private String categoryDescription; + + private double createdBy; + + private double modifiedBy; + + @Temporal(TemporalType.TIMESTAMP) + private Date creationDate; + + @Temporal(TemporalType.TIMESTAMP) + private Date modificationDate; + + private double deletedBy; + + @Temporal(TemporalType.TIMESTAMP) + private Date deleteDate; + + @OneToMany + @JoinTable( + joinColumns = @JoinColumn(name = "parentId"), + inverseJoinColumns = @JoinColumn(name = "childId")) + private Set childCategories; + + @OneToMany private Set properties; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + + public String getCategoryDescription() { + return categoryDescription; + } + + public void setCategoryDescription(String categoryDescription) { + this.categoryDescription = categoryDescription; + } + + public double getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(double createdBy) { + this.createdBy = createdBy; + } + + public double getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(double modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public Date getCreationDate() { + return new Date(creationDate.getTime()); + } + + public void setCreationDate(Date creationDate) { + this.creationDate = new Date(creationDate.getTime()); + } + + public Date getModificationDate() { + return new Date(modificationDate.getTime()); + } + + public void setModificationDate(Date modificationDate) { + this.modificationDate = new Date(modificationDate.getTime()); + } + + public double getDeletedBy() { + return deletedBy; + } + + public void setDeletedBy(double deletedBy) { + this.deletedBy = deletedBy; + } + + public Date getDeleteDate() { + return new Date(deleteDate.getTime()); + } + + public void setDeleteDate(Date deleteDate) { + this.deleteDate = new Date(deleteDate.getTime()); + } + + public Set getChildCategories() { + return childCategories; + } + + public void setChildCategories(Set childCategories) { + this.childCategories = childCategories; + } + + public Set getProperties() { + return properties; + } + + public void setProperties(Set properties) { + this.properties = properties; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/CategoryProp.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/CategoryProp.java new file mode 100644 index 0000000000..cc4c8a130e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/CategoryProp.java @@ -0,0 +1,63 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain2; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +@Entity +@Table(name = "categoryprop_") +public class CategoryProp { + + @Id private long id; + + private long categoryId; + + private String propName; + + private String propValue; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public long getCategoryId() { + return categoryId; + } + + public void setCategoryId(long categoryId) { + this.categoryId = categoryId; + } + + public String getPropName() { + return propName; + } + + public void setPropName(String propName) { + this.propName = propName; + } + + public String getPropValue() { + return propValue; + } + + public void setPropValue(String propValue) { + this.propValue = propValue; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Child.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Child.java new file mode 100644 index 0000000000..89e21a9bb0 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Child.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain2; + +import jakarta.persistence.Embeddable; + +@Embeddable +public class Child { + + private String childName; + + public String getChildName() { + return childName; + } + + public void setChildName(String childName) { + this.childName = childName; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Contact.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Contact.java new file mode 100644 index 0000000000..8c1ef485f4 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Contact.java @@ -0,0 +1,53 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain2; + +public class Contact { + + private long id; + + private String firstName, lastName, email; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Document2.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Document2.java new file mode 100644 index 0000000000..ea24470237 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Document2.java @@ -0,0 +1,159 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain2; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import java.util.Date; + +@Entity +@Table(name = "document2_") +public class Document2 { + + @Id private long id; + + private String documentTitle; + + private String documentBody; + + private String documentSummary; + + private double createdBy; + + @Temporal(TemporalType.TIMESTAMP) + private Date creationDate; + + private double modifiedBy; + + @Temporal(TemporalType.TIMESTAMP) + private Date modificationDate; + + private double deletedBy; + + @Temporal(TemporalType.TIMESTAMP) + private Date deletedDate; + + private double documentVersion; + + private double documentStatus; + + private double entryId; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getDocumentTitle() { + return documentTitle; + } + + public void setDocumentTitle(String documentTitle) { + this.documentTitle = documentTitle; + } + + public String getDocumentBody() { + return documentBody; + } + + public void setDocumentBody(String documentBody) { + this.documentBody = documentBody; + } + + public String getDocumentSummary() { + return documentSummary; + } + + public void setDocumentSummary(String documentSummary) { + this.documentSummary = documentSummary; + } + + public double getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(double createdBy) { + this.createdBy = createdBy; + } + + public Date getCreationDate() { + return new Date(creationDate.getTime()); + } + + public void setCreationDate(Date creationDate) { + this.creationDate = new Date(creationDate.getTime()); + } + + public double getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(double modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public Date getModificationDate() { + return new Date(modificationDate.getTime()); + } + + public void setModificationDate(Date modificationDate) { + this.modificationDate = new Date(modificationDate.getTime()); + } + + public double getDeletedBy() { + return deletedBy; + } + + public void setDeletedBy(double deletedBy) { + this.deletedBy = deletedBy; + } + + public Date getDeletedDate() { + return new Date(deletedDate.getTime()); + } + + public void setDeletedDate(Date deletedDate) { + this.deletedDate = new Date(deletedDate.getTime()); + } + + public double getDocumentVersion() { + return documentVersion; + } + + public void setDocumentVersion(double documentVersion) { + this.documentVersion = documentVersion; + } + + public double getDocumentStatus() { + return documentStatus; + } + + public void setDocumentStatus(double documentStatus) { + this.documentStatus = documentStatus; + } + + public double getEntryId() { + return entryId; + } + + public void setEntryId(double entryId) { + this.entryId = entryId; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/DocumentProp.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/DocumentProp.java new file mode 100644 index 0000000000..6f6f3028ca --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/DocumentProp.java @@ -0,0 +1,69 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain2; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +@Entity +@Table(name = "documentprop_") +public class DocumentProp { + + @Id private long id; + + private double documentId; + + private String propName, propValue, propValueDetails; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public double getDocumentId() { + return documentId; + } + + public void setDocumentId(double documentId) { + this.documentId = documentId; + } + + public String getPropName() { + return propName; + } + + public void setPropName(String propName) { + this.propName = propName; + } + + public String getPropValue() { + return propValue; + } + + public void setPropValue(String propValue) { + this.propValue = propValue; + } + + public String getPropValueDetails() { + return propValueDetails; + } + + public void setPropValueDetails(String propValueDetails) { + this.propValueDetails = propValueDetails; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Domain2.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Domain2.java new file mode 100644 index 0000000000..28841a73ba --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Domain2.java @@ -0,0 +1,32 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain2; + +import java.util.Arrays; +import java.util.List; + +public final class Domain2 { + + private Domain2() {} + + public static final List> classes = + Arrays.>asList( + Category.class, + CategoryProp.class, + Contact.class, + Document2.class, + DocumentProp.class, + User2.class, + UserProp.class); +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Parent.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Parent.java new file mode 100644 index 0000000000..730b07e0d0 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/Parent.java @@ -0,0 +1,54 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain2; + +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +@Entity +@Table(name = "parent_") +public class Parent { + + @Id private long id; + + private String name; + + @Embedded private Child child; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Child getChild() { + return child; + } + + public void setChild(Child child) { + this.child = child; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/User2.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/User2.java new file mode 100644 index 0000000000..cdbb9335e0 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/User2.java @@ -0,0 +1,153 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain2; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import java.util.Date; +import java.util.Set; + +@Entity +@Table(name = "user2_") +public class User2 { + + @Id private long id; + + private String userName, userPassword, userFirstName, userEmail, userLastName; + + @Temporal(TemporalType.TIMESTAMP) + private Date creationDate; + + private double createdBy; + + @Temporal(TemporalType.TIMESTAMP) + private Date modificationDate; + + private double modifiedBy; + + @Temporal(TemporalType.TIMESTAMP) + private Date deleteDate; + + private double deletedBy; + + @OneToMany private Set properties; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserPassword() { + return userPassword; + } + + public void setUserPassword(String userPassword) { + this.userPassword = userPassword; + } + + public String getUserFirstName() { + return userFirstName; + } + + public void setUserFirstName(String userFirstName) { + this.userFirstName = userFirstName; + } + + public String getUserEmail() { + return userEmail; + } + + public void setUserEmail(String userEmail) { + this.userEmail = userEmail; + } + + public String getUserLastName() { + return userLastName; + } + + public void setUserLastName(String userLastName) { + this.userLastName = userLastName; + } + + public Date getCreationDate() { + return new Date(creationDate.getTime()); + } + + public void setCreationDate(Date creationDate) { + this.creationDate = new Date(creationDate.getTime()); + } + + public double getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(double createdBy) { + this.createdBy = createdBy; + } + + public Date getModificationDate() { + return new Date(modificationDate.getTime()); + } + + public void setModificationDate(Date modificationDate) { + this.modificationDate = new Date(modificationDate.getTime()); + } + + public double getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(double modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public Date getDeleteDate() { + return new Date(deleteDate.getTime()); + } + + public void setDeleteDate(Date deleteDate) { + this.deleteDate = new Date(deleteDate.getTime()); + } + + public double getDeletedBy() { + return deletedBy; + } + + public void setDeletedBy(double deletedBy) { + this.deletedBy = deletedBy; + } + + public Set getProperties() { + return properties; + } + + public void setProperties(Set properties) { + this.properties = properties; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/UserProp.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/UserProp.java new file mode 100644 index 0000000000..50c87fb1da --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain2/UserProp.java @@ -0,0 +1,139 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain2; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import java.util.Date; +import java.util.Set; + +@Entity +@Table(name = "userprop_") +public class UserProp { + + @Id private long id; + + private String categoryName, categoryDescription; + + private double createdBy; + + @Temporal(TemporalType.TIMESTAMP) + private Date creationDate; + + private double modifiedBy; + + @Temporal(TemporalType.TIMESTAMP) + private Date modificationDate; + + private double deletedBy; + + @Temporal(TemporalType.TIMESTAMP) + private Date deleteDate; + + @OneToMany private Set childCategories; + + @OneToMany private Set properties; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + + public String getCategoryDescription() { + return categoryDescription; + } + + public void setCategoryDescription(String categoryDescription) { + this.categoryDescription = categoryDescription; + } + + public double getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(double createdBy) { + this.createdBy = createdBy; + } + + public Date getCreationDate() { + return new Date(creationDate.getTime()); + } + + public void setCreationDate(Date creationDate) { + this.creationDate = new Date(creationDate.getTime()); + } + + public double getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(double modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public Date getModificationDate() { + return new Date(modificationDate.getTime()); + } + + public void setModificationDate(Date modificationDate) { + this.modificationDate = new Date(modificationDate.getTime()); + } + + public double getDeletedBy() { + return deletedBy; + } + + public void setDeletedBy(double deletedBy) { + this.deletedBy = deletedBy; + } + + public Date getDeleteDate() { + return new Date(deleteDate.getTime()); + } + + public void setDeleteDate(Date deleteDate) { + this.deleteDate = new Date(deleteDate.getTime()); + } + + public Set getChildCategories() { + return childCategories; + } + + public void setChildCategories(Set childCategories) { + this.childCategories = childCategories; + } + + public Set getProperties() { + return properties; + } + + public void setProperties(Set properties) { + this.properties = properties; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain3/HardwareStore.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain3/HardwareStore.java new file mode 100644 index 0000000000..1bfbead883 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain3/HardwareStore.java @@ -0,0 +1,29 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain3; + +public class HardwareStore extends Store { + + private static final long serialVersionUID = 2725944536560445206L; + + private String storeCode; + + public String getStoreCode() { + return storeCode; + } + + public void setStoreCode(String storeCode) { + this.storeCode = storeCode; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain3/Store.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain3/Store.java new file mode 100644 index 0000000000..4784232983 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain3/Store.java @@ -0,0 +1,101 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain3; + +import java.io.Serializable; + +public class Store implements Serializable { + + private static final long serialVersionUID = 7221730732392000227L; + + private String code; + + private String name; + + private String address; + + private String city; + + private String phoneDetails; + + private String faxDetails; + + private String zipCode; + + private String chainCode; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getPhoneDetails() { + return phoneDetails; + } + + public void setPhoneDetails(String phoneDetails) { + this.phoneDetails = phoneDetails; + } + + public String getFaxDetails() { + return faxDetails; + } + + public void setFaxDetails(String faxDetails) { + this.faxDetails = faxDetails; + } + + public String getZipCode() { + return zipCode; + } + + public void setZipCode(String zipCode) { + this.zipCode = zipCode; + } + + public String getChainCode() { + return chainCode; + } + + public void setChainCode(String chainCode) { + this.chainCode = chainCode; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/BookDefinition.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/BookDefinition.java new file mode 100644 index 0000000000..99b34410e3 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/BookDefinition.java @@ -0,0 +1,66 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain4; + +import jakarta.persistence.Access; +import jakarta.persistence.AccessType; +import jakarta.persistence.Basic; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Embeddable; +import jakarta.persistence.OrderColumn; +import java.io.Serializable; +import java.util.List; + +@Embeddable +@Access(AccessType.PROPERTY) +public class BookDefinition implements Serializable { + + private static final long serialVersionUID = 3570098308959717614L; + + private String name; + + private String description; + + private List bookMarks; + + @Basic + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Basic + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @ElementCollection() + @CollectionTable(name = "book_bookmarks") + @OrderColumn() + public List getBookMarks() { + return bookMarks; + } + + public void setBookMarks(List bookMarks) { + this.bookMarks = bookMarks; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/BookID.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/BookID.java new file mode 100644 index 0000000000..b2e586f472 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/BookID.java @@ -0,0 +1,43 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain4; + +import jakarta.persistence.Access; +import jakarta.persistence.AccessType; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.io.Serializable; + +@Entity +@Table(name = "bookid_") +@Access(AccessType.PROPERTY) +public class BookID implements Serializable { + + private static final long serialVersionUID = -3205025118656391776L; + + private Long identity; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + public Long getIdentity() { + return identity; + } + + public void setIdentity(Long identity) { + this.identity = identity; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/BookMark.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/BookMark.java new file mode 100644 index 0000000000..0b104d5f4f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/BookMark.java @@ -0,0 +1,49 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain4; + +import jakarta.persistence.Access; +import jakarta.persistence.AccessType; +import jakarta.persistence.Basic; +import jakarta.persistence.Embeddable; +import java.io.Serializable; + +@Embeddable +@Access(AccessType.PROPERTY) +public class BookMark implements Serializable { + + private static final long serialVersionUID = 8027009758015834551L; + + private Long page; + + private String comment; + + @Basic + public Long getPage() { + return page; + } + + public void setPage(Long page) { + this.page = page; + } + + @Basic + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/BookVersion.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/BookVersion.java new file mode 100644 index 0000000000..65ac968f8e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/BookVersion.java @@ -0,0 +1,79 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain4; + +import jakarta.persistence.Access; +import jakarta.persistence.AccessType; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Embedded; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.MapsId; +import jakarta.persistence.Table; +import java.io.Serializable; + +@Entity +@Table(name = "bookversion_") +@Access(AccessType.PROPERTY) +public class BookVersion implements Serializable { + + private static final long serialVersionUID = -1697470794339057030L; + + private BookID bookID; + + private BookVersionPK pk = new BookVersionPK(); + + private Library library; + + private BookDefinition definition; + + @EmbeddedId + public BookVersionPK getPk() { + return pk; + } + + public void setPk(BookVersionPK pk) { + this.pk = pk; + } + + @MapsId("bookID") + @ManyToOne(cascade = CascadeType.ALL) + public BookID getBookID() { + return bookID; + } + + public void setBookID(BookID bookID) { + this.bookID = bookID; + } + + @MapsId("library") + @ManyToOne(cascade = CascadeType.ALL) + public Library getLibrary() { + return library; + } + + public void setLibrary(Library library) { + this.library = library; + } + + @Embedded + public BookDefinition getDefinition() { + return definition; + } + + public void setDefinition(BookDefinition definition) { + this.definition = definition; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/BookVersionPK.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/BookVersionPK.java new file mode 100644 index 0000000000..b1b73e0670 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/BookVersionPK.java @@ -0,0 +1,43 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain4; + +import jakarta.persistence.Embeddable; +import java.io.Serializable; + +@Embeddable +public class BookVersionPK implements Serializable { + + private static final long serialVersionUID = 8483495681236266676L; + + private Long bookID; + + private Long library; + + public Long getBookID() { + return bookID; + } + + public void setBookID(Long bookID) { + this.bookID = bookID; + } + + public Long getLibrary() { + return library; + } + + public void setLibrary(Long library) { + this.library = library; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/Library.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/Library.java new file mode 100644 index 0000000000..399e09edf3 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain4/Library.java @@ -0,0 +1,43 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.domain4; + +import jakarta.persistence.Access; +import jakarta.persistence.AccessType; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.io.Serializable; + +@Entity +@Table(name = "library_") +@Access(AccessType.PROPERTY) +public class Library implements Serializable { + + private static final long serialVersionUID = 6360420736014459567L; + + private Long identity; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + public Long getIdentity() { + return identity; + } + + public void setIdentity(Long identity) { + this.identity = identity; + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain5/MyEmbeddedAttribute.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain5/MyEmbeddedAttribute.java new file mode 100644 index 0000000000..a4890073c1 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain5/MyEmbeddedAttribute.java @@ -0,0 +1,9 @@ +package com.querydsl.jpa.domain5; + +import jakarta.persistence.Embeddable; +import jakarta.persistence.ManyToOne; + +@Embeddable +public class MyEmbeddedAttribute { + @ManyToOne private MyOtherEntity attributeWithInitProblem; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain5/MyEntity.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain5/MyEntity.java new file mode 100644 index 0000000000..059b219dc2 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain5/MyEntity.java @@ -0,0 +1,16 @@ +package com.querydsl.jpa.domain5; + +import com.querydsl.core.annotations.QueryInit; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; + +@Entity +public class MyEntity extends MyMappedSuperclass { + + @Id private int id; + + @Embedded + @QueryInit("*") + private MyEmbeddedAttribute embeddedAttribute; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain5/MyMappedSuperclass.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain5/MyMappedSuperclass.java new file mode 100644 index 0000000000..5382a22091 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain5/MyMappedSuperclass.java @@ -0,0 +1,6 @@ +package com.querydsl.jpa.domain5; + +import jakarta.persistence.MappedSuperclass; + +@MappedSuperclass +public class MyMappedSuperclass {} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain5/MyOtherEntity.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain5/MyOtherEntity.java new file mode 100644 index 0000000000..ff9128e159 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/domain5/MyOtherEntity.java @@ -0,0 +1,10 @@ +package com.querydsl.jpa.domain5; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; + +@Entity +public class MyOtherEntity { + + @Id private int id; +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/AbstractJPASuite.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/AbstractJPASuite.java new file mode 100644 index 0000000000..81a1873c9d --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/AbstractJPASuite.java @@ -0,0 +1,16 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.jpa.Mode; +import org.junit.AfterClass; +import org.junit.experimental.runners.Enclosed; +import org.junit.runner.RunWith; + +@RunWith(Enclosed.class) +public abstract class AbstractJPASuite { + + @AfterClass + public static void tearDownClass() throws Exception { + Mode.mode.remove(); + Mode.target.remove(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/AbstractSuite.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/AbstractSuite.java new file mode 100644 index 0000000000..30e9c93442 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/AbstractSuite.java @@ -0,0 +1,16 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.jpa.Mode; +import org.junit.AfterClass; +import org.junit.experimental.runners.Enclosed; +import org.junit.runner.RunWith; + +@RunWith(Enclosed.class) +public abstract class AbstractSuite { + + @AfterClass + public static void tearDownClass() throws Exception { + Mode.mode.remove(); + Mode.target.remove(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/DerbyEclipseLinkTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/DerbyEclipseLinkTest.java new file mode 100644 index 0000000000..79671ede15 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/DerbyEclipseLinkTest.java @@ -0,0 +1,49 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.Derby; +import com.querydsl.jpa.JPABase; +import com.querydsl.jpa.JPAIntegrationBase; +import com.querydsl.jpa.JPASQLBase; +import com.querydsl.jpa.Mode; +import com.querydsl.jpa.SerializationBase; +import org.junit.BeforeClass; +import org.junit.experimental.categories.Category; + +@Category(Derby.class) +public class DerbyEclipseLinkTest extends AbstractJPASuite { + + public static class JPA extends JPABase { + @Override + public void order_stringValue() { + // not supported in MySQL/EclipseLink + } + + @Override + public void order_stringValue_to_integer() { + // not supported in MySQL/EclipseLink + } + + @Override + public void order_stringValue_toLong() { + // not supported in MySQL/EclipseLink + } + + @Override + public void order_stringValue_toBigInteger() { + // not supported in MySQL/EclipseLink + } + } + + public static class JPASQL extends JPASQLBase {} + + public static class JPAIntegration extends JPAIntegrationBase {} + + public static class Serialization extends SerializationBase {} + + @BeforeClass + public static void setUp() throws Exception { + Mode.mode.set("derby-eclipselink"); + Mode.target.set(Target.DERBY); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/DerbySuiteTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/DerbySuiteTest.java new file mode 100644 index 0000000000..accbeb9c07 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/DerbySuiteTest.java @@ -0,0 +1,35 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.Derby; +import com.querydsl.jpa.HibernateBase; +import com.querydsl.jpa.HibernateSQLBase; +import com.querydsl.jpa.JPABase; +import com.querydsl.jpa.JPAIntegrationBase; +import com.querydsl.jpa.JPASQLBase; +import com.querydsl.jpa.Mode; +import com.querydsl.jpa.SerializationBase; +import org.junit.BeforeClass; +import org.junit.experimental.categories.Category; + +@Category(Derby.class) +public class DerbySuiteTest extends AbstractSuite { + + public static class JPA extends JPABase {} + + public static class JPASQL extends JPASQLBase {} + + public static class JPAIntegration extends JPAIntegrationBase {} + + public static class Serialization extends SerializationBase {} + + public static class Hibernate extends HibernateBase {} + + public static class HibernateSQL extends HibernateSQLBase {} + + @BeforeClass + public static void setUp() throws Exception { + Mode.mode.set("derby"); + Mode.target.set(Target.DERBY); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/H2BatooTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/H2BatooTest.java new file mode 100644 index 0000000000..114076a629 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/H2BatooTest.java @@ -0,0 +1,31 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.H2; +import com.querydsl.jpa.JPABase; +import com.querydsl.jpa.JPAIntegrationBase; +import com.querydsl.jpa.JPASQLBase; +import com.querydsl.jpa.Mode; +import com.querydsl.jpa.SerializationBase; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.experimental.categories.Category; + +@Ignore +@Category(H2.class) +public class H2BatooTest extends AbstractJPASuite { + + public static class JPA extends JPABase {} + + public static class JPASQL extends JPASQLBase {} + + public static class JPAIntegration extends JPAIntegrationBase {} + + public static class Serialization extends SerializationBase {} + + @BeforeClass + public static void setUp() throws Exception { + Mode.mode.set("h2-batoo"); + Mode.target.set(Target.H2); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/H2EclipseLinkTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/H2EclipseLinkTest.java new file mode 100644 index 0000000000..6de0b54902 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/H2EclipseLinkTest.java @@ -0,0 +1,29 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.H2; +import com.querydsl.jpa.JPABase; +import com.querydsl.jpa.JPAIntegrationBase; +import com.querydsl.jpa.JPASQLBase; +import com.querydsl.jpa.Mode; +import com.querydsl.jpa.SerializationBase; +import org.junit.BeforeClass; +import org.junit.experimental.categories.Category; + +@Category(H2.class) +public class H2EclipseLinkTest extends AbstractJPASuite { + + public static class JPA extends JPABase {} + + public static class JPASQL extends JPASQLBase {} + + public static class JPAIntegration extends JPAIntegrationBase {} + + public static class Serialization extends SerializationBase {} + + @BeforeClass + public static void setUp() throws Exception { + Mode.mode.set("h2-eclipselink"); + Mode.target.set(Target.H2); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/H2OpenJPATest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/H2OpenJPATest.java new file mode 100644 index 0000000000..6ba451fca5 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/H2OpenJPATest.java @@ -0,0 +1,31 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.H2; +import com.querydsl.jpa.JPABase; +import com.querydsl.jpa.JPAIntegrationBase; +import com.querydsl.jpa.JPASQLBase; +import com.querydsl.jpa.Mode; +import com.querydsl.jpa.SerializationBase; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.experimental.categories.Category; + +@Ignore +@Category(H2.class) +public class H2OpenJPATest extends AbstractJPASuite { + + public static class JPA extends JPABase {} + + public static class JPASQL extends JPASQLBase {} + + public static class JPAIntegration extends JPAIntegrationBase {} + + public static class Serialization extends SerializationBase {} + + @BeforeClass + public static void setUp() throws Exception { + Mode.mode.set("h2-openjpa"); + Mode.target.set(Target.H2); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/H2SuiteTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/H2SuiteTest.java new file mode 100644 index 0000000000..dd8d97e83c --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/H2SuiteTest.java @@ -0,0 +1,35 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.H2; +import com.querydsl.jpa.HibernateBase; +import com.querydsl.jpa.HibernateSQLBase; +import com.querydsl.jpa.JPABase; +import com.querydsl.jpa.JPAIntegrationBase; +import com.querydsl.jpa.JPASQLBase; +import com.querydsl.jpa.Mode; +import com.querydsl.jpa.SerializationBase; +import org.junit.BeforeClass; +import org.junit.experimental.categories.Category; + +@Category(H2.class) +public class H2SuiteTest extends AbstractSuite { + + public static class JPA extends JPABase {} + + public static class JPASQL extends JPASQLBase {} + + public static class JPAIntegration extends JPAIntegrationBase {} + + public static class Serialization extends SerializationBase {} + + public static class Hibernate extends HibernateBase {} + + public static class HibernateSQL extends HibernateSQLBase {} + + @BeforeClass + public static void setUp() throws Exception { + Mode.mode.set("h2"); + Mode.target.set(Target.H2); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/HSQLDBEclipseLinkTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/HSQLDBEclipseLinkTest.java new file mode 100644 index 0000000000..121fe8e488 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/HSQLDBEclipseLinkTest.java @@ -0,0 +1,29 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.HSQLDB; +import com.querydsl.jpa.JPABase; +import com.querydsl.jpa.JPAIntegrationBase; +import com.querydsl.jpa.JPASQLBase; +import com.querydsl.jpa.Mode; +import com.querydsl.jpa.SerializationBase; +import org.junit.BeforeClass; +import org.junit.experimental.categories.Category; + +@Category(HSQLDB.class) +public class HSQLDBEclipseLinkTest extends AbstractJPASuite { + + public static class JPA extends JPABase {} + + public static class JPASQL extends JPASQLBase {} + + public static class JPAIntegration extends JPAIntegrationBase {} + + public static class Serialization extends SerializationBase {} + + @BeforeClass + public static void setUp() throws Exception { + Mode.mode.set("hsqldb-eclipselink"); + Mode.target.set(Target.HSQLDB); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/HSQLDBSuiteTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/HSQLDBSuiteTest.java new file mode 100644 index 0000000000..88339ae879 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/HSQLDBSuiteTest.java @@ -0,0 +1,35 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.HSQLDB; +import com.querydsl.jpa.HibernateBase; +import com.querydsl.jpa.HibernateSQLBase; +import com.querydsl.jpa.JPABase; +import com.querydsl.jpa.JPAIntegrationBase; +import com.querydsl.jpa.JPASQLBase; +import com.querydsl.jpa.Mode; +import com.querydsl.jpa.SerializationBase; +import org.junit.BeforeClass; +import org.junit.experimental.categories.Category; + +@Category(HSQLDB.class) +public class HSQLDBSuiteTest extends AbstractSuite { + + public static class JPA extends JPABase {} + + public static class JPASQL extends JPASQLBase {} + + public static class JPAIntegration extends JPAIntegrationBase {} + + public static class Serialization extends SerializationBase {} + + public static class Hibernate extends HibernateBase {} + + public static class HibernateSQL extends HibernateSQLBase {} + + @BeforeClass + public static void setUp() throws Exception { + Mode.mode.set("hsqldb"); + Mode.target.set(Target.HSQLDB); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/MSSQLSuiteTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/MSSQLSuiteTest.java new file mode 100644 index 0000000000..1e51c03093 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/MSSQLSuiteTest.java @@ -0,0 +1,35 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.SQLServer; +import com.querydsl.jpa.HibernateBase; +import com.querydsl.jpa.HibernateSQLBase; +import com.querydsl.jpa.JPABase; +import com.querydsl.jpa.JPAIntegrationBase; +import com.querydsl.jpa.JPASQLBase; +import com.querydsl.jpa.Mode; +import com.querydsl.jpa.SerializationBase; +import org.junit.BeforeClass; +import org.junit.experimental.categories.Category; + +@Category(SQLServer.class) +public class MSSQLSuiteTest extends AbstractSuite { + + public static class JPA extends JPABase {} + + public static class JPASQL extends JPASQLBase {} + + public static class JPAIntegration extends JPAIntegrationBase {} + + public static class Serialization extends SerializationBase {} + + public static class Hibernate extends HibernateBase {} + + public static class HibernateSQL extends HibernateSQLBase {} + + @BeforeClass + public static void setUp() throws Exception { + Mode.mode.set("mssql"); + Mode.target.set(Target.SQLSERVER); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/MySQLEclipseLinkTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/MySQLEclipseLinkTest.java new file mode 100644 index 0000000000..832b1a0fcd --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/MySQLEclipseLinkTest.java @@ -0,0 +1,69 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.MySQL; +import com.querydsl.jpa.JPABase; +import com.querydsl.jpa.JPAIntegrationBase; +import com.querydsl.jpa.JPASQLBase; +import com.querydsl.jpa.Mode; +import com.querydsl.jpa.SerializationBase; +import org.junit.BeforeClass; +import org.junit.experimental.categories.Category; + +@Category(MySQL.class) +public class MySQLEclipseLinkTest extends AbstractJPASuite { + + public static class JPA extends JPABase { + @Override + public void cast() { + // not supported in MySQL/EclipseLink + } + + @Override + public void enum_startsWith() { + // not supported in MySQL/EclipseLink + } + + @Override + public void order_stringValue() { + // not supported in MySQL/EclipseLink + } + + @Override + public void order_stringValue_to_integer() { + // not supported in MySQL/EclipseLink + } + + @Override + public void order_stringValue_toLong() { + // not supported in MySQL/EclipseLink + } + + @Override + public void order_stringValue_toBigInteger() { + // not supported in MySQL/EclipseLink + } + + @Override + public void order_nullsFirst() { + // not supported in MySQL/EclipseLink + } + + @Override + public void order_nullsLast() { + // not supported in MySQL/EclipseLink + } + } + + public static class JPASQL extends JPASQLBase {} + + public static class JPAIntegration extends JPAIntegrationBase {} + + public static class Serialization extends SerializationBase {} + + @BeforeClass + public static void setUp() throws Exception { + Mode.mode.set("mysql-eclipselink"); + Mode.target.set(Target.MYSQL); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/MySQLSuiteTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/MySQLSuiteTest.java new file mode 100644 index 0000000000..6af143c668 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/MySQLSuiteTest.java @@ -0,0 +1,45 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.MySQL; +import com.querydsl.jpa.HibernateBase; +import com.querydsl.jpa.HibernateSQLBase; +import com.querydsl.jpa.JPABase; +import com.querydsl.jpa.JPAIntegrationBase; +import com.querydsl.jpa.JPASQLBase; +import com.querydsl.jpa.Mode; +import com.querydsl.jpa.SerializationBase; +import org.junit.BeforeClass; +import org.junit.experimental.categories.Category; + +@Category(MySQL.class) +public class MySQLSuiteTest extends AbstractSuite { + + public static class JPA extends JPABase { + @Override + public void order_stringValue_toLong() { + // not supported + } + } + + public static class JPASQL extends JPASQLBase {} + + public static class JPAIntegration extends JPAIntegrationBase {} + + public static class Serialization extends SerializationBase {} + + public static class Hibernate extends HibernateBase { + @Override + public void order_stringValue_toLong() { + // not supported + } + } + + public static class HibernateSQL extends HibernateSQLBase {} + + @BeforeClass + public static void setUp() throws Exception { + Mode.mode.set("mysql"); + Mode.target.set(Target.MYSQL); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/OracleSuiteTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/OracleSuiteTest.java new file mode 100644 index 0000000000..a77959409e --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/OracleSuiteTest.java @@ -0,0 +1,51 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.Oracle; +import com.querydsl.jpa.HibernateBase; +import com.querydsl.jpa.HibernateSQLBase; +import com.querydsl.jpa.JPABase; +import com.querydsl.jpa.JPAIntegrationBase; +import com.querydsl.jpa.JPASQLBase; +import com.querydsl.jpa.Mode; +import com.querydsl.jpa.SerializationBase; +import java.util.TimeZone; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.experimental.categories.Category; + +@Category(Oracle.class) +public class OracleSuiteTest extends AbstractSuite { + + public static class JPA extends JPABase {} + + public static class JPASQL extends JPASQLBase {} + + public static class JPAIntegration extends JPAIntegrationBase {} + + public static class Serialization extends SerializationBase {} + + public static class Hibernate extends HibernateBase {} + + public static class HibernateSQL extends HibernateSQLBase {} + + private static TimeZone defaultZone; + + @BeforeClass + public static void setUp() throws Exception { + Mode.mode.set("oracle"); + Mode.target.set(Target.ORACLE); + + // change time zone to work around ORA-01882 + // see https://gist.github.com/jarek-przygodzki/cbea3cedae3aef2bbbe0ff6b057e8321 + // the test may work fine on your machine without this, but it fails when the GitHub runner + // executes it + defaultZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + } + + @AfterClass + public static void tearDown() { + TimeZone.setDefault(defaultZone); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/PostgreSQLEclipseLinkSuiteTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/PostgreSQLEclipseLinkSuiteTest.java new file mode 100644 index 0000000000..c7ba9e63b8 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/PostgreSQLEclipseLinkSuiteTest.java @@ -0,0 +1,29 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.PostgreSQL; +import com.querydsl.jpa.JPABase; +import com.querydsl.jpa.JPAIntegrationBase; +import com.querydsl.jpa.JPASQLBase; +import com.querydsl.jpa.Mode; +import com.querydsl.jpa.SerializationBase; +import org.junit.BeforeClass; +import org.junit.experimental.categories.Category; + +@Category(PostgreSQL.class) +public class PostgreSQLEclipseLinkSuiteTest extends AbstractJPASuite { + + public static class JPA extends JPABase {} + + public static class JPASQL extends JPASQLBase {} + + public static class JPAIntegration extends JPAIntegrationBase {} + + public static class Serialization extends SerializationBase {} + + @BeforeClass + public static void setUp() throws Exception { + Mode.mode.set("postgresql-eclipselink"); + Mode.target.set(Target.POSTGRESQL); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/PostgreSQLSuiteTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/PostgreSQLSuiteTest.java new file mode 100644 index 0000000000..26a249c6a4 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/suites/PostgreSQLSuiteTest.java @@ -0,0 +1,35 @@ +package com.querydsl.jpa.suites; + +import com.querydsl.core.Target; +import com.querydsl.core.testutil.PostgreSQL; +import com.querydsl.jpa.HibernateBase; +import com.querydsl.jpa.HibernateSQLBase; +import com.querydsl.jpa.JPABase; +import com.querydsl.jpa.JPAIntegrationBase; +import com.querydsl.jpa.JPASQLBase; +import com.querydsl.jpa.Mode; +import com.querydsl.jpa.SerializationBase; +import org.junit.BeforeClass; +import org.junit.experimental.categories.Category; + +@Category(PostgreSQL.class) +public class PostgreSQLSuiteTest extends AbstractSuite { + + public static class JPA extends JPABase {} + + public static class JPASQL extends JPASQLBase {} + + public static class JPAIntegration extends JPAIntegrationBase {} + + public static class Serialization extends SerializationBase {} + + public static class Hibernate extends HibernateBase {} + + public static class HibernateSQL extends HibernateSQLBase {} + + @BeforeClass + public static void setUp() throws Exception { + Mode.mode.set("postgresql"); + Mode.target.set(Target.POSTGRESQL); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/support/DialectSupportTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/support/DialectSupportTest.java new file mode 100644 index 0000000000..6cb25cea82 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/support/DialectSupportTest.java @@ -0,0 +1,19 @@ +package com.querydsl.jpa.support; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.types.Ops; +import com.querydsl.core.types.Template; +import com.querydsl.sql.HSQLDBTemplates; +import org.junit.Test; + +public class DialectSupportTest { + + @Test + public void convert() { + Template trim = HSQLDBTemplates.DEFAULT.getTemplate(Ops.TRIM); + assertThat(DialectSupport.convert(trim)).isEqualTo("trim(both from ?1)"); + Template concat = HSQLDBTemplates.DEFAULT.getTemplate(Ops.CONCAT); + assertThat(DialectSupport.convert(concat)).isEqualTo("?1 || ?2"); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/support/JPAPathBuilderValidatorTest.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/support/JPAPathBuilderValidatorTest.java new file mode 100644 index 0000000000..7f5edccfa3 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/support/JPAPathBuilderValidatorTest.java @@ -0,0 +1,36 @@ +package com.querydsl.jpa.support; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.jpa.domain.Cat; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; +import java.util.Collection; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class JPAPathBuilderValidatorTest { + + private EntityManagerFactory entityManagerFactory; + + @Before + public void setUp() { + entityManagerFactory = Persistence.createEntityManagerFactory("h2"); + } + + @After + public void tearDown() { + entityManagerFactory.close(); + } + + @Test + public void validate() { + var validator = new JPAPathBuilderValidator(entityManagerFactory.getMetamodel()); + assertThat(validator.validate(Cat.class, "name", String.class)).isEqualTo(String.class); + assertThat(validator.validate(Cat.class, "kittens", Collection.class)).isEqualTo(Cat.class); + assertThat(validator.validate(Cat.class, "mate", Cat.class)).isEqualTo(Cat.class); + assertThat(validator.validate(Cat.class, "xxx", String.class)).isNull(); + assertThat(validator.validate(Object.class, "name", String.class)).isNull(); + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/testutil/HibernateTestRunner.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/testutil/HibernateTestRunner.java new file mode 100644 index 0000000000..d73c3f9f00 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/testutil/HibernateTestRunner.java @@ -0,0 +1,153 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.testutil; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.core.Target; +import com.querydsl.jpa.HibernateTest; +import com.querydsl.jpa.Mode; +import com.querydsl.jpa.domain.Domain; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.List; +import java.util.Properties; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.cfg.Configuration; +import org.hibernate.service.ServiceRegistry; +import org.junit.rules.MethodRule; +import org.junit.runner.Description; +import org.junit.runner.notification.Failure; +import org.junit.runner.notification.RunNotifier; +import org.junit.runners.BlockJUnit4ClassRunner; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.InitializationError; +import org.junit.runners.model.Statement; + +/** + * @author tiwe + */ +public class HibernateTestRunner extends BlockJUnit4ClassRunner { + + private SessionFactory sessionFactory; + + private Session session; + + private boolean isDerby = false; + + public HibernateTestRunner(Class klass) throws InitializationError { + super(klass); + } + + @Override + protected List rules(Object test) { + assertThat(test instanceof HibernateTest) + .as( + "In order to use the %s for %s, it should (directly or indirectly) implement %s" + .formatted( + HibernateTestRunner.class.getSimpleName(), + test.getClass(), + HibernateTest.class)) + .isTrue(); + + var rules = super.rules(test); + rules.add( + new MethodRule() { + @Override + public Statement apply( + final Statement base, FrameworkMethod method, final Object target) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + ((HibernateTest) target).setSession(session); + base.evaluate(); + } + }; + } + }); + return rules; + } + + @Override + public void run(final RunNotifier notifier) { + try { + start(); + super.run(notifier); + } catch (Exception e) { + e.printStackTrace(); + var failure = + new Failure(Description.createSuiteDescription(getTestClass().getJavaClass()), e); + notifier.fireTestFailure(failure); + } finally { + shutdown(); + } + } + + private void start() throws Exception { + Mode.mode.set("hsqldb"); + Mode.target.set(Target.HSQLDB); + + var cfg = new Configuration(); + for (Class cl : Domain.classes) { + cfg.addAnnotatedClass(cl); + } + var mode = Mode.mode.get() + ".properties"; + isDerby = mode.contains("derby"); + if (isDerby) { + Class.forName("org.apache.derby.jdbc.EmbeddedDriver").getDeclaredConstructor().newInstance(); + } + var props = new Properties(); + var is = HibernateTestRunner.class.getResourceAsStream(mode); + if (is == null) { + throw new IllegalArgumentException("No configuration available at classpath:" + mode); + } + props.load(is); + ServiceRegistry serviceRegistry = + new StandardServiceRegistryBuilder().applySettings(props).build(); + cfg.setProperties(props); + sessionFactory = cfg.buildSessionFactory(serviceRegistry); + session = sessionFactory.openSession(); + session.beginTransaction(); + } + + private void shutdown() { + if (session != null) { + try { + session.getTransaction().rollback(); + } finally { + session.close(); + session = null; + } + } + + if (sessionFactory != null) { + sessionFactory.getCache().evictAll(); + sessionFactory.close(); + sessionFactory = null; + } + + // clean shutdown of derby + if (isDerby) { + try { + DriverManager.getConnection("jdbc:derby:;shutdown=true"); + } catch (SQLException e) { + if (!e.getMessage().equals("Derby system shutdown.")) { + throw new RuntimeException(e); + } + } + } + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/testutil/JPATestRunner.java b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/testutil/JPATestRunner.java new file mode 100644 index 0000000000..176e6114cf --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/java/com/querydsl/jpa/testutil/JPATestRunner.java @@ -0,0 +1,137 @@ +/* + * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.querydsl.jpa.testutil; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.querydsl.jpa.JPATest; +import com.querydsl.jpa.Mode; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.List; +import org.junit.rules.MethodRule; +import org.junit.runner.Description; +import org.junit.runner.notification.Failure; +import org.junit.runner.notification.RunNotifier; +import org.junit.runners.BlockJUnit4ClassRunner; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.InitializationError; +import org.junit.runners.model.Statement; + +/** + * @author tiwe + */ +public class JPATestRunner extends BlockJUnit4ClassRunner { + + private EntityManagerFactory entityManagerFactory; + + private EntityManager entityManager; + + private boolean isDerby; + + public JPATestRunner(Class klass) throws InitializationError { + super(klass); + } + + @Override + protected List rules(Object test) { + assertThat(test instanceof JPATest) + .as( + "In order to use the %s for %s, it should (directly or indirectly) implement %s" + .formatted(JPATestRunner.class.getSimpleName(), test.getClass(), JPATest.class)) + .isTrue(); + + var rules = super.rules(test); + rules.add( + new MethodRule() { + @Override + public Statement apply( + final Statement base, FrameworkMethod method, final Object target) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + ((JPATest) target).setEntityManager(entityManager); + base.evaluate(); + } + }; + } + }); + return rules; + } + + @Override + public void run(final RunNotifier notifier) { + try { + start(); + super.run(notifier); + } catch (Exception e) { + e.printStackTrace(); + var failure = + new Failure(Description.createSuiteDescription(getTestClass().getJavaClass()), e); + notifier.fireTestFailure(failure); + } finally { + shutdown(); + } + } + + private void start() throws Exception { + var mode = Mode.mode.get(); + if (mode == null) { + mode = "h2perf"; + } + System.out.println(mode); + isDerby = mode.contains("derby"); + if (isDerby) { + Class.forName("org.apache.derby.jdbc.EmbeddedDriver").getDeclaredConstructor().newInstance(); + } + entityManagerFactory = Persistence.createEntityManagerFactory(mode); + entityManager = entityManagerFactory.createEntityManager(); + entityManager.getTransaction().begin(); + } + + private void shutdown() { + if (entityManager != null) { + try { + if (entityManager.getTransaction().isActive()) { + entityManager.getTransaction().rollback(); + } + } finally { + entityManager.close(); + entityManager = null; + } + } + + if (entityManagerFactory != null) { + if (entityManagerFactory.getCache() != null) { + entityManagerFactory.getCache().evictAll(); + } + entityManagerFactory.close(); + entityManagerFactory = null; + } + + // clean shutdown of derby + if (isDerby) { + try { + DriverManager.getConnection("jdbc:derby:;shutdown=true"); + } catch (SQLException e) { + if (!e.getMessage().equals("Derby system shutdown.")) { + throw new RuntimeException(e); + } + } + } + } +} diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/META-INF/persistence.xml b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/META-INF/persistence.xml new file mode 100644 index 0000000000..60ca31c002 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/META-INF/persistence.xml @@ -0,0 +1,297 @@ + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + + + + + + + + + + + + + org.eclipse.persistence.jpa.PersistenceProvider + false + + + + + + + + + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + + + + + + + + + + + + + + org.eclipse.persistence.jpa.PersistenceProvider + false + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + + + + + + + + + + + + + + org.eclipse.persistence.jpa.PersistenceProvider + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + + + + + + + + + + + + + + + org.eclipse.persistence.jpa.PersistenceProvider + false + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + + + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + + + + + + + + + + + + + + + org.eclipse.persistence.jpa.PersistenceProvider + false + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + + + + + + + + + + + + + + diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/derby.properties b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/derby.properties new file mode 100644 index 0000000000..12588cba01 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/derby.properties @@ -0,0 +1,11 @@ +## Derby +#hibernate.dialect=org.hibernate.dialect.DerbyDialect +hibernate.dialect=com.querydsl.jpa.support.QDerbyDialect +hibernate.connection.driver_class=org.apache.derby.jdbc.EmbeddedDriver +hibernate.connection.url=jdbc:derby:target/derbydb;create=true + +## Common properties +#hibernate.show_sql=true +hibernate.flushMode=FLUSH_AUTO +hibernate.hbm2ddl.auto=create-drop +#hibernate.use_sql_comments=true \ No newline at end of file diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/h2.properties b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/h2.properties new file mode 100644 index 0000000000..7fc01b0083 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/h2.properties @@ -0,0 +1,9 @@ +hibernate.dialect=com.querydsl.jpa.support.QH2Dialect +hibernate.connection.driver_class=org.h2.Driver +hibernate.connection.url=jdbc:h2:./target/h2-jpa1;MODE=legacy +hibernate.connection.username=sa +hibernate.connection.password= + +#hibernate.show_sql=true +hibernate.flushMode=FLUSH_AUTO +hibernate.hbm2ddl.auto=create-drop \ No newline at end of file diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/hsqldb.properties b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/hsqldb.properties new file mode 100644 index 0000000000..b2dc0c0fec --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/hsqldb.properties @@ -0,0 +1,13 @@ +## HSQL +#hibernate.dialect=org.hibernate.dialect.HSQLDialect +hibernate.dialect=com.querydsl.jpa.support.QHSQLDialect +hibernate.connection.url=jdbc:hsqldb:file:target/testdb;shutdown=true +hibernate.connection.driver_class=org.hsqldb.jdbcDriver +hibernate.connection.username=sa +hibernate.connection.password= + +## Common properties +#hibernate.show_sql=true +hibernate.flushMode=FLUSH_AUTO +hibernate.hbm2ddl.auto=create-drop +#hibernate.use_sql_comments=true \ No newline at end of file diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/mssql.properties b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/mssql.properties new file mode 100644 index 0000000000..b7b0002044 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/mssql.properties @@ -0,0 +1,12 @@ +## MSSQL +hibernate.dialect=com.querydsl.jpa.support.QSQLServer2008Dialect +hibernate.connection.driver_class=com.microsoft.sqlserver.jdbc.SQLServerDriver +hibernate.connection.url=jdbc:sqlserver://localhost:1433;databaseName=tempdb;sendTimeAsDatetime=false;trustServerCertificate=true +hibernate.connection.username=sa +hibernate.connection.password=Password1! + +## Common properties +#hibernate.show_sql=true +hibernate.flushMode=FLUSH_AUTO +hibernate.hbm2ddl.auto=update +#hibernate.use_sql_comments=true \ No newline at end of file diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/mysql.properties b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/mysql.properties new file mode 100644 index 0000000000..619988c92f --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/mysql.properties @@ -0,0 +1,12 @@ +## MySQL +hibernate.dialect=com.querydsl.jpa.support.QMySQL5InnoDBDialect +hibernate.connection.driver_class=com.mysql.jdbc.Driver +hibernate.connection.url=jdbc:mysql://localhost:3306/querydsl +hibernate.connection.username=querydsl +hibernate.connection.password=querydsl + +## Common properties +#hibernate.show_sql=true +hibernate.flushMode=FLUSH_AUTO +hibernate.hbm2ddl.auto=update +#hibernate.use_sql_comments=true diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/oracle.properties b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/oracle.properties new file mode 100644 index 0000000000..f577ff1f06 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/oracle.properties @@ -0,0 +1,13 @@ +## MySQL +#hibernate.dialect=org.hibernate.dialect.Oracle10gDialect +hibernate.dialect=com.querydsl.jpa.support.QOracleDialect +hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver +hibernate.connection.url=jdbc:oracle:thin:@localhost:1521:xe +hibernate.connection.username=querydsl +hibernate.connection.password=querydsl + +## Common properties +#hibernate.show_sql=true +hibernate.flushMode=FLUSH_AUTO +hibernate.hbm2ddl.auto=update +#hibernate.use_sql_comments=true diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/postgresql.properties b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/postgresql.properties new file mode 100644 index 0000000000..2f782835c7 --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/com/querydsl/jpa/testutil/postgresql.properties @@ -0,0 +1,12 @@ +## MySQL +hibernate.dialect=com.querydsl.jpa.support.QPostgreSQL9Dialect +hibernate.connection.driver_class=org.postgresql.Driver +hibernate.connection.url=jdbc:postgresql://localhost:5432/querydsl +hibernate.connection.username=querydsl +hibernate.connection.password=querydsl + +## Common properties +#hibernate.show_sql=true +hibernate.flushMode=FLUSH_AUTO +hibernate.hbm2ddl.auto=update +#hibernate.use_sql_comments=true diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/contact.hbm.xml b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/contact.hbm.xml new file mode 100644 index 0000000000..72265d314c --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/contact.hbm.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/contact2.hbm.xml b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/contact2.hbm.xml new file mode 100644 index 0000000000..49c99a45fe --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/contact2.hbm.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/hibernate.cfg.xml b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/hibernate.cfg.xml new file mode 100644 index 0000000000..77f0d8b63b --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/hibernate.cfg.xml @@ -0,0 +1,12 @@ + + + + + + com.querydsl.jpa.support.ExtendedDerbyDialect + org.apache.derby.jdbc.EmbeddedDriver + jdbc:derby:target/derbydb;create=true + + diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/log4j.properties b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/log4j.properties new file mode 100644 index 0000000000..0ada73a50c --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/log4j.properties @@ -0,0 +1,19 @@ +### direct log messages to stdout ### +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +#log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%5p [%d{yyyy-MM-dd HH:mm:ss}] (%F:%L) - %m %X%n + +### set log levels - for more verbose logging change 'info' to 'debug' ### + +log4j.rootLogger=debug, stdout + +log4j.appender.querydsl=org.apache.log4j.ConsoleAppender +log4j.appender.querydsl.layout=org.apache.log4j.PatternLayout +log4j.appender.querydsl.layout.ConversionPattern=Querydsl : %C#%M - %m%n + +#log4j.logger.com.querydsl.jpa.hibernate=DEBUG, querydsl +#log4j.logger.com.querydsl.jpa.impl=DEBUG, querydsl + +log4j.logger.org.hibernate=debug +log4j.logger.org.hibernate.tool.hbm2ddl=debug \ No newline at end of file diff --git a/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/store.hbm.xml b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/store.hbm.xml new file mode 100644 index 0000000000..da0b6e537a --- /dev/null +++ b/querydsl-libraries/querydsl-hibernate-reactive/src/notest/resources/store.hbm.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/JPQLSerializerTest.java b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/JPQLSerializerTest.java index 4a769c1a3e..bf9a715463 100644 --- a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/JPQLSerializerTest.java +++ b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/JPQLSerializerTest.java @@ -250,10 +250,11 @@ public void nullsFirst() { md.addOrderBy(cat.name.asc().nullsFirst()); serializer.serialize(md, false, null); assertThat(serializer.toString()) - .isEqualTo(""" - select cat - from Cat cat - order by cat.name asc nulls first"""); + .isEqualTo( + """ + select cat + from Cat cat + order by cat.name asc nulls first"""); } @Test @@ -265,10 +266,11 @@ public void nullsLast() { md.addOrderBy(cat.name.asc().nullsLast()); serializer.serialize(md, false, null); assertThat(serializer.toString()) - .isEqualTo(""" - select cat - from Cat cat - order by cat.name asc nulls last"""); + .isEqualTo( + """ + select cat + from Cat cat + order by cat.name asc nulls last"""); } @SuppressWarnings("unchecked") diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/ProjectableR2DBCQuery.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/ProjectableR2DBCQuery.java index ae92ba5622..bb76d22daf 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/ProjectableR2DBCQuery.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/ProjectableR2DBCQuery.java @@ -18,9 +18,9 @@ import com.querydsl.core.Query; import com.querydsl.core.QueryFlag; import com.querydsl.core.QueryFlag.Position; -import com.querydsl.core.ReactiveFetchableQuery; +import com.querydsl.core.dml.reactive.ReactiveFetchableQuery; +import com.querydsl.core.dml.reactive.ReactiveFetchableSubQueryBase; import com.querydsl.core.support.QueryMixin; -import com.querydsl.core.support.ReactiveFetchableSubQueryBase; import com.querydsl.core.types.EntityPath; import com.querydsl.core.types.Expression; import com.querydsl.core.types.ExpressionUtils; diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/Union.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/Union.java index 9d2513e69e..d7294d9e80 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/Union.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/Union.java @@ -13,7 +13,7 @@ */ package com.querydsl.r2dbc; -import com.querydsl.core.ReactiveFetchable; +import com.querydsl.core.dml.reactive.ReactiveFetchable; import com.querydsl.core.types.Expression; import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.Path; diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCClause.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCClause.java index 0a6158708d..5a70556029 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCClause.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCClause.java @@ -14,7 +14,7 @@ package com.querydsl.r2dbc.dml; import com.querydsl.core.QueryMetadata; -import com.querydsl.core.dml.ReactiveDMLClause; +import com.querydsl.core.dml.reactive.ReactiveDMLClause; import com.querydsl.core.types.ParamExpression; import com.querydsl.core.types.ParamNotSetException; import com.querydsl.core.types.Path; diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java index 5ffe87e7a9..161134611b 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java @@ -18,7 +18,7 @@ import com.querydsl.core.QueryFlag; import com.querydsl.core.QueryFlag.Position; import com.querydsl.core.QueryModifiers; -import com.querydsl.core.dml.ReactiveDeleteClause; +import com.querydsl.core.dml.reactive.ReactiveDeleteClause; import com.querydsl.core.types.Expression; import com.querydsl.core.types.Predicate; import com.querydsl.core.types.ValidatingVisitor; diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCInsertClause.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCInsertClause.java index 658a91712d..da0a9ce357 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCInsertClause.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCInsertClause.java @@ -18,7 +18,7 @@ import com.querydsl.core.QueryFlag; import com.querydsl.core.QueryFlag.Position; import com.querydsl.core.QueryMetadata; -import com.querydsl.core.dml.ReactiveInsertClause; +import com.querydsl.core.dml.reactive.ReactiveInsertClause; import com.querydsl.core.types.ConstantImpl; import com.querydsl.core.types.Expression; import com.querydsl.core.types.ParamExpression; diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCUpdateClause.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCUpdateClause.java index 32961ba6fb..95c6127827 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCUpdateClause.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCUpdateClause.java @@ -19,7 +19,7 @@ import com.querydsl.core.QueryFlag.Position; import com.querydsl.core.QueryMetadata; import com.querydsl.core.QueryModifiers; -import com.querydsl.core.dml.ReactiveUpdateClause; +import com.querydsl.core.dml.reactive.ReactiveUpdateClause; import com.querydsl.core.types.ConstantImpl; import com.querydsl.core.types.Expression; import com.querydsl.core.types.Path; diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveAbstractGroupByTransformer.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveAbstractGroupByTransformer.java index e0ce83c3dd..6c387f72c1 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveAbstractGroupByTransformer.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveAbstractGroupByTransformer.java @@ -13,8 +13,8 @@ */ package com.querydsl.r2dbc.group; -import com.querydsl.core.ReactiveResultTransformer; import com.querydsl.core.Tuple; +import com.querydsl.core.dml.reactive.ReactiveResultTransformer; import com.querydsl.core.group.GMap; import com.querydsl.core.group.GOne; import com.querydsl.core.group.GroupExpression; diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupByBuilder.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupByBuilder.java index 5c5e60eae3..11f04124ad 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupByBuilder.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupByBuilder.java @@ -13,7 +13,7 @@ */ package com.querydsl.r2dbc.group; -import com.querydsl.core.ReactiveResultTransformer; +import com.querydsl.core.dml.reactive.ReactiveResultTransformer; import com.querydsl.core.group.Group; import com.querydsl.core.group.GroupExpression; import com.querydsl.core.types.Expression; diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupByList.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupByList.java index 463b86fac4..1120d61fed 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupByList.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupByList.java @@ -13,8 +13,8 @@ */ package com.querydsl.r2dbc.group; -import com.querydsl.core.ReactiveFetchableQuery; import com.querydsl.core.Tuple; +import com.querydsl.core.dml.reactive.ReactiveFetchableQuery; import com.querydsl.core.group.Group; import com.querydsl.core.group.GroupExpression; import com.querydsl.core.group.GroupImpl; diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupByMap.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupByMap.java index bb096c446f..ec9e571ce6 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupByMap.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupByMap.java @@ -13,8 +13,8 @@ */ package com.querydsl.r2dbc.group; -import com.querydsl.core.ReactiveFetchableQuery; import com.querydsl.core.Tuple; +import com.querydsl.core.dml.reactive.ReactiveFetchableQuery; import com.querydsl.core.group.Group; import com.querydsl.core.group.GroupExpression; import com.querydsl.core.group.GroupImpl; diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/AbstractBaseTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/AbstractBaseTest.java index 43c31b564f..527d387146 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/AbstractBaseTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/AbstractBaseTest.java @@ -18,7 +18,7 @@ import com.querydsl.core.DefaultQueryMetadata; import com.querydsl.core.QueryMetadata; import com.querydsl.core.Target; -import com.querydsl.core.dml.ReactiveDMLClause; +import com.querydsl.core.dml.reactive.ReactiveDMLClause; import com.querydsl.r2dbc.dml.R2DBCDeleteClause; import com.querydsl.r2dbc.dml.R2DBCInsertClause; import com.querydsl.r2dbc.dml.R2DBCUpdateClause; diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/AbstractSQLTemplatesTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/AbstractSQLTemplatesTest.java index 3eda879fba..61edddfd56 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/AbstractSQLTemplatesTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/AbstractSQLTemplatesTest.java @@ -83,12 +83,13 @@ public void union() { """); } else { assertThat(union.toString()) - .isEqualTo(""" - select 1 as col1) - union - select 2 - union - select 3"""); + .isEqualTo( + """ + select 1 as col1) + union + select 2 + union + select 3"""); } } else { var dummyTable = templates.getDummyTable(); diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/JoinFlagsTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/JoinFlagsTest.java index 4a63fef388..1f8a3204ee 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/JoinFlagsTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/JoinFlagsTest.java @@ -50,10 +50,11 @@ public void joinFlags_beforeCondition() { query.addJoinFlag(" a ", JoinFlag.Position.BEFORE_CONDITION); assertThat(query.toString()) - .isEqualTo(""" - from SURVEY s - inner join SURVEY s2 a\s - on s.ID = s2.ID"""); + .isEqualTo( + """ + from SURVEY s + inner join SURVEY s2 a\s + on s.ID = s2.ID"""); } @SuppressWarnings("unchecked") @@ -63,10 +64,11 @@ public void joinFlags_beforeTarget() { query.addJoinFlag(" b ", JoinFlag.Position.BEFORE_TARGET); assertThat(query.toString()) - .isEqualTo(""" - from SURVEY s - inner join b SURVEY s3 - on s.ID = s3.ID"""); + .isEqualTo( + """ + from SURVEY s + inner join b SURVEY s3 + on s.ID = s3.ID"""); } @SuppressWarnings("unchecked") @@ -76,10 +78,11 @@ public void joinFlags_end() { query.addJoinFlag(" c ", JoinFlag.Position.END); assertThat(query.toString()) - .isEqualTo(""" - from SURVEY s - inner join SURVEY s4 - on s.ID = s4.ID c"""); + .isEqualTo( + """ + from SURVEY s + inner join SURVEY s4 + on s.ID = s4.ID c"""); } @SuppressWarnings("unchecked") @@ -98,9 +101,10 @@ public void joinFlags_start() { query.addJoinFlag(" e ", JoinFlag.Position.START); assertThat(query.toString()) - .isEqualTo(""" - from SURVEY s e\s - inner join SURVEY s6 - on s.ID = s6.ID"""); + .isEqualTo( + """ + from SURVEY s e\s + inner join SURVEY s6 + on s.ID = s6.ID"""); } } diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/PostgreSQLTemplatesTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/PostgreSQLTemplatesTest.java index 057e1cca43..cd46b0f516 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/PostgreSQLTemplatesTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/PostgreSQLTemplatesTest.java @@ -48,12 +48,13 @@ public void union() { R2DBCExpressions.select(two), R2DBCExpressions.select(three)); assertThat(union.toString()) - .isEqualTo(""" - (select 1 as col1) - union - (select 2) - union - (select 3)"""); + .isEqualTo( + """ + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2005TemplatesTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2005TemplatesTest.java index 3cf5bc6a6a..b75392de34 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2005TemplatesTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2005TemplatesTest.java @@ -52,12 +52,13 @@ public void union() { R2DBCExpressions.select(two), R2DBCExpressions.select(three)); assertThat(union.toString()) - .isEqualTo(""" - (select 1 as col1) - union - (select 2) - union - (select 3)"""); + .isEqualTo( + """ + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2012TemplatesTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2012TemplatesTest.java index ba7e5c41e9..71ca959782 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2012TemplatesTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2012TemplatesTest.java @@ -53,12 +53,13 @@ public void union() { R2DBCExpressions.select(two), R2DBCExpressions.select(three)); assertThat(union.toString()) - .isEqualTo(""" - (select 1 as col1) - union - (select 2) - union - (select 3)"""); + .isEqualTo( + """ + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServerTemplatesTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServerTemplatesTest.java index 9a672732bd..f64b9e6aea 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServerTemplatesTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServerTemplatesTest.java @@ -51,12 +51,13 @@ public void union() { R2DBCExpressions.select(two), R2DBCExpressions.select(three)); assertThat(union.toString()) - .isEqualTo(""" - (select 1 as col1) - union - (select 2) - union - (select 3)"""); + .isEqualTo( + """ + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SelectBase.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SelectBase.java index 3bd38cd34c..01ac37f115 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SelectBase.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SelectBase.java @@ -41,10 +41,10 @@ import com.querydsl.core.Pair; import com.querydsl.core.QueryException; import com.querydsl.core.QuerydslModule; -import com.querydsl.core.ReactiveFetchable; import com.querydsl.core.ReactiveQueryExecution; import com.querydsl.core.Target; import com.querydsl.core.Tuple; +import com.querydsl.core.dml.reactive.ReactiveFetchable; import com.querydsl.core.testutil.ExcludeIn; import com.querydsl.core.testutil.IncludeIn; import com.querydsl.core.testutil.Serialization; diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/UnionSubQueryTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/UnionSubQueryTest.java index ef9d90a86c..fb4b22604e 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/UnionSubQueryTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/UnionSubQueryTest.java @@ -47,10 +47,11 @@ public void in_union() { serializer.handle(expr); assertThat(serializer.toString()) - .isEqualTo(""" - intPath in ((select 1 from dual) - union - (select 2 from dual))"""); + .isEqualTo( + """ + intPath in ((select 1 from dual) + union + (select 2 from dual))"""); } @SuppressWarnings("unchecked") diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/AbstractSQLTemplatesTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/AbstractSQLTemplatesTest.java index 8b93fc18b1..52fc9a27b4 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/AbstractSQLTemplatesTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/AbstractSQLTemplatesTest.java @@ -80,12 +80,13 @@ public void union() { """); } else { assertThat(union.toString()) - .isEqualTo(""" - select 1 as col1) - union - select 2 - union - select 3"""); + .isEqualTo( + """ + select 1 as col1) + union + select 2 + union + select 3"""); } } else { var dummyTable = templates.getDummyTable(); diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/JoinFlagsTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/JoinFlagsTest.java index 23e0d2c332..d66f3afb44 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/JoinFlagsTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/JoinFlagsTest.java @@ -50,10 +50,11 @@ public void joinFlags_beforeCondition() { query.addJoinFlag(" a ", JoinFlag.Position.BEFORE_CONDITION); assertThat(query.toString()) - .isEqualTo(""" - from SURVEY s - inner join SURVEY s2 a\s - on s.ID = s2.ID"""); + .isEqualTo( + """ + from SURVEY s + inner join SURVEY s2 a\s + on s.ID = s2.ID"""); } @SuppressWarnings("unchecked") @@ -63,10 +64,11 @@ public void joinFlags_beforeTarget() { query.addJoinFlag(" b ", JoinFlag.Position.BEFORE_TARGET); assertThat(query.toString()) - .isEqualTo(""" - from SURVEY s - inner join b SURVEY s3 - on s.ID = s3.ID"""); + .isEqualTo( + """ + from SURVEY s + inner join b SURVEY s3 + on s.ID = s3.ID"""); } @SuppressWarnings("unchecked") @@ -76,10 +78,11 @@ public void joinFlags_end() { query.addJoinFlag(" c ", JoinFlag.Position.END); assertThat(query.toString()) - .isEqualTo(""" - from SURVEY s - inner join SURVEY s4 - on s.ID = s4.ID c"""); + .isEqualTo( + """ + from SURVEY s + inner join SURVEY s4 + on s.ID = s4.ID c"""); } @SuppressWarnings("unchecked") @@ -98,9 +101,10 @@ public void joinFlags_start() { query.addJoinFlag(" e ", JoinFlag.Position.START); assertThat(query.toString()) - .isEqualTo(""" - from SURVEY s e\s - inner join SURVEY s6 - on s.ID = s6.ID"""); + .isEqualTo( + """ + from SURVEY s e\s + inner join SURVEY s6 + on s.ID = s6.ID"""); } } diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/PostgreSQLTemplatesTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/PostgreSQLTemplatesTest.java index 53ff4038e8..c95a33c70f 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/PostgreSQLTemplatesTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/PostgreSQLTemplatesTest.java @@ -45,12 +45,13 @@ public void union() { Path col1 = Expressions.path(Integer.class, "col1"); Union union = query.union(select(one.as(col1)), select(two), select(three)); assertThat(union.toString()) - .isEqualTo(""" - (select 1 as col1) - union - (select 2) - union - (select 3)"""); + .isEqualTo( + """ + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2005TemplatesTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2005TemplatesTest.java index 6b7b5c6244..c2998c0493 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2005TemplatesTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2005TemplatesTest.java @@ -48,12 +48,13 @@ public void union() { Path col1 = Expressions.path(Integer.class, "col1"); Union union = query.union(select(one.as(col1)), select(two), select(three)); assertThat(union.toString()) - .isEqualTo(""" - (select 1 as col1) - union - (select 2) - union - (select 3)"""); + .isEqualTo( + """ + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2012TemplatesTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2012TemplatesTest.java index 2b88ac50dd..144ac8922f 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2012TemplatesTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2012TemplatesTest.java @@ -49,12 +49,13 @@ public void union() { Path col1 = Expressions.path(Integer.class, "col1"); Union union = query.union(select(one.as(col1)), select(two), select(three)); assertThat(union.toString()) - .isEqualTo(""" - (select 1 as col1) - union - (select 2) - union - (select 3)"""); + .isEqualTo( + """ + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServerTemplatesTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServerTemplatesTest.java index d0a3be9d6d..2902aa11dc 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServerTemplatesTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServerTemplatesTest.java @@ -47,12 +47,13 @@ public void union() { Path col1 = Expressions.path(Integer.class, "col1"); Union union = query.union(select(one.as(col1)), select(two), select(three)); assertThat(union.toString()) - .isEqualTo(""" - (select 1 as col1) - union - (select 2) - union - (select 3)"""); + .isEqualTo( + """ + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLiteTemplatesTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLiteTemplatesTest.java index 9baa1a0059..9e31ef5ed7 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLiteTemplatesTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLiteTemplatesTest.java @@ -38,12 +38,13 @@ public void union() { Union union = query.union(select(one.as(col1)), select(two), select(three)); assertThat(union.toString()) - .isEqualTo(""" - select 1 as col1 - union - select 2 - union - select 3"""); + .isEqualTo( + """ + select 1 as col1 + union + select 2 + union + select 3"""); } @Test diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/UnionSubQueryTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/UnionSubQueryTest.java index f4be522292..4fa2603b40 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/UnionSubQueryTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/UnionSubQueryTest.java @@ -48,10 +48,11 @@ public void in_union() { serializer.handle(expr); assertThat(serializer.toString()) - .isEqualTo(""" - intPath in ((select 1 from dual) - union - (select 2 from dual))"""); + .isEqualTo( + """ + intPath in ((select 1 from dual) + union + (select 2 from dual))"""); } @SuppressWarnings("unchecked") diff --git a/querydsl-tooling/querydsl-codegen/src/test/java/com/querydsl/codegen/ProjectionSerializerTest.java b/querydsl-tooling/querydsl-codegen/src/test/java/com/querydsl/codegen/ProjectionSerializerTest.java index 6261cd8681..63a7b29636 100644 --- a/querydsl-tooling/querydsl-codegen/src/test/java/com/querydsl/codegen/ProjectionSerializerTest.java +++ b/querydsl-tooling/querydsl-codegen/src/test/java/com/querydsl/codegen/ProjectionSerializerTest.java @@ -56,14 +56,14 @@ public void constructors() throws IOException { assertThat(writer.toString()) .contains( """ - public Path(Expression firstName, Expression lastName) { - super(com.querydsl.DomainClass.class, new Class[]{String.class, String.class}, firstName, lastName); - } + public Path(Expression firstName, Expression lastName) { + super(com.querydsl.DomainClass.class, new Class[]{String.class, String.class}, firstName, lastName); + } - public Path(Expression firstName, Expression lastName, Expression age) { - super(com.querydsl.DomainClass.class, new Class[]{String.class, String.class, int.class}, firstName, lastName, age); - } - """); + public Path(Expression firstName, Expression lastName, Expression age) { + super(com.querydsl.DomainClass.class, new Class[]{String.class, String.class, int.class}, firstName, lastName, age); + } +"""); } @Test