From cb9140ed4afa9ff3b565b6a7838a8a11114f9ad4 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Fri, 2 Mar 2018 03:00:11 +0100 Subject: [PATCH] [#209, #442] Allow to build with JDK 9. Add initial support for Hibernate 5.3 and DataNucleus 5.1. Adapt parameter handling in custom sql queries. Fix subview attribute flusher oversight. Documentation update --- .travis.yml | 200 +- README.md | 104 +- build.sh | 4 +- .../impl/AbstractCTECriteriaBuilder.java | 1 + .../impl/AbstractCommonQueryBuilder.java | 2 +- ...stractDeleteCollectionCriteriaBuilder.java | 2 + ...stractInsertCollectionCriteriaBuilder.java | 2 + .../AbstractModificationCriteriaBuilder.java | 3 +- ...stractUpdateCollectionCriteriaBuilder.java | 2 + .../BaseFinalSetOperationBuilderImpl.java | 1 + .../impl/BaseInsertCriteriaBuilderImpl.java | 1 + .../persistence/impl/ExtendedParameter.java | 29 + .../impl/PaginatedCriteriaBuilderImpl.java | 8 +- .../persistence/impl/ParameterManager.java | 15 +- .../impl/query/AbstractCustomQuery.java | 246 ++- .../impl/query/CTEQuerySpecification.java | 10 +- ...nDeleteModificationQuerySpecification.java | 5 +- ...nInsertModificationQuerySpecification.java | 5 +- ...nUpdateModificationQuerySpecification.java | 5 +- .../impl/query/CustomQuerySpecification.java | 17 +- .../query/CustomReturningSQLTypedQuery.java | 6 +- .../impl/query/CustomSQLQuery.java | 2 +- .../impl/query/CustomSQLTypedQuery.java | 4 +- .../impl/query/DefaultQuerySpecification.java | 6 + .../query/ModificationQuerySpecification.java | 20 +- .../impl/query/QuerySpecification.java | 4 + ...nDeleteModificationQuerySpecification.java | 5 +- ...nInsertModificationQuerySpecification.java | 5 +- ...nUpdateModificationQuerySpecification.java | 5 +- ...turningModificationQuerySpecification.java | 11 +- .../query/SetOperationQuerySpecification.java | 10 +- .../persistence/impl/util/SetView.java | 111 + core/testsuite/pom.xml | 569 ++++- dist/bom/pom.xml | 12 + dist/full/pom.xml | 8 + .../core/manual/en_US/02_getting_started.adoc | 137 +- .../manual/en_US/02_getting_started.adoc | 53 + .../manual/en_US/12_spring_data.adoc | 108 +- .../view/impl/proxy/ProxyFactory.java | 70 +- .../update/flush/SubviewAttributeFlusher.java | 8 +- entity-view/testsuite/pom.xml | 547 ++++- examples/showcase/runner/cdi/pom.xml | 95 + examples/showcase/runner/spring/pom.xml | 65 + examples/spring-data-rest/pom.xml | 24 +- integration/datanucleus-5.1/pom.xml | 164 ++ .../datanucleus/CTEAnnotationReader.java | 77 + .../DataNucleus51ExtendedQuerySupport.java | 121 ++ .../datanucleus/DataNucleus51JpaProvider.java | 410 ++++ .../AbstractJpqlFunctionSQLMethod.java | 94 + .../datanucleus/function/CustomSQLText.java | 51 + ...cleus51EntityManagerFactoryIntegrator.java | 333 +++ .../DataNucleusFunctionRenderContext.java | 66 + .../DataNucleusJpqlFunctionAdapter.java | 182 ++ .../JpqlFunctionInstanceSQLMethod.java | 40 + .../function/JpqlFunctionSQLMethod.java | 41 + .../QueryGeneratorInvocationHandler.java | 44 + .../src/main/resources/META-INF/MANIFEST.MF | 7 + .../src/main/resources/plugin.xml | 32 + integration/deltaspike-data/api/pom.xml | 12 + integration/deltaspike-data/impl/pom.xml | 12 + integration/deltaspike-data/testsuite/pom.xml | 1924 ++++++++++++++++- .../main/resources/META-INF/persistence.xml | 9 - .../AbstractEntityViewRepositoryTest.java | 28 +- .../producer/EntityManagerProducer.java | 14 +- integration/entity-view-cdi/pom.xml | 82 +- .../hibernate/Hibernate4Access.java | 7 + .../hibernate/Hibernate43Access.java | 7 + .../hibernate/Hibernate52Access.java | 7 + integration/hibernate-5.3/pom.xml | 105 + .../CustomBasicCollectionPersister.java | 54 + .../hibernate/CustomOneToManyPersister.java | 54 + .../CustomPersisterClassResolver.java | 37 + .../hibernate/Hibernate53Access.java | 228 ++ .../Hibernate53DelegatingDialect.java | 909 ++++++++ ...rnate53EntityManagerFactoryIntegrator.java | 102 + .../hibernate/Hibernate53Integrator.java | 80 + .../hibernate/Hibernate53LimitHandler.java | 81 + .../Hibernate53LimitHandlingDialect.java | 41 + .../Hibernate53MetadataContributor.java | 88 + .../Hibernate53ServiceContributor.java | 50 + ...nate53SessionFactoryInvocationHandler.java | 47 + .../Hibernate53SessionInvocationHandler.java | 47 + .../JdbcCoordinatorInvocationHandler.java | 64 + .../hibernate/NativeTableNameFormatter.java | 41 + .../PreparedStatementInvocationHandler.java | 74 + .../hibernate/StatementPreparerImpl.java | 200 ++ ...org.hibernate.boot.spi.MetadataContributor | 16 + .../hibernate/Hibernate5Access.java | 7 + .../hibernate/Hibernate60Access.java | 7 + .../hibernate/base/HibernateAccess.java | 3 + .../base/HibernateExtendedQuerySupport.java | 3 +- integration/pom.xml | 2 + integration/spring-data/1.x/pom.xml | 1271 ----------- integration/spring-data/2.x/pom.xml | 1271 ----------- integration/spring-data/base/pom.xml | 1269 ----------- integration/spring-data/rest/pom.xml | 1269 ----------- integration/spring-data/testsuite/pom.xml | 563 ++++- jpa-criteria/testsuite/pom.xml | 549 +++++ parent/pom.xml | 49 +- pom.xml | 10 +- testsuite-base/datanucleus/pom.xml | 4 - .../base/AbstractPersistenceTest.java | 23 +- travis/install_jdk_10.sh | 20 + website/pom.xml | 25 + website/src/main/jbake/content/downloads.adoc | 23 + 105 files changed, 9542 insertions(+), 5455 deletions(-) create mode 100644 core/impl/src/main/java/com/blazebit/persistence/impl/ExtendedParameter.java create mode 100644 core/impl/src/main/java/com/blazebit/persistence/impl/util/SetView.java create mode 100644 integration/datanucleus-5.1/pom.xml create mode 100644 integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/CTEAnnotationReader.java create mode 100644 integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/DataNucleus51ExtendedQuerySupport.java create mode 100644 integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/DataNucleus51JpaProvider.java create mode 100644 integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/AbstractJpqlFunctionSQLMethod.java create mode 100644 integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/CustomSQLText.java create mode 100644 integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/DataNucleus51EntityManagerFactoryIntegrator.java create mode 100644 integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/DataNucleusFunctionRenderContext.java create mode 100644 integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/DataNucleusJpqlFunctionAdapter.java create mode 100644 integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/JpqlFunctionInstanceSQLMethod.java create mode 100644 integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/JpqlFunctionSQLMethod.java create mode 100644 integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/QueryGeneratorInvocationHandler.java create mode 100644 integration/datanucleus-5.1/src/main/resources/META-INF/MANIFEST.MF create mode 100644 integration/datanucleus-5.1/src/main/resources/plugin.xml create mode 100644 integration/hibernate-5.3/pom.xml create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/CustomBasicCollectionPersister.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/CustomOneToManyPersister.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/CustomPersisterClassResolver.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53Access.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53DelegatingDialect.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53EntityManagerFactoryIntegrator.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53Integrator.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53LimitHandler.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53LimitHandlingDialect.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53MetadataContributor.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53ServiceContributor.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53SessionFactoryInvocationHandler.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53SessionInvocationHandler.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/JdbcCoordinatorInvocationHandler.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/NativeTableNameFormatter.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/PreparedStatementInvocationHandler.java create mode 100644 integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/StatementPreparerImpl.java create mode 100644 integration/hibernate-5.3/src/main/resources/META-INF/services/org.hibernate.boot.spi.MetadataContributor create mode 100644 travis/install_jdk_10.sh diff --git a/.travis.yml b/.travis.yml index 4292bc6ee9..e0a1882279 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ cache: - '$HOME/.m2/repository' before_install: - sh -c "if [ '$RDBMS' = 'firebird' ]; then sh travis/before_install_firebird.sh; fi" + - sh -c "if [ '$JDK' = '10' ]; then unset _JAVA_OPTIONS && . ./travis/install_jdk_10.sh; fi" install: - sh -c "if [ '$LATEST_MAVEN' = 'true' ]; then sh travis/install_latest_maven.sh; fi" before_script: @@ -56,7 +57,7 @@ matrix: sudo: true services: - docker - - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 SPRING_DATA=spring-data-2.0.x + - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 SPRING_DATA=spring-data-2.0.x DELTASPIKE=deltaspike-1.8 jdk: oraclejdk8 # - env: JPAPROVIDER=hibernate-5.2 RDBMS=sqlite # jdk: oraclejdk8 @@ -102,7 +103,7 @@ matrix: # eclipselink ################################################ - env: JPAPROVIDER=eclipselink RDBMS=h2 - jdk: openjdk7 + jdk: oraclejdk8 # - env: JPAPROVIDER=eclipselink RDBMS=mysql # dist: trusty # sudo: required @@ -157,6 +158,74 @@ matrix: # - env: JPAPROVIDER=openjpa RDBMS=firebird # sudo: true +################################################ +# hibernate-5.3 +################################################ +# - env: JPAPROVIDER=hibernate-5.3 RDBMS=h2 +# jdk: oraclejdk8 +# - env: JPAPROVIDER=hibernate-5.3 RDBMS=mysql +# jdk: oraclejdk8 +# dist: trusty +# sudo: required +# - env: JPAPROVIDER=hibernate-5.3 RDBMS=postgresql +# jdk: oraclejdk8 +# addons: +# postgresql: "9.3" +# - env: JPAPROVIDER=hibernate-5.3 RDBMS=mssql +# jdk: oraclejdk8 +# sudo: true +# services: +# - docker +# - env: JPAPROVIDER=hibernate-5.3 RDBMS=db2 +# jdk: oraclejdk8 +# sudo: true +# services: +# - docker +# - env: JPAPROVIDER=hibernate-5.3 RDBMS=oracle +# jdk: oraclejdk8 +# sudo: true +# services: +# - docker +# - env: JPAPROVIDER=hibernate-5.3 RDBMS=sqlite +# jdk: oraclejdk8 +# - env: JPAPROVIDER=hibernate-5.3 RDBMS=firebird +# jdk: oraclejdk8 +# sudo: true + +################################################ +# datanucleus-5.1 +################################################ +# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=h2 +# jdk: oraclejdk8 +# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=mysql +# jdk: oraclejdk8 +# dist: trusty +# sudo: required +# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=postgresql +# jdk: oraclejdk8 +# addons: +# postgresql: "9.3" +# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=mssql +# jdk: oraclejdk8 +# sudo: true +# services: +# - docker +# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=db2 +# jdk: oraclejdk8 +# sudo: true +# services: +# - docker +# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=oracle +# jdk: oraclejdk8 +# sudo: true +# services: +# - docker +# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=sqlite +# jdk: oraclejdk8 +# - env: JPAPROVIDER=datanucleus-5.1 RDBMS=firebird +# jdk: oraclejdk8 +# sudo: true + ################################################ # hibernate-5.1 ################################################ @@ -229,13 +298,13 @@ matrix: # hibernate-4.3 ################################################ - env: JPAPROVIDER=hibernate-4.3 RDBMS=h2 - jdk: openjdk7 + jdk: oraclejdk8 - env: JPAPROVIDER=hibernate-4.3 RDBMS=mysql - jdk: openjdk7 + jdk: oraclejdk8 dist: trusty sudo: required - env: JPAPROVIDER=hibernate-4.3 RDBMS=postgresql - jdk: openjdk7 + jdk: oraclejdk8 addons: postgresql: "9.3" - env: JPAPROVIDER=hibernate-4.3 RDBMS=mssql @@ -244,7 +313,7 @@ matrix: services: - docker - env: JPAPROVIDER=hibernate-4.3 RDBMS=db2 - jdk: openjdk7 + jdk: oraclejdk8 sudo: true services: - docker @@ -262,13 +331,13 @@ matrix: # hibernate-4.2 ################################################ - env: JPAPROVIDER=hibernate RDBMS=h2 - jdk: openjdk7 + jdk: oraclejdk8 - env: JPAPROVIDER=hibernate RDBMS=mysql - jdk: openjdk7 + jdk: oraclejdk8 dist: trusty sudo: required - env: JPAPROVIDER=hibernate RDBMS=postgresql - jdk: openjdk7 + jdk: oraclejdk8 addons: postgresql: "9.3" - env: JPAPROVIDER=hibernate RDBMS=mssql @@ -277,7 +346,7 @@ matrix: services: - docker - env: JPAPROVIDER=hibernate RDBMS=db2 - jdk: openjdk7 + jdk: oraclejdk8 sudo: true services: - docker @@ -334,15 +403,124 @@ matrix: ################################################ # JDK 9 ################################################ -# JDK 9 - Not going to work until javassist is fixed + - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=10 LATEST_MAVEN=true - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=9 LATEST_MAVEN=true addons: apt: packages: - oracle-java9-installer jdk: oraclejdk9 + - env: JPAPROVIDER=datanucleus-5 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=eclipselink RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=hibernate-5.3 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=datanucleus-5.1 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=hibernate-5.1 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=hibernate-5.0 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=hibernate-4.3 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=hibernate-4.2 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=datanucleus-4 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 allow_failures: + - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=10 LATEST_MAVEN=true - env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=datanucleus-5 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=eclipselink RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=hibernate-5.3 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=datanucleus-5.1 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=hibernate-5.1 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=hibernate-5.0 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=hibernate-4.3 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=hibernate-4.2 RDBMS=h2 JDK=9 LATEST_MAVEN=true + addons: + apt: + packages: + - oracle-java9-installer + jdk: oraclejdk9 + - env: JPAPROVIDER=datanucleus-4 RDBMS=h2 JDK=9 LATEST_MAVEN=true addons: apt: packages: diff --git a/README.md b/README.md index e2d0fa6a02..ab950d83bd 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,78 @@ Java EE archetype: mvn archetype:generate "-DarchetypeGroupId=com.blazebit" "-DarchetypeArtifactId=blaze-persistence-archetype-java-ee-sample" "-DarchetypeVersion=1.2.0-Alpha4" ``` +## Supported Java runtimes + +All projects are built for Java 7 except for the ones where dependencies already use Java 8 like e.g. Hibernate 5.2, Spring Data 2.0 etc. +So you are going to need a JDK 8 for building the project. + +We also support building the project with JDK 9 and try to keep up with newer versions. +If you want to run your application on a Java 9 JVM you need to handle the fact that JDK 9+ doesn't export the JAXB and JTA APIs anymore. +In fact, JDK 11 will even remove the modules so the command line flags to add modules to the classpath won't work. + +Since libraries like Hibernate and others require these APIs you need to make them available. The easiest way to get these APIs back on the classpath is to package them along with your application. +This will also work when running on Java 8. We suggest you add the following dependencies. + +```xml + + javax.xml.bind + jaxb-api + 2.2.11 + + + com.sun.xml.bind + jaxb-core + 2.2.11 + + + com.sun.xml.bind + jaxb-impl + 2.2.11 + + + javax.transaction + javax.transaction-api + 1.2 + + provided + + + javax.activation + activation + 1.1.1 + + provided + + + javax.annotation + javax.annotation-api + 1.3.2 + + provided + +``` + +The `javax.transaction` and `javax.activation` dependencies are especially relevant for the JPA metamodel generation. + +## Supported environments/libraries + +The bare minimum is JPA 2.0. If you want to use the JPA Criteria API module, you will also have to add the JPA 2 compatibility module. +Generally, we support the usage in Java EE 6+ or Spring 4+ applications. + +See the following table for an overview of supported versions. + +Module | Minimum version | Supported versions +---------------------------------------------------------------------------------------- +Hibernate integration | Hibernate 4.2 | 4.2, 4.3, 5.0, 5.1, 5.2, 5.3 (not all features are available in older versions) +EclipseLink integration | EclipseLink 2.6 | 2.6 (Probably 2.4 and 2.5 work as well, but only tested against 2.6) +DataNucleus integration | DataNucleus 4.1 | 4.1, 5.0 +OpenJPA integration | N/A | (Currently not usable. OpenJPA doesn't seem to be actively developed anymore and no users asked for support yet) +Entity View CDI integration | CDI 1.0 | 1.0, 1.1, 1.2 +Entity View Spring integration | Spring 4.3 | 4.3, 5.0 +DeltaSpike Data integration | DeltaSpike 1.7 | 1.7, 1.8 +Spring Data integration | Spring Data 1.11 | 1.11, 2.0 +Spring Data Rest integration | Spring Data 1.11, Spring MVC 4.3 | Spring Data 1.11 + Spring MVC 4.3, Spring Data 2.0 + Spring MVC 5.0 + ## Manual setup For compiling you will only need API artifacts and for the runtime you need impl and integration artifacts. @@ -218,6 +290,17 @@ Blaze-Persistence DeltaSpike Data integration Blaze-Persistence JPA provider integration module dependencies +Hibernate 5.3 + +```xml + + com.blazebit + blaze-persistence-integration-hibernate-5.3 + ${blaze-persistence.version} + runtime + +``` + Hibernate 5.2 ```xml @@ -262,7 +345,18 @@ Hibernate 4.2 ``` -Datanucleus +Datanucleus 5.1 + +```xml + + com.blazebit + blaze-persistence-integration-datanucleus-5.1 + ${blaze-persistence.version} + runtime + +``` + +Datanucleus 4 and 5 ```xml @@ -482,15 +576,17 @@ Click on *Check project* and checkstyle will run once for the whole project, the ## Testing a JPA provider and DBMS combination By default, a Maven build `mvn clean install` will test against H2 and Hibernate 5.2 but you can activate different profiles to test other combinations. -To test a specific combination, you need to activate at least 3 profiles +To test a specific combination, you need to activate at least 4 profiles * One of the JPA provider profiles +** `hibernate-5.3` ** `hibernate-5.2` ** `hibernate-5.1` ** `hibernate-5.0` ** `hibernate-4.3` ** `hibernate` ** `eclipselink` +** `datanucleus-5.1` ** `datanucleus-5` ** `datanucleus-4` ** `openjpa` @@ -506,6 +602,9 @@ To test a specific combination, you need to activate at least 3 profiles * A Spring data profile ** `spring-data-2.0.x` ** `spring-data-1.11.x` +* A Deltaspike profile +** `deltaspike-1.7` +** `deltaspike-1.8` The default DBMS connection infos are defined via Maven properties, so you can override them in a build by passing the properties as system properties. @@ -534,6 +633,7 @@ After that, the entities in the project *core/testsuite* have to be enhanced. Th * DataNucleus 4: `mvn -P "datanucleus-4" -pl core/testsuite datanucleus:enhance` * DataNucleus 5: `mvn -P "datanucleus-5" -pl core/testsuite datanucleus:enhance` +* DataNucleus 5.1: `mvn -P "datanucleus-5.1" -pl core/testsuite datanucleus:enhance` After doing that, you should be able to execute any test in IntelliJ. diff --git a/build.sh b/build.sh index 232130ee94..3af0053113 100755 --- a/build.sh +++ b/build.sh @@ -24,7 +24,7 @@ if [ "$TRAVIS_REPO_SLUG" == "Blazebit/blaze-persistence" ] && [ "$TRAVIS_BRANCH" == "master" ] && [ "$JPAPROVIDER" == "hibernate-5.2" ] && [ "$RDBMS" == "h2" ]; then - exec ${MVN_BIN} -P ${JPAPROVIDER},${RDBMS},${SPRING_DATA:-spring-data-1.11.x} install + exec ${MVN_BIN} -P ${JPAPROVIDER},${RDBMS},${SPRING_DATA:-spring-data-1.11.x},${DELTASPIKE:-deltaspike-1.7} install else if [ "$TRAVIS_REPO_SLUG" == "Blazebit/blaze-persistence" ] && [ "$TRAVIS_BRANCH" == "master" ] && @@ -38,5 +38,5 @@ else : # do nothing right now fi - eval exec ${MVN_BIN} -P ${JPAPROVIDER},${RDBMS},${SPRING_DATA:-spring-data-1.11.x} install --projects "core/testsuite,entity-view/testsuite,jpa-criteria/testsuite" -am $PROPERTIES + eval exec ${MVN_BIN} -P ${JPAPROVIDER},${RDBMS},${DELTASPIKE:-deltaspike-1.7} install --projects "core/testsuite,entity-view/testsuite,jpa-criteria/testsuite" -am $PROPERTIES fi diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractCTECriteriaBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractCTECriteriaBuilder.java index b230776856..0c020b3455 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractCTECriteriaBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractCTECriteriaBuilder.java @@ -116,6 +116,7 @@ protected Query getQuery() { QuerySpecification querySpecification = new CTEQuerySpecification( this, query, + parameterManager.getParameters(), parameterListNames, limit, offset, diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractCommonQueryBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractCommonQueryBuilder.java index 03a3942dd8..b28c4531c5 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractCommonQueryBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractCommonQueryBuilder.java @@ -1551,7 +1551,7 @@ protected TypedQuery getTypedQuery() { boolean shouldRenderCteNodes = renderCteNodes(false); List ctes = shouldRenderCteNodes ? getCteNodes(baseQuery, false) : Collections.EMPTY_LIST; QuerySpecification querySpecification = new CustomQuerySpecification( - this, baseQuery, parameterListNames, limit, offset, keyRestrictedLeftJoinAliases, entityFunctionNodes, mainQuery.cteManager.isRecursive(), ctes, shouldRenderCteNodes + this, baseQuery, parameterManager.getParameters(), parameterListNames, limit, offset, keyRestrictedLeftJoinAliases, entityFunctionNodes, mainQuery.cteManager.isRecursive(), ctes, shouldRenderCteNodes ); TypedQuery query = new CustomSQLTypedQuery( diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractDeleteCollectionCriteriaBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractDeleteCollectionCriteriaBuilder.java index 3aa109910b..56f2caecad 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractDeleteCollectionCriteriaBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractDeleteCollectionCriteriaBuilder.java @@ -150,6 +150,7 @@ private QuerySpecification getQuerySpecification(Query baseQuery, Query exam this, baseQuery, exampleQuery, + parameterManager.getParameters(), parameterListNames, mainQuery.cteManager.isRecursive(), ctes, @@ -167,6 +168,7 @@ private QuerySpecification getQuerySpecification(Query baseQuery, Query exam this, baseQuery, exampleQuery, + parameterManager.getParameters(), parameterListNames, mainQuery.cteManager.isRecursive(), ctes, diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractInsertCollectionCriteriaBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractInsertCollectionCriteriaBuilder.java index 7f3bb8c3b5..5fcc260c3a 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractInsertCollectionCriteriaBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractInsertCollectionCriteriaBuilder.java @@ -201,6 +201,7 @@ private QuerySpecification getQuerySpecification(Query baseQuery, Query exam this, baseQuery, exampleQuery, + parameterManager.getParameters(), parameterListNames, keyRestrictedLeftJoinAliases, entityFunctionNodes, @@ -219,6 +220,7 @@ private QuerySpecification getQuerySpecification(Query baseQuery, Query exam this, baseQuery, exampleQuery, + parameterManager.getParameters(), parameterListNames, keyRestrictedLeftJoinAliases, entityFunctionNodes, diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractModificationCriteriaBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractModificationCriteriaBuilder.java index 9ea1f06202..5c045a3a77 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractModificationCriteriaBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractModificationCriteriaBuilder.java @@ -183,6 +183,7 @@ protected Query getQuery(Map includedModification this, query, getCountExampleQuery(), + parameterManager.getParameters(), parameterListNames, mainQuery.cteManager.isRecursive(), ctes, @@ -346,7 +347,7 @@ protected TypedQuery> getExecuteWithReturningQuery(TypedQ boolean shouldRenderCteNodes = renderCteNodes(false); List ctes = shouldRenderCteNodes ? getCteNodes(baseQuery, false) : Collections.EMPTY_LIST; QuerySpecification querySpecification = new ReturningModificationQuerySpecification( - this, baseQuery, exampleQuery, parameterListNames, mainQuery.cteManager.isRecursive(), ctes, shouldRenderCteNodes, returningColumns, objectBuilder + this, baseQuery, exampleQuery, parameterManager.getParameters(), parameterListNames, mainQuery.cteManager.isRecursive(), ctes, shouldRenderCteNodes, returningColumns, objectBuilder ); CustomReturningSQLTypedQuery query = new CustomReturningSQLTypedQuery( diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractUpdateCollectionCriteriaBuilder.java b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractUpdateCollectionCriteriaBuilder.java index 723d5d320e..a3cf40102b 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractUpdateCollectionCriteriaBuilder.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/AbstractUpdateCollectionCriteriaBuilder.java @@ -248,6 +248,7 @@ private QuerySpecification getQuerySpecification(Query baseQuery, Query exam this, baseQuery, exampleQuery, + parameterManager.getParameters(), parameterListNames, mainQuery.cteManager.isRecursive(), ctes, @@ -267,6 +268,7 @@ private QuerySpecification getQuerySpecification(Query baseQuery, Query exam this, baseQuery, exampleQuery, + parameterManager.getParameters(), parameterListNames, mainQuery.cteManager.isRecursive(), ctes, diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationBuilderImpl.java index 80351b2b5a..7db5f06b32 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseFinalSetOperationBuilderImpl.java @@ -269,6 +269,7 @@ protected TypedQuery getTypedQuery() { setOperationManager.getOperator(), getOrderByElements(), setOperationManager.isNested(), + parameterManager.getParameters(), parameterListNames, limit, offset, diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseInsertCriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseInsertCriteriaBuilderImpl.java index 7dc7640f0f..c7c910c77e 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/BaseInsertCriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/BaseInsertCriteriaBuilderImpl.java @@ -173,6 +173,7 @@ protected Query getQuery(Map includedModification this, query, getCountExampleQuery(), + parameterManager.getParameters(), parameterListNames, keyRestrictedLeftJoinAliases, entityFunctionNodes, diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/ExtendedParameter.java b/core/impl/src/main/java/com/blazebit/persistence/impl/ExtendedParameter.java new file mode 100644 index 0000000000..109a0774f4 --- /dev/null +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/ExtendedParameter.java @@ -0,0 +1,29 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.impl; + +import javax.persistence.Parameter; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +public interface ExtendedParameter extends Parameter { + + public boolean isCollectionValued(); + +} diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/PaginatedCriteriaBuilderImpl.java b/core/impl/src/main/java/com/blazebit/persistence/impl/PaginatedCriteriaBuilderImpl.java index 95c8869b22..ff9841c3d9 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/PaginatedCriteriaBuilderImpl.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/PaginatedCriteriaBuilderImpl.java @@ -176,7 +176,7 @@ private TypedQuery getCountQuery(String countQueryString, Class result boolean shouldRenderCteNodes = renderCteNodes(false); List ctes = shouldRenderCteNodes ? getCteNodes(baseQuery, false) : Collections.EMPTY_LIST; QuerySpecification querySpecification = new CustomQuerySpecification( - this, baseQuery, parameterListNames, null, null, keyRestrictedLeftJoinAliases, entityFunctionNodes, mainQuery.cteManager.isRecursive(), ctes, shouldRenderCteNodes + this, baseQuery, parameterManager.getParameters(), parameterListNames, null, null, keyRestrictedLeftJoinAliases, entityFunctionNodes, mainQuery.cteManager.isRecursive(), ctes, shouldRenderCteNodes ); TypedQuery countQuery = new CustomSQLTypedQuery( @@ -372,7 +372,7 @@ private Map.Entry, KeysetExtractionObjectBuilder> getObjectQuer boolean shouldRenderCteNodes = renderCteNodes(false); List ctes = shouldRenderCteNodes ? getCteNodes(baseQuery, false) : Collections.EMPTY_LIST; QuerySpecification querySpecification = new CustomQuerySpecification( - this, baseQuery, parameterListNames, null, null, keyRestrictedLeftJoinAliases, entityFunctionNodes, mainQuery.cteManager.isRecursive(), ctes, shouldRenderCteNodes + this, baseQuery, parameterManager.getParameters(), parameterListNames, null, null, keyRestrictedLeftJoinAliases, entityFunctionNodes, mainQuery.cteManager.isRecursive(), ctes, shouldRenderCteNodes ); query = new CustomSQLTypedQuery( @@ -425,7 +425,7 @@ private TypedQuery getIdQuery(String idQueryString, boolean normalQuer boolean shouldRenderCteNodes = renderCteNodes(false); List ctes = shouldRenderCteNodes ? getCteNodes(baseQuery, false) : Collections.EMPTY_LIST; QuerySpecification querySpecification = new CustomQuerySpecification( - this, baseQuery, parameterListNames, null, null, keyRestrictedLeftJoinAliases, entityFunctionNodes, mainQuery.cteManager.isRecursive(), ctes, shouldRenderCteNodes + this, baseQuery, parameterManager.getParameters(), parameterListNames, null, null, keyRestrictedLeftJoinAliases, entityFunctionNodes, mainQuery.cteManager.isRecursive(), ctes, shouldRenderCteNodes ); TypedQuery idQuery = new CustomSQLTypedQuery( @@ -459,7 +459,7 @@ private TypedQuery getObjectQueryById(boolean normalQueryMode, Set boolean shouldRenderCteNodes = renderCteNodes(false); List ctes = shouldRenderCteNodes ? getCteNodes(baseQuery, false) : Collections.EMPTY_LIST; QuerySpecification querySpecification = new CustomQuerySpecification( - this, baseQuery, parameterListNames, null, null, keyRestrictedLeftJoinAliases, entityFunctionNodes, mainQuery.cteManager.isRecursive(), ctes, shouldRenderCteNodes + this, baseQuery, parameterManager.getParameters(), parameterListNames, null, null, keyRestrictedLeftJoinAliases, entityFunctionNodes, mainQuery.cteManager.isRecursive(), ctes, shouldRenderCteNodes ); TypedQuery query = new CustomSQLTypedQuery( diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/ParameterManager.java b/core/impl/src/main/java/com/blazebit/persistence/impl/ParameterManager.java index 5262d08b5d..87559a24dc 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/ParameterManager.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/ParameterManager.java @@ -36,8 +36,8 @@ public class ParameterManager { private static final String PREFIX = "param_"; private int counter; - private final Map> parameters = new HashMap>(); - private final Map valuesParameters = new HashMap(); + private final Map> parameters = new HashMap<>(); + private final Map valuesParameters = new HashMap<>(); private final ParameterRegistrationVisitor parameterRegistrationVisitor; private final ParameterUnregistrationVisitor parameterUnregistrationVisitor; @@ -139,7 +139,7 @@ public ParameterImpl getParameter(String parameterName) { } @SuppressWarnings({ "unchecked", "rawtypes" }) - public Set> getParameters() { + public Set> getParameters() { return new HashSet>(parameters.values()); } @@ -205,7 +205,7 @@ private String addParameter(Object o, boolean collectionValued, ClauseType claus throw new NullPointerException(); } String name = PREFIX + counter++; - parameters.put(name, new ParameterImpl(name, collectionValued, clause, o)); + parameters.put(name, new ParameterImpl<>(name, collectionValued, clause, o)); return name; } @@ -213,7 +213,7 @@ public void addParameterMapping(String parameterName, Object o, ClauseType claus if (parameterName == null) { throw new NullPointerException("parameterName"); } - parameters.put(parameterName, new ParameterImpl(parameterName, o instanceof Collection, clause, o)); + parameters.put(parameterName, new ParameterImpl<>(parameterName, o instanceof Collection, clause, o)); } public void registerParameterName(String parameterName, boolean collectionValued, ClauseType clause) { @@ -222,7 +222,7 @@ public void registerParameterName(String parameterName, boolean collectionValued } ParameterImpl parameter = parameters.get(parameterName); if (parameter == null) { - parameters.put(parameterName, new ParameterImpl(parameterName, collectionValued, clause)); + parameters.put(parameterName, new ParameterImpl<>(parameterName, collectionValued, clause)); } else { parameter.getClauseTypes().add(clause); } @@ -306,7 +306,7 @@ public void setParameterType(String parameterName, Class type) { * @author Christian Beikov * @since 1.2.0 */ - static final class ParameterImpl implements Parameter { + static final class ParameterImpl implements ExtendedParameter { private final String name; private final Integer position; @@ -342,6 +342,7 @@ public Integer getPosition() { return position; } + @Override public boolean isCollectionValued() { return collectionValued; } diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/AbstractCustomQuery.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/AbstractCustomQuery.java index cd385d7baf..24d8d75845 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/AbstractCustomQuery.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/AbstractCustomQuery.java @@ -18,12 +18,21 @@ import com.blazebit.persistence.impl.ParameterValueTransformer; import com.blazebit.persistence.impl.ValuesParameterBinder; +import com.blazebit.persistence.impl.util.SetView; import com.blazebit.persistence.spi.CteQueryWrapper; import javax.persistence.Parameter; import javax.persistence.Query; import javax.persistence.TemporalType; -import java.util.*; +import java.util.Calendar; +import java.util.Collection; +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; /** * @author Christian Beikov @@ -34,56 +43,33 @@ public abstract class AbstractCustomQuery implements Query, CteQueryWrapper { protected final QuerySpecification querySpecification; protected final Map transformers; protected final Map valuesParameters; - protected final Map> parameterQueries; - protected final Set> parameters; - protected final Set parametersToSet; + protected final Map> parameters; + protected final Map valueBinders; protected int firstResult; protected int maxResults = Integer.MAX_VALUE; public AbstractCustomQuery(QuerySpecification querySpecification, Map transformers, Map valuesParameters, Map valuesBinders) { this.querySpecification = querySpecification; Map valuesParameterMap = new HashMap(); - Map> parameterQueries = new HashMap>(); - Set> parameters = new HashSet>(); - Set parametersToSet = new HashSet(); - // TODO: Fix this, currently this builds the complete query plan - for (Query q : querySpecification.getParticipatingQueries()) { - for (Parameter p : q.getParameters()) { - String name = p.getName(); - String valuesName = valuesParameters.get(name); - if (valuesName != null) { - // Replace the name with the values parameter name so the query gets registered for that - name = valuesName; - if (!valuesParameterMap.containsKey(valuesName)) { - ValuesParameter param = new ValuesParameter(valuesName, valuesBinders.get(valuesName)); - parameters.add(param); - valuesParameterMap.put(valuesName, param); - - if (!q.isBound(p)) { - parametersToSet.add(valuesName); - } - } - } - - Set queries = parameterQueries.get(name); - if (queries == null) { - queries = new HashSet(); - parameterQueries.put(name, queries); - if (valuesName == null) { - parameters.add(p); - if (!q.isBound(p)) { - parametersToSet.add(name); - } - } - } - queries.add(q); + Map> parameters = new HashMap<>(); + this.valueBinders = new HashMap<>(parameters.size()); + + for (Parameter p : querySpecification.getParameters()) { + String name = p.getName(); + String valuesName = valuesParameters.get(name); + if (valuesName == null) { + parameters.put(name, p); + valueBinders.put(name, null); + } else if (!valuesParameterMap.containsKey(valuesName)) { + ValuesParameter param = new ValuesParameter(valuesName, valuesBinders.get(valuesName)); + parameters.put(valuesName, param); + valueBinders.put(valuesName, null); + valuesParameterMap.put(valuesName, param); } } this.transformers = Collections.unmodifiableMap(transformers); this.valuesParameters = Collections.unmodifiableMap(valuesParameterMap); - this.parameters = Collections.unmodifiableSet(parameters); - this.parameterQueries = Collections.unmodifiableMap(parameterQueries); - this.parametersToSet = parametersToSet; + this.parameters = Collections.unmodifiableMap(parameters); } public QuerySpecification getQuerySpecification() { @@ -121,19 +107,37 @@ public int getFirstResult() { return firstResult; } - private Set queries(String name) { - Set queries = parameterQueries.get(name); - if (queries == null) { - throw new IllegalArgumentException("Parameter '" + name + "' does not exist!"); + protected void bindParameters() { + Set missingParameters = null; + for (Query q : querySpecification.getParticipatingQueries()) { + for (Parameter p : q.getParameters()) { + String name = p.getName(); + ValuesParameter valuesParameter = valuesParameters.get(name); + if (valuesParameter == null) { + ValueBinder valueBinder = valueBinders.get(name); + if (valueBinder == null) { + if (missingParameters == null) { + missingParameters = new HashSet<>(); + } + missingParameters.add(name); + } else { + valueBinder.bind(q, name); + } + } else { + if (valuesParameter.getValue() == null) { + if (missingParameters == null) { + missingParameters = new HashSet<>(); + } + missingParameters.add(name); + } else { + valuesParameter.bind(q); + } + } + } } - return queries; - } - - protected void validateParameterBindings() { - if (parametersToSet.isEmpty()) { - return; + if (missingParameters != null && !missingParameters.isEmpty()) { + throw new IllegalArgumentException("The following parameters have not been set: " + missingParameters); } - throw new IllegalArgumentException("The following parameters have not been set: " + parametersToSet); } @Override @@ -156,27 +160,19 @@ public Query setParameter(Parameter param, Date value, TemporalType tempor @Override public Query setParameter(String name, Object value) { - Set queries = queries(name); ValuesParameter valuesParameter = valuesParameters.get(name); - if (valuesParameter != null) { - parametersToSet.remove(name); - for (Query q : queries) { - valuesParameter.setValue(value); - valuesParameter.bind(q); + if (valuesParameter == null) { + if (!parameters.containsKey(name)) { + throw new IllegalArgumentException("Invalid or unknown parameter with name: " + name); } - } else if (queries.size() > 0) { querySpecification.onParameterChange(name); - parametersToSet.remove(name); ParameterValueTransformer transformer = transformers.get(name); if (transformer != null) { value = transformer.transform(value); } - - for (Query q : queries) { - q.setParameter(name, value); - } + valueBinders.put(name, new DefaultValueBinder(value)); } else { - throw new IllegalArgumentException("Invalid or unknown parameter with name: " + name); + valuesParameter.setValue(value); } return this; @@ -184,32 +180,22 @@ public Query setParameter(String name, Object value) { @Override public Query setParameter(String name, Calendar value, TemporalType temporalType) { - Set queries = queries(name); - if (queries.size() > 0) { - querySpecification.onParameterChange(name); - parametersToSet.remove(name); - for (Query q : queries) { - q.setParameter(name, value, temporalType); - } - } else { + if (!parameters.containsKey(name)) { throw new IllegalArgumentException("Invalid or unknown parameter with name: " + name); } + querySpecification.onParameterChange(name); + valueBinders.put(name, new CalendarValueBinder(value, temporalType)); return this; } @Override public Query setParameter(String name, Date value, TemporalType temporalType) { - Set queries = queries(name); - if (queries.size() > 0) { - querySpecification.onParameterChange(name); - parametersToSet.remove(name); - for (Query q : queries) { - q.setParameter(name, value, temporalType); - } - } else { + if (!parameters.containsKey(name)) { throw new IllegalArgumentException("Invalid or unknown parameter with name: " + name); } + querySpecification.onParameterChange(name); + valueBinders.put(name, new DateValueBinder(value, temporalType)); return this; } @@ -231,19 +217,12 @@ public Query setParameter(int position, Date value, TemporalType temporalType) { @Override public Set> getParameters() { - return parameters; + return new SetView<>(parameters.values()); } @Override public Parameter getParameter(String name) { - ValuesParameter valuesParameter = valuesParameters.get(name); - if (valuesParameter != null) { - return valuesParameter; - } - - Set queries = queries(name); - Query q = queries.iterator().next(); - return q.getParameter(name); + return parameters.get(name); } @Override @@ -272,9 +251,7 @@ public boolean isBound(Parameter param) { return valuesParameter.getValue() != null; } - Set queries = queries(param.getName()); - Query q = queries.iterator().next(); - return q.isBound(q.getParameter(param.getName())); + return valueBinders.get(param.getName()) != null; } @Override @@ -289,8 +266,8 @@ public Object getParameterValue(String name) { return valuesParameter.getValue(); } - Set queries = queries(name); - return queries.iterator().next().getParameterValue(name); + ValueBinder valueBinder = valueBinders.get(name); + return valueBinder == null ? null : valueBinder.getValue(); } @Override @@ -298,6 +275,85 @@ public Object getParameterValue(int position) { throw new IllegalArgumentException("Positional parameters unsupported!"); } + /** + * @author Christian Beikov + * @since 1.2.0 + */ + static interface ValueBinder { + void bind(Query query, String name); + Object getValue(); + } + + /** + * @author Christian Beikov + * @since 1.2.0 + */ + static class DefaultValueBinder implements ValueBinder { + private final Object value; + + public DefaultValueBinder(Object value) { + this.value = value; + } + + @Override + public void bind(Query query, String name) { + query.setParameter(name, value); + } + + @Override + public Object getValue() { + return value; + } + } + + /** + * @author Christian Beikov + * @since 1.2.0 + */ + static class CalendarValueBinder implements ValueBinder { + private final Calendar value; + private final TemporalType temporalType; + + public CalendarValueBinder(Calendar value, TemporalType temporalType) { + this.value = value; + this.temporalType = temporalType; + } + + @Override + public void bind(Query query, String name) { + query.setParameter(name, value, temporalType); + } + + @Override + public Object getValue() { + return value; + } + } + + /** + * @author Christian Beikov + * @since 1.2.0 + */ + static class DateValueBinder implements ValueBinder { + private final Date value; + private final TemporalType temporalType; + + public DateValueBinder(Date value, TemporalType temporalType) { + this.value = value; + this.temporalType = temporalType; + } + + @Override + public void bind(Query query, String name) { + query.setParameter(name, value, temporalType); + } + + @Override + public Object getValue() { + return value; + } + } + /** * @author Christian Beikov * @since 1.2.0 diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CTEQuerySpecification.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CTEQuerySpecification.java index 33f05b01dd..9e6cb4055b 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CTEQuerySpecification.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CTEQuerySpecification.java @@ -19,8 +19,12 @@ import com.blazebit.persistence.impl.AbstractCommonQueryBuilder; import com.blazebit.persistence.impl.plan.SelectQueryPlan; +import javax.persistence.Parameter; import javax.persistence.Query; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; /** * @@ -29,9 +33,9 @@ */ public class CTEQuerySpecification extends CustomQuerySpecification { - public CTEQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Set parameterListNames, String limit, String offset, + public CTEQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Set> parameters, Set parameterListNames, String limit, String offset, List keyRestrictedLeftJoinAliases, List entityFunctionNodes) { - super(commonQueryBuilder, baseQuery, parameterListNames, limit, offset, keyRestrictedLeftJoinAliases, entityFunctionNodes, false, Collections.EMPTY_LIST, false); + super(commonQueryBuilder, baseQuery, parameters, parameterListNames, limit, offset, keyRestrictedLeftJoinAliases, entityFunctionNodes, false, Collections.EMPTY_LIST, false); } @Override diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CollectionDeleteModificationQuerySpecification.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CollectionDeleteModificationQuerySpecification.java index 5c6cfa92bd..1b1b43c775 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CollectionDeleteModificationQuerySpecification.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CollectionDeleteModificationQuerySpecification.java @@ -20,6 +20,7 @@ import com.blazebit.persistence.impl.util.SqlUtils; import com.blazebit.persistence.spi.DbmsModificationState; +import javax.persistence.Parameter; import javax.persistence.Query; import java.util.ArrayList; import java.util.List; @@ -39,9 +40,9 @@ public class CollectionDeleteModificationQuerySpecification extends Modification private final String deleteSql; private final Map columnExpressionRemappings; - public CollectionDeleteModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set parameterListNames, boolean recursive, List ctes, boolean shouldRenderCteNodes, + public CollectionDeleteModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set> parameters, Set parameterListNames, boolean recursive, List ctes, boolean shouldRenderCteNodes, boolean isEmbedded, String[] returningColumns, Map includedModificationStates, Map returningAttributeBindingMap, Query deleteExampleQuery, String deleteSql, Map columnExpressionRemappings) { - super(commonQueryBuilder, baseQuery, exampleQuery, parameterListNames, recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap); + super(commonQueryBuilder, baseQuery, exampleQuery, parameters, parameterListNames, recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap); this.deleteExampleQuery = deleteExampleQuery; this.deleteSql = deleteSql; this.columnExpressionRemappings = columnExpressionRemappings; diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CollectionInsertModificationQuerySpecification.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CollectionInsertModificationQuerySpecification.java index 9452cd30d4..0a304a3123 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CollectionInsertModificationQuerySpecification.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CollectionInsertModificationQuerySpecification.java @@ -19,6 +19,7 @@ import com.blazebit.persistence.impl.AbstractCommonQueryBuilder; import com.blazebit.persistence.spi.DbmsModificationState; +import javax.persistence.Parameter; import javax.persistence.Query; import java.util.ArrayList; import java.util.List; @@ -35,10 +36,10 @@ public class CollectionInsertModificationQuerySpecification extends Modification private final Query insertExampleQuery; private final String insertSql; - public CollectionInsertModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set parameterListNames, + public CollectionInsertModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set> parameters, Set parameterListNames, List keyRestrictedLeftJoinAliases, List entityFunctionNodes, boolean recursive, List ctes, boolean shouldRenderCteNodes, boolean isEmbedded, String[] returningColumns, Map includedModificationStates, Map returningAttributeBindingMap, Query insertExampleQuery, String insertSql) { - super(commonQueryBuilder, baseQuery, exampleQuery, parameterListNames, keyRestrictedLeftJoinAliases, entityFunctionNodes, recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap); + super(commonQueryBuilder, baseQuery, exampleQuery, parameters, parameterListNames, keyRestrictedLeftJoinAliases, entityFunctionNodes, recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap); this.insertExampleQuery = insertExampleQuery; this.insertSql = insertSql; } diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CollectionUpdateModificationQuerySpecification.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CollectionUpdateModificationQuerySpecification.java index 53c648e8da..a6e83a2957 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CollectionUpdateModificationQuerySpecification.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CollectionUpdateModificationQuerySpecification.java @@ -20,6 +20,7 @@ import com.blazebit.persistence.impl.util.SqlUtils; import com.blazebit.persistence.spi.DbmsModificationState; +import javax.persistence.Parameter; import javax.persistence.Query; import java.util.ArrayList; import java.util.List; @@ -41,9 +42,9 @@ public class CollectionUpdateModificationQuerySpecification extends Modification private final Map columnOnlyRemappings; private final Map columnExpressionRemappings; - public CollectionUpdateModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set parameterListNames, boolean recursive, List ctes, boolean shouldRenderCteNodes, boolean isEmbedded, String[] returningColumns, + public CollectionUpdateModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set> parameters, Set parameterListNames, boolean recursive, List ctes, boolean shouldRenderCteNodes, boolean isEmbedded, String[] returningColumns, Map includedModificationStates, Map returningAttributeBindingMap, Query updateExampleQuery, String updateSql, List setExpressionContainingUpdateQueries, Map columnOnlyRemappings, Map columnExpressionRemappings) { - super(commonQueryBuilder, baseQuery, exampleQuery, parameterListNames, recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap); + super(commonQueryBuilder, baseQuery, exampleQuery, parameters, parameterListNames, recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap); this.updateExampleQuery = updateExampleQuery; this.updateSql = updateSql; this.setExpressionContainingUpdateQueries = setExpressionContainingUpdateQueries; diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomQuerySpecification.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomQuerySpecification.java index a87b0ff7e5..e98815f5e8 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomQuerySpecification.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomQuerySpecification.java @@ -28,8 +28,13 @@ import com.blazebit.persistence.spi.ServiceProvider; import javax.persistence.EntityManager; +import javax.persistence.Parameter; import javax.persistence.Query; -import java.util.*; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; /** * @@ -45,6 +50,7 @@ public class CustomQuerySpecification implements QuerySpecification { protected final DbmsStatementType statementType; protected final Query baseQuery; + protected final Set> parameters; protected final Set parameterListNames; protected final String limit; protected final String offset; @@ -60,7 +66,7 @@ public class CustomQuerySpecification implements QuerySpecification { protected List participatingQueries; protected Map addedCtes; - public CustomQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Set parameterListNames, String limit, String offset, + public CustomQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Set> parameters, Set parameterListNames, String limit, String offset, List keyRestrictedLeftJoinAliases, List entityFunctionNodes, boolean recursive, List ctes, boolean shouldRenderCtes) { this.em = commonQueryBuilder.getEntityManager(); this.dbmsDialect = commonQueryBuilder.getService(DbmsDialect.class); @@ -68,6 +74,7 @@ public CustomQuerySpecification(AbstractCommonQueryBuilder common this.extendedQuerySupport = commonQueryBuilder.getService(ExtendedQuerySupport.class); this.statementType = commonQueryBuilder.getStatementType(); this.baseQuery = baseQuery; + this.parameters = parameters; this.parameterListNames = parameterListNames; this.limit = limit; this.offset = offset; @@ -107,6 +114,12 @@ public List getParticipatingQueries() { return participatingQueries; } + @Override + @SuppressWarnings("unchecked") + public Set> getParameters() { + return (Set>) (Set) parameters; + } + @Override public Map getAddedCtes() { if (dirty) { diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomReturningSQLTypedQuery.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomReturningSQLTypedQuery.java index 1351beec14..cf09df25a7 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomReturningSQLTypedQuery.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomReturningSQLTypedQuery.java @@ -44,20 +44,20 @@ public CustomReturningSQLTypedQuery(QuerySpecification> query @Override @SuppressWarnings("unchecked") public List> getResultList() { - validateParameterBindings(); + bindParameters(); return querySpecification.createSelectPlan(firstResult, maxResults).getResultList(); } @Override @SuppressWarnings("unchecked") public ReturningResult getSingleResult() { - validateParameterBindings(); + bindParameters(); return querySpecification.createSelectPlan(firstResult, maxResults).getSingleResult(); } @Override public int executeUpdate() { - validateParameterBindings(); + bindParameters(); return querySpecification.createModificationPlan(firstResult, maxResults).executeUpdate(); } diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomSQLQuery.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomSQLQuery.java index c03867ce37..29fa880648 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomSQLQuery.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomSQLQuery.java @@ -56,7 +56,7 @@ public Object getSingleResult() { @Override public int executeUpdate() { - validateParameterBindings(); + bindParameters(); return querySpecification.createModificationPlan(firstResult, maxResults).executeUpdate(); } diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomSQLTypedQuery.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomSQLTypedQuery.java index d7d7db849f..8abc488f22 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomSQLTypedQuery.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/CustomSQLTypedQuery.java @@ -46,14 +46,14 @@ public CustomSQLTypedQuery(QuerySpecification querySpecification, TypedQuery @Override @SuppressWarnings("unchecked") public List getResultList() { - validateParameterBindings(); + bindParameters(); return querySpecification.createSelectPlan(firstResult, maxResults).getResultList(); } @Override @SuppressWarnings("unchecked") public X getSingleResult() { - validateParameterBindings(); + bindParameters(); return querySpecification.createSelectPlan(firstResult, maxResults).getSingleResult(); } diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/DefaultQuerySpecification.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/DefaultQuerySpecification.java index aeba915920..c17607fa1d 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/DefaultQuerySpecification.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/DefaultQuerySpecification.java @@ -24,6 +24,7 @@ import com.blazebit.persistence.spi.ExtendedQuerySupport; import javax.persistence.EntityManager; +import javax.persistence.Parameter; import javax.persistence.Query; import java.util.Arrays; import java.util.List; @@ -71,6 +72,11 @@ public List getParticipatingQueries() { return Arrays.asList(query); } + @Override + public Set> getParameters() { + return query.getParameters(); + } + @Override public Map getAddedCtes() { return null; diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/ModificationQuerySpecification.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/ModificationQuerySpecification.java index 7cdaa4ba96..e1f418273e 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/ModificationQuerySpecification.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/ModificationQuerySpecification.java @@ -23,8 +23,14 @@ import com.blazebit.persistence.spi.DbmsLimitHandler; import com.blazebit.persistence.spi.DbmsModificationState; +import javax.persistence.Parameter; import javax.persistence.Query; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; /** * @@ -41,15 +47,15 @@ public class ModificationQuerySpecification extends CustomQuerySpecification { protected Query query; - public ModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set parameterListNames, boolean recursive, List ctes, boolean shouldRenderCteNodes, + public ModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set> parameters, Set parameterListNames, boolean recursive, List ctes, boolean shouldRenderCteNodes, boolean isEmbedded, String[] returningColumns, Map includedModificationStates, Map returningAttributeBindingMap) { - this(commonQueryBuilder, baseQuery, exampleQuery, parameterListNames, Collections.emptyList(), Collections.emptyList(), recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap); + this(commonQueryBuilder, baseQuery, exampleQuery, parameters, parameterListNames, Collections.emptyList(), Collections.emptyList(), recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap); } - public ModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set parameterListNames, - List keyRestrictedLeftJoinAliases, List entityFunctionNodes, boolean recursive, List ctes, boolean shouldRenderCteNodes, - boolean isEmbedded, String[] returningColumns, Map includedModificationStates, Map returningAttributeBindingMap) { - super(commonQueryBuilder, baseQuery, parameterListNames, null, null, keyRestrictedLeftJoinAliases, entityFunctionNodes, recursive, ctes, shouldRenderCteNodes); + public ModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set> parameters, Set parameterListNames, + List keyRestrictedLeftJoinAliases, List entityFunctionNodes, boolean recursive, List ctes, boolean shouldRenderCteNodes, + boolean isEmbedded, String[] returningColumns, Map includedModificationStates, Map returningAttributeBindingMap) { + super(commonQueryBuilder, baseQuery, parameters, parameterListNames, null, null, keyRestrictedLeftJoinAliases, entityFunctionNodes, recursive, ctes, shouldRenderCteNodes); this.exampleQuery = exampleQuery; this.isEmbedded = isEmbedded; this.returningColumns = returningColumns; diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/QuerySpecification.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/QuerySpecification.java index 89b49441ac..bdb8e5fe6d 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/QuerySpecification.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/QuerySpecification.java @@ -19,9 +19,11 @@ import com.blazebit.persistence.impl.plan.ModificationQueryPlan; import com.blazebit.persistence.impl.plan.SelectQueryPlan; +import javax.persistence.Parameter; import javax.persistence.Query; import java.util.List; import java.util.Map; +import java.util.Set; /** * @@ -38,6 +40,8 @@ public interface QuerySpecification { public List getParticipatingQueries(); + public Set> getParameters(); + public Map getAddedCtes(); public Query getBaseQuery(); diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningCollectionDeleteModificationQuerySpecification.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningCollectionDeleteModificationQuerySpecification.java index e623311788..6ed4edaaa8 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningCollectionDeleteModificationQuerySpecification.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningCollectionDeleteModificationQuerySpecification.java @@ -23,6 +23,7 @@ import com.blazebit.persistence.impl.plan.SelectQueryPlan; import com.blazebit.persistence.spi.DbmsModificationState; +import javax.persistence.Parameter; import javax.persistence.Query; import java.util.List; import java.util.Map; @@ -37,10 +38,10 @@ public class ReturningCollectionDeleteModificationQuerySpecification extends private final ReturningObjectBuilder objectBuilder; - public ReturningCollectionDeleteModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set parameterListNames, boolean recursive, List ctes, boolean shouldRenderCteNodes, + public ReturningCollectionDeleteModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set> parameters, Set parameterListNames, boolean recursive, List ctes, boolean shouldRenderCteNodes, boolean isEmbedded, String[] returningColumns, Map includedModificationStates, Map returningAttributeBindingMap, Query deleteExampleQuery, String deleteSql, Map columnExpressionRemappings, ReturningObjectBuilder objectBuilder) { - super(commonQueryBuilder, baseQuery, exampleQuery, parameterListNames, recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap, deleteExampleQuery, deleteSql, columnExpressionRemappings); + super(commonQueryBuilder, baseQuery, exampleQuery, parameters, parameterListNames, recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap, deleteExampleQuery, deleteSql, columnExpressionRemappings); this.objectBuilder = objectBuilder; } diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningCollectionInsertModificationQuerySpecification.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningCollectionInsertModificationQuerySpecification.java index d21e09a7b4..ccddbc5272 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningCollectionInsertModificationQuerySpecification.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningCollectionInsertModificationQuerySpecification.java @@ -23,6 +23,7 @@ import com.blazebit.persistence.impl.plan.SelectQueryPlan; import com.blazebit.persistence.spi.DbmsModificationState; +import javax.persistence.Parameter; import javax.persistence.Query; import java.util.List; import java.util.Map; @@ -37,9 +38,9 @@ public class ReturningCollectionInsertModificationQuerySpecification extends private final ReturningObjectBuilder objectBuilder; - public ReturningCollectionInsertModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set parameterListNames, List keyRestrictedLeftJoinAliases, List entityFunctionNodes, boolean recursive, List ctes, boolean shouldRenderCteNodes, + public ReturningCollectionInsertModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set> parameters, Set parameterListNames, List keyRestrictedLeftJoinAliases, List entityFunctionNodes, boolean recursive, List ctes, boolean shouldRenderCteNodes, boolean isEmbedded, String[] returningColumns, Map includedModificationStates, Map returningAttributeBindingMap, Query insertExampleQuery, String insertSql, ReturningObjectBuilder objectBuilder) { - super(commonQueryBuilder, baseQuery, exampleQuery, parameterListNames, keyRestrictedLeftJoinAliases, entityFunctionNodes, recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap, insertExampleQuery, insertSql); + super(commonQueryBuilder, baseQuery, exampleQuery, parameters, parameterListNames, keyRestrictedLeftJoinAliases, entityFunctionNodes, recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap, insertExampleQuery, insertSql); this.objectBuilder = objectBuilder; } diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningCollectionUpdateModificationQuerySpecification.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningCollectionUpdateModificationQuerySpecification.java index f0c30be6b7..8a71242eac 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningCollectionUpdateModificationQuerySpecification.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningCollectionUpdateModificationQuerySpecification.java @@ -23,6 +23,7 @@ import com.blazebit.persistence.impl.plan.SelectQueryPlan; import com.blazebit.persistence.spi.DbmsModificationState; +import javax.persistence.Parameter; import javax.persistence.Query; import java.util.List; import java.util.Map; @@ -37,10 +38,10 @@ public class ReturningCollectionUpdateModificationQuerySpecification extends private final ReturningObjectBuilder objectBuilder; - public ReturningCollectionUpdateModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set parameterListNames, boolean recursive, List ctes, boolean shouldRenderCteNodes, + public ReturningCollectionUpdateModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set> parameters, Set parameterListNames, boolean recursive, List ctes, boolean shouldRenderCteNodes, boolean isEmbedded, String[] returningColumns, Map includedModificationStates, Map returningAttributeBindingMap, Query updateExampleQuery, String updateSql, List setExpressionContainingUpdateQueries, Map columnOnlyRemappings, Map columnExpressionRemappings, ReturningObjectBuilder objectBuilder) { - super(commonQueryBuilder, baseQuery, exampleQuery, parameterListNames, recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap, updateExampleQuery, updateSql, setExpressionContainingUpdateQueries, columnOnlyRemappings, columnExpressionRemappings); + super(commonQueryBuilder, baseQuery, exampleQuery, parameters, parameterListNames, recursive, ctes, shouldRenderCteNodes, isEmbedded, returningColumns, includedModificationStates, returningAttributeBindingMap, updateExampleQuery, updateSql, setExpressionContainingUpdateQueries, columnOnlyRemappings, columnExpressionRemappings); this.objectBuilder = objectBuilder; } diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningModificationQuerySpecification.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningModificationQuerySpecification.java index d263a2ee7a..15841c0d2d 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningModificationQuerySpecification.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/ReturningModificationQuerySpecification.java @@ -22,8 +22,13 @@ import com.blazebit.persistence.impl.plan.ModificationQueryPlan; import com.blazebit.persistence.impl.plan.SelectQueryPlan; +import javax.persistence.Parameter; import javax.persistence.Query; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; /** * @@ -36,9 +41,9 @@ public class ReturningModificationQuerySpecification extends CustomQuerySpeci private final String[] returningColumns; private final ReturningObjectBuilder objectBuilder; - public ReturningModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set parameterListNames, boolean recursive, List ctes, boolean shouldRenderCteNodes, + public ReturningModificationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query baseQuery, Query exampleQuery, Set> parameters, Set parameterListNames, boolean recursive, List ctes, boolean shouldRenderCteNodes, String[] returningColumns, ReturningObjectBuilder objectBuilder) { - super(commonQueryBuilder, baseQuery, parameterListNames, null, null, Collections.EMPTY_LIST, Collections.EMPTY_LIST, recursive, ctes, shouldRenderCteNodes); + super(commonQueryBuilder, baseQuery, parameters, parameterListNames, null, null, Collections.EMPTY_LIST, Collections.EMPTY_LIST, recursive, ctes, shouldRenderCteNodes); this.exampleQuery = exampleQuery; this.returningColumns = returningColumns; this.objectBuilder = objectBuilder; diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/query/SetOperationQuerySpecification.java b/core/impl/src/main/java/com/blazebit/persistence/impl/query/SetOperationQuerySpecification.java index 3d7c221bf5..e0196459b8 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/query/SetOperationQuerySpecification.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/query/SetOperationQuerySpecification.java @@ -22,8 +22,12 @@ import com.blazebit.persistence.spi.OrderByElement; import com.blazebit.persistence.spi.SetOperationType; +import javax.persistence.Parameter; import javax.persistence.Query; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; /** * @@ -39,9 +43,9 @@ public class SetOperationQuerySpecification extends CustomQuerySpecification { private final boolean nested; public SetOperationQuerySpecification(AbstractCommonQueryBuilder commonQueryBuilder, Query leftMostQuery, Query baseQuery, List setOperands, SetOperationType operator, - List orderByElements, boolean nested, Set parameterListNames, String limit, String offset, + List orderByElements, boolean nested, Set> parameters, Set parameterListNames, String limit, String offset, List keyRestrictedLeftJoinAliases, List entityFunctionNodes, boolean recursive, List ctes, boolean shouldRenderCteNodes) { - super(commonQueryBuilder, baseQuery, parameterListNames, limit, offset, keyRestrictedLeftJoinAliases, entityFunctionNodes, recursive, ctes, shouldRenderCteNodes); + super(commonQueryBuilder, baseQuery, parameters, parameterListNames, limit, offset, keyRestrictedLeftJoinAliases, entityFunctionNodes, recursive, ctes, shouldRenderCteNodes); this.leftMostQuery = leftMostQuery; this.setOperands = setOperands; this.operator = operator; diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/util/SetView.java b/core/impl/src/main/java/com/blazebit/persistence/impl/util/SetView.java new file mode 100644 index 0000000000..0da08c3ee2 --- /dev/null +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/util/SetView.java @@ -0,0 +1,111 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.impl.util; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Iterator; +import java.util.Set; + +/** + * A set implementation that allows to provide a set view of a collection. + * + * @author Christian Beikov + * @since 1.2.0 + */ +public class SetView implements Set, Serializable { + + final Collection c; + + public SetView(Collection c) { + if (c == null) { + throw new NullPointerException(); + } + this.c = c; + } + + public int size() { + return c.size(); + } + + public boolean isEmpty() { + return c.isEmpty(); + } + + public boolean contains(Object o) { + return c.contains(o); + } + + public Object[] toArray() { + return c.toArray(); + } + + public T[] toArray(T[] a) { + return c.toArray(a); + } + + public String toString() { + return c.toString(); + } + + public Iterator iterator() { + return new Iterator() { + private final Iterator i = c.iterator(); + + public boolean hasNext() { + return i.hasNext(); + } + + public E next() { + return i.next(); + } + + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + + public boolean add(E e) { + throw new UnsupportedOperationException(); + } + + public boolean remove(Object o) { + throw new UnsupportedOperationException(); + } + + public boolean containsAll(Collection coll) { + return c.containsAll(coll); + } + + public boolean addAll(Collection coll) { + throw new UnsupportedOperationException(); + } + + public boolean removeAll(Collection coll) { + throw new UnsupportedOperationException(); + } + + public boolean retainAll(Collection coll) { + throw new UnsupportedOperationException(); + } + + public void clear() { + throw new UnsupportedOperationException(); + } + +} diff --git a/core/testsuite/pom.xml b/core/testsuite/pom.xml index f1e0285478..8a0e29cb7f 100644 --- a/core/testsuite/pom.xml +++ b/core/testsuite/pom.xml @@ -73,6 +73,28 @@ 1.10.19 + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.annotation + javax.annotation-api + ${version.annotation} + + @@ -600,7 +622,6 @@ generate-sources - ${processor.plugin.compilerArguments} ${project.build.directory}/generated-sources/metamodel @@ -616,6 +637,31 @@ hibernate-jpamodelgen 1.3.0.Final + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -715,6 +761,31 @@ hibernate-jpamodelgen ${version.hibernate-4.3} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -814,6 +885,31 @@ hibernate-jpamodelgen ${version.hibernate-5} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -913,6 +1009,31 @@ hibernate-jpamodelgen ${version.hibernate-5.1} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -1015,6 +1136,155 @@ hibernate-jpamodelgen ${version.hibernate-5.2} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + + + + hibernate-5.3 + + com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate52 + src/main/hibernate + + + + org.hibernate + hibernate-entitymanager + ${version.hibernate-5.3} + + + org.hibernate + hibernate-testing + ${version.hibernate-5.3} + + + ${project.groupId} + blaze-persistence-integration-hibernate-5.3 + test + + + ${project.groupId} + blaze-persistence-testsuite-base-hibernate + compile + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5.3} + provided + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${additional.source.directory} + ${project.build.directory}/generated-sources/metamodel + + + + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/generated-sources/metamodel + + org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor + + + + + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5.3} + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -1121,6 +1391,31 @@ hibernate-jpamodelgen ${version.hibernate-6.0} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -1201,6 +1496,31 @@ org.eclipse.persistence.jpa.modelgen.processor ${version.eclipselink} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -1250,6 +1570,10 @@ blaze-persistence-testsuite-base-datanucleus compile + + ${project.groupId} + blaze-persistence-integration-datanucleus + @@ -1288,6 +1612,10 @@ blaze-persistence-testsuite-base-datanucleus ${project.version} + + ${project.groupId} + blaze-persistence-integration-datanucleus + @@ -1335,6 +1663,31 @@ datanucleus-jpa-query ${version.datanucleus.jpa-5} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -1384,6 +1737,163 @@ blaze-persistence-testsuite-base-datanucleus compile + + ${project.groupId} + blaze-persistence-integration-datanucleus + + + + + + org.datanucleus + datanucleus-maven-plugin + 4.0.0-release + + JPA + TestsuiteBase + false + true + ${basedir}/log4j.properties + ${project.build.outputDirectory} + true + + + + process-classes + + enhance + + + + + + ${project.groupId} + blaze-persistence-testsuite-base-datanucleus + ${project.version} + + + ${project.groupId} + blaze-persistence-integration-datanucleus + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${additional.source.directory} + ${project.build.directory}/generated-sources/metamodel + + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/generated-sources/metamodel + + org.datanucleus.jpa.query.JPACriteriaProcessor + + + + + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + + + + datanucleus-5.1 + + com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus + src/main/basic + + + + DataNucleus Nightly + DataNucleus Repository Nightly + http://www.datanucleus.org/downloads/maven2-nightly + + + + + org.datanucleus + javax.persistence + 2.2.0-release + + + org.datanucleus + datanucleus-core + ${version.datanucleus.base-5.1} + + + org.datanucleus + datanucleus-api-jpa + ${version.datanucleus.api-jpa-5.1} + + + org.datanucleus + datanucleus-jpa-query + ${version.datanucleus.jpa-5.1} + + + org.datanucleus + datanucleus-rdbms + ${version.datanucleus.rdbms-5.1} + + + ${project.groupId} + blaze-persistence-testsuite-base-datanucleus + compile + + + ${project.groupId} + blaze-persistence-integration-datanucleus-5.1 + @@ -1414,6 +1924,11 @@ blaze-persistence-testsuite-base-datanucleus ${project.version} + + ${project.groupId} + blaze-persistence-integration-datanucleus-5.1 + ${project.version} + @@ -1454,6 +1969,33 @@ + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + @@ -1525,6 +2067,31 @@ openjpa-all ${version.openjpa} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + diff --git a/dist/bom/pom.xml b/dist/bom/pom.xml index 90b72040db..df9539a882 100644 --- a/dist/bom/pom.xml +++ b/dist/bom/pom.xml @@ -131,6 +131,12 @@ ${project.version} runtime + + ${project.groupId} + blaze-persistence-integration-hibernate-5.3 + ${project.version} + runtime + ${project.groupId} blaze-persistence-integration-hibernate-6.0 @@ -143,6 +149,12 @@ ${project.version} runtime + + ${project.groupId} + blaze-persistence-integration-datanucleus-5.1 + ${project.version} + runtime + ${project.groupId} blaze-persistence-integration-eclipselink diff --git a/dist/full/pom.xml b/dist/full/pom.xml index 81ad63e7e1..23ba5058cb 100644 --- a/dist/full/pom.xml +++ b/dist/full/pom.xml @@ -97,6 +97,10 @@ ${project.groupId} blaze-persistence-integration-hibernate-5.2 + + ${project.groupId} + blaze-persistence-integration-hibernate-5.3 + ${project.groupId} blaze-persistence-integration-hibernate-6.0 @@ -105,6 +109,10 @@ ${project.groupId} blaze-persistence-integration-datanucleus + + ${project.groupId} + blaze-persistence-integration-datanucleus-5.1 + ${project.groupId} blaze-persistence-integration-eclipselink diff --git a/documentation/src/main/asciidoc/core/manual/en_US/02_getting_started.adoc b/documentation/src/main/asciidoc/core/manual/en_US/02_getting_started.adoc index 129c4a4934..d80da63038 100644 --- a/documentation/src/main/asciidoc/core/manual/en_US/02_getting_started.adoc +++ b/documentation/src/main/asciidoc/core/manual/en_US/02_getting_started.adoc @@ -53,6 +53,19 @@ The required dependencies for the core module are Depending on the JPA provider that should be used, one of the following integrations is required +[[maven-setup-hibernate53]] +===== Hibernate 5.3 + +[source,xml] +---- + + com.blazebit + blaze-persistence-integration-hibernate-5.3 + ${blaze-persistence.version} + runtime + +---- + [[maven-setup-hibernate52]] ===== Hibernate 5.2 @@ -105,8 +118,21 @@ Depending on the JPA provider that should be used, one of the following integrat ---- +[[maven-setup-datanucleus51]] +===== Datanucleus 5.1 + +[source,xml] +---- + + com.blazebit + blaze-persistence-integration-datanucleus-5.1 + ${blaze-persistence.version} + runtime + +---- + [[maven-setup-datanucleus]] -===== Datanucleus +===== Datanucleus 4 and 5 [source,xml] ---- @@ -258,6 +284,115 @@ public class BlazePersistenceConfiguration { } ---- +[[supported-java-runtimes]] +=== Supported Java runtimes + +All projects are built for Java 7 except for the ones where dependencies already use Java 8 like e.g. Hibernate 5.2, Spring Data 2.0 etc. +So you are going to need at least JDK 8 for building the project. + +We also support building the project with JDK 9 and try to keep up with newer versions. +If you want to run your application on a Java 9 JVM you need to handle the fact that JDK 9+ doesn't export some APIs like the JAXB, JAF, javax.annotations and JTA anymore. +In fact, JDK 11 will even remove the modules so the command line flags to add modules to the classpath won't work. + +Since libraries like Hibernate and others require these APIs you need to make them available. The easiest way to get these APIs back on the classpath is to package them along with your application. +This will also work when running on Java 8. We suggest you add the following dependencies. + +[source,xml] +---- + + javax.xml.bind + jaxb-api + 2.2.11 + + + com.sun.xml.bind + jaxb-core + 2.2.11 + + + com.sun.xml.bind + jaxb-impl + 2.2.11 + + + javax.transaction + javax.transaction-api + 1.2 + + provided + + + javax.activation + activation + 1.1.1 + + provided + + + javax.annotation + javax.annotation-api + 1.3.2 + + provided + +---- + +Automatic module names for modules. + +|=== +|Module |Automatic module name + +|Core API +|com.blazebit.persistence.core + +|Core Impl +|com.blazebit.persistence.core.impl + +|Core Parser +|com.blazebit.persistence.core.parser + +|JPA Criteria API +|com.blazebit.persistence.criteria + +|Core Impl +|com.blazebit.persistence.criteria.impl + +|JPA Criteria JPA2 Compatibility +|com.blazebit.persistence.criteria.jpa2compatibility + +|=== + +=== Supported environments/libraries + +The bare minimum is JPA 2.0. If you want to use the JPA Criteria API module, you will also have to add the JPA 2 compatibility module. +Generally, we support the usage in Java EE 6+ or Spring 4+ applications. + +The following table outlines the supported library versions for the integrations. + +|=== +|Module |Automatic module name |Minimum version |Supported versions + +|Hibernate integration +|com.blazebit.persistence.integration.hibernate +|Hibernate 4.2 +|4.2, 4.3, 5.0, 5.1, 5.2, 5.3 (not all features are available in older versions) + +|EclipseLink integration +|com.blazebit.persistence.integration.eclipselink +|EclipseLink 2.6 +|2.6 (Probably 2.4 and 2.5 work as well, but only tested against 2.6) + +|DataNucleus integration +|com.blazebit.persistence.integration.datanucleus +|DataNucleus 4.1 +|4.1, 5.0 + +|OpenJPA integration +|com.blazebit.persistence.integration.openjpa +|N/A +|(Currently not usable. OpenJPA doesn't seem to be actively developed anymore and no users asked for support yet) +|=== + === First criteria query This section is supposed to give you a first feeling of how to use the criteria diff --git a/documentation/src/main/asciidoc/entity-view/manual/en_US/02_getting_started.adoc b/documentation/src/main/asciidoc/entity-view/manual/en_US/02_getting_started.adoc index 86e4c975ca..9b4fb4cc21 100644 --- a/documentation/src/main/asciidoc/entity-view/manual/en_US/02_getting_started.adoc +++ b/documentation/src/main/asciidoc/entity-view/manual/en_US/02_getting_started.adoc @@ -279,6 +279,59 @@ public class BlazePersistenceConfiguration { } ---- +[[supported-java-runtimes]] +=== Supported Java runtimes + +The entity view module like all other modules generally follows what has already been stated in the link:{core_doc}#supported-java-runtimes[core moduel documentation]. + +Automatic module names for modules. + +|=== +|Module |Automatic module name + +|Entity View API +|com.blazebit.persistence.view + +|Entity View Impl +|com.blazebit.persistence.view.impl + +|=== + +=== Supported environments/libraries + +Generally, we support the usage in Java EE 6+ or Spring 4+ applications. + +The following table outlines the supported library versions for the integrations. + +|=== +|Module |Automatic module name |Minimum version |Supported versions + +|CDI integration +|com.blazebit.persistence.integration.view.cdi +|CDI 1.0 +|1.0, 1.1, 1.2 + +|Spring integration +|com.blazebit.persistence.integration.view.spring +|Spring 4.3 +|4.3, 5.0 + +|DeltaSpike Data integration +|com.blazebit.persistence.integration.deltaspike.data +|DeltaSpike 1.7 +|1.7, 1.8 + +|Spring Data integration +|com.blazebit.persistence.integration.spring.data +|Spring Data 1.11 +|1.11, 2.0 + +|Spring Data Rest integration +|com.blazebit.persistence.integration.spring.data.rest +|Spring Data 1.11, Spring MVC 4.3 +|Spring Data 1.11 + Spring MVC 4.3, Spring Data 2.0 + Spring MVC 5.0 +|=== + === First entity view query This section is supposed to give you a first feeling of how to use entity views. diff --git a/documentation/src/main/asciidoc/entity-view/manual/en_US/12_spring_data.adoc b/documentation/src/main/asciidoc/entity-view/manual/en_US/12_spring_data.adoc index 254010f131..312a105092 100644 --- a/documentation/src/main/asciidoc/entity-view/manual/en_US/12_spring_data.adoc +++ b/documentation/src/main/asciidoc/entity-view/manual/en_US/12_spring_data.adoc @@ -16,7 +16,7 @@ In short, the following Maven dependencies are required ---- com.blazebit - blaze-persistence-integration-spring-data-2x + blaze-persistence-integration-spring-data-2.x ${blaze-persistence.version} compile @@ -143,7 +143,7 @@ public class MyCatController { } ---- -Support for https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#specifications[Spring Data Specifications] can be added to an entity view repository by extending from `com.blazebit.persistence.spring.data.repository.EntityViewSpecificationExecutor`. +https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#specifications[Spring Data Specifications] can be used without restrictions. There is also the convenience base interface `com.blazebit.persistence.spring.data.repository.EntityViewSpecificationExecutor` that can be extended from. [source,java] ---- @@ -167,5 +167,107 @@ public class MyCatController { } ---- +The integration handles ad-hoc uses of https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.entity-graph[`@EntityGraph`] by adapting the query generation through call of link:{core_jdoc}/persistence/CriteriaBuilder.html#fetch(java.lang.String...)[`CriteriaBuilder.fetch()`] rather than passing the entity graphs as hints. + +Another notable feature the integration provides is the support for the return type `KeysetAwarePage` as a replacement for `Page`. +By using `KeysetAwarePage` the keyset pagination feature is enabled for the repository method. + +[source,java] +---- +@Transactional(readOnly = true) +public interface KeysetAwareCatViewRepository extends Repository { + + KeysetAwarePage findAll(Pageable pageable); +} +---- + +Note that the `Pageable` should be an instance of `KeysetPageable` if keyset pagination should be used. A `KeysetPageable` can be retrieved through the `KeysetAwarePage` or manually +by constructing a `KeysetPageRequest`. Note that constructing a `KeysetPageRequest` or actually the contained `KeysetPage` manually is not recommended. When working with Spring MVC, +the Spring Data Rest integration might come in handy. For stateful server side frameworks, it's best to put the `KeysetAwarePage` into a session like storage +to be able to use the `previousOrFirst()` and `next()` methods for retrieving `KeysetPageable` objects. + All other Spring Data repository features like restrictions, pagination, slices and ordering are supported as usual. -Please consult the Spring Data documentation for further information. \ No newline at end of file +Please consult the Spring Data documentation for further information. + +=== Spring Data Rest integration + +The Spring Data Rest integration offers similar pagination features for keyset pagination to what Spring Data already offers for normal pagination. +First, a keyset pagination enabled repository is needed. + + +[source,java] +---- +@Transactional(readOnly = true) +public interface KeysetAwareCatViewRepository extends Repository { + + KeysetAwarePage findAll(Pageable pageable); +} +---- + +A controller can then use this repository like the following: + +[source,java] +---- +@Controller +public class MyCatController { + + @Autowired + private KeysetAwareCatViewRepository simpleCatViewRepository; + + @RequestMapping(path = "/cats", method = RequestMethod.GET) + public Page getCats(@KeysetConfig(Cat.class) KeysetPageable pageable) { + return simpleCatViewRepository.findAll(pageable); + } +---- + +Note that {projectname} imposes some very important requirements that have to be fulfilled + +* There must always be a sort specification +* The last sort specification must be the entity identifier + +For the keyset pagination to kick in, the client has to _remember_ the values by which the sorting is done of the first and the last element of the result. +The values then need to be passed to the next request as JSON encoded query parameters. The values of the first element should use the parameter `lowest` and the last element the parameter `highest`. + +The following will illustrate how this works. + +First, the client makes an initial request. + +[source] +---- +GET /cats?page=0&size=3&sort=id,desc +{ + content: [ + { id: 10, name: 'Felix', age: 10 }, + { id: 9, name: 'Robin', age: 4 }, + { id: 8, name: 'Billy', age: 7 } + ] +} +---- + +It's the responsibility of the client to remember the attributes by which it sorts of the first and last element. +In this case, `{id: 10}` will be remembered as `lowest` and `{id: 8}` as `highest`. The client also has to remember the page and size which was used to request this data. +When the client then wants to switch to the next page, it has to pass `lowest` and `highest` as parameters as well as `prevPage` representing the page that was used before. + +Note that the following is just an example for illustration. Stringified JSON objects in JavaScript should be encoded view `encodeURI()` before being used as query parameter. + +[source] +---- +GET /cats?page=1&size=3&sort=id,desc&prevPage=0&lowest={id:10}&highest={id:8} +{ + content: [ + { id: 7, name: 'Kitty', age: 1 }, + { id: 6, name: 'Bob', age: 8 }, + { id: 5, name: 'Frank', age: 14 } + ] +} +---- + +This will make use of keyset pagination as can be seen by looking at the generated JPQL or SQL query. + +Note that the client should _drop_ or _forget_ the `lowest`, `highest` and `prevPage` values when + +* the page size changes +* the sorting changes +* the filtering changes + +For a full AngularJS example see the following https://github.com/Blazebit/blaze-persistence/blob/master/examples/spring-data-rest/src/main/resources/static/app.js[example project]. \ No newline at end of file diff --git a/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/proxy/ProxyFactory.java b/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/proxy/ProxyFactory.java index 3e06c5a0c8..aa0fbd47cd 100644 --- a/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/proxy/ProxyFactory.java +++ b/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/proxy/ProxyFactory.java @@ -81,6 +81,7 @@ import javax.persistence.metamodel.EntityType; import javax.persistence.metamodel.IdentifiableType; +import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; @@ -460,34 +461,7 @@ private Class createProxyClass(EntityViewManager entityViewMana createInheritanceConstructors(entityViewManager, constructors, inheritanceBase, managedViewType, subtypeIndex, addedReferenceConstructor, unsafe, cc, initialStateField, mutableStateField, fieldMap, mutableAttributes, mutableAttributeCount); } - try { - Class c; - if (unsafe) { - c = (Class) UnsafeHelper.define(cc.getName(), cc.toBytecode(), clazz); - } else { - c = cc.toClass(clazz.getClassLoader(), null); - } - - c.getField("$$_evm").set(null, entityViewManager); - - return c; - } catch (CannotCompileException | LinkageError ex) { - // If there are multiple proxy factories for the same class loader - // we could end up in defining a class multiple times, so we check if the classloader - // actually has something to offer - LinkageError error; - if (ex instanceof LinkageError && (error = (LinkageError) ex) != null - || ex.getCause() instanceof LinkageError && (error = (LinkageError) ex.getCause()) != null) { - try { - return (Class) pool.getClassLoader().loadClass(proxyClassName); - } catch (ClassNotFoundException cnfe) { - // Something we can't handle happened - throw error; - } - } else { - throw ex; - } - } + return defineOrGetClass(entityViewManager, unsafe, clazz, proxyClassName, cc); } catch (Exception ex) { throw new RuntimeException("Probably we did something wrong, please contact us if you see this message.", ex); } finally { @@ -495,6 +469,46 @@ private Class createProxyClass(EntityViewManager entityViewMana } } + private Class defineOrGetClass(EntityViewManager entityViewManager, boolean unsafe, Class clazz, String proxyClassName, CtClass cc) throws IOException, IllegalAccessException, NoSuchFieldException, CannotCompileException { + try { + Class c; + if (unsafe) { + c = (Class) UnsafeHelper.define(cc.getName(), cc.toBytecode(), clazz); + } else { + c = cc.toClass(clazz.getClassLoader(), null); + } + + c.getField("$$_evm").set(null, entityViewManager); + + return c; + } catch (CannotCompileException | LinkageError ex) { + // If there are multiple proxy factories for the same class loader + // we could end up in defining a class multiple times, so we check if the classloader + // actually has something to offer + LinkageError error; + if (ex instanceof LinkageError && (error = (LinkageError) ex) != null + || ex.getCause() instanceof LinkageError && (error = (LinkageError) ex.getCause()) != null) { + try { + return (Class) pool.getClassLoader().loadClass(proxyClassName); + } catch (ClassNotFoundException cnfe) { + // Something we can't handle happened + throw error; + } + } else { + throw ex; + } + } catch (NullPointerException ex) { + // With Java 9 it's actually the case that Javassist doesn't throw the LinkageError but instead tries to define the class differently + // Too bad that this different path lead to a NullPointerException + try { + return (Class) pool.getClassLoader().loadClass(proxyClassName); + } catch (ClassNotFoundException cnfe) { + // Something we can't handle happened + throw ex; + } + } + } + private boolean shouldAddDefaultConstructor(boolean hasEmptyConstructor, boolean addedReferenceConstructor, CtField[] attributeFields) { // Add the default constructor only for interfaces since abstract classes may omit it // Only add the "normal" constructor if there are attributes other than the id attribute available, otherwise we get a duplicate member exception diff --git a/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/update/flush/SubviewAttributeFlusher.java b/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/update/flush/SubviewAttributeFlusher.java index 8bd4593683..9ff67e063e 100644 --- a/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/update/flush/SubviewAttributeFlusher.java +++ b/entity-view/impl/src/main/java/com/blazebit/persistence/view/impl/update/flush/SubviewAttributeFlusher.java @@ -422,9 +422,11 @@ public DirtyKind getDirtyKind(V initial, V current) { return DirtyKind.UPDATED; } - EntityViewUpdater updater = viewToEntityMapper.getUpdater(current); - if (updater != null) { - return updater.getDirtyChecker().getDirtyKind((DirtyStateTrackable) initial, (DirtyStateTrackable) current); + if (initial instanceof DirtyStateTrackable && current instanceof DirtyStateTrackable) { + EntityViewUpdater updater = viewToEntityMapper.getUpdater(current); + if (updater != null) { + return updater.getDirtyChecker().getDirtyKind((DirtyStateTrackable) initial, (DirtyStateTrackable) current); + } } return Objects.equals(initial, current) ? DirtyKind.NONE : DirtyKind.UPDATED; diff --git a/entity-view/testsuite/pom.xml b/entity-view/testsuite/pom.xml index 723824afa8..ab614cabae 100644 --- a/entity-view/testsuite/pom.xml +++ b/entity-view/testsuite/pom.xml @@ -91,6 +91,28 @@ mockito-all 1.10.19 + + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.annotation + javax.annotation-api + ${version.annotation} + @@ -445,6 +467,31 @@ hibernate-jpamodelgen 1.3.0.Final + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -525,6 +572,31 @@ hibernate-jpamodelgen ${version.hibernate-4.3} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -605,6 +677,31 @@ hibernate-jpamodelgen ${version.hibernate-5} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -685,6 +782,31 @@ hibernate-jpamodelgen ${version.hibernate-5.1} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -768,6 +890,136 @@ hibernate-jpamodelgen ${version.hibernate-5.2} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-test-source-metamodel + generate-test-sources + + add-test-source + + + + ${project.build.directory}/test-metamodel + + + + + + + + + + hibernate-5.3 + + com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate52 + + + + org.hibernate + hibernate-entitymanager + ${version.hibernate-5.3} + + + ${project.groupId} + blaze-persistence-integration-hibernate-5.3 + test + + + ${project.groupId} + blaze-persistence-testsuite-base-hibernate + test + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5.3} + provided + + + + + + org.bsc.maven + maven-processor-plugin + + + process-test + + process + + generate-test-sources + + + ${project.build.directory}/test-metamodel + + org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor + + + + + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5.3} + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -855,6 +1107,31 @@ hibernate-jpamodelgen ${version.hibernate-6.0} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -940,11 +1217,30 @@ org.eclipse.persistence.jpa.modelgen.processor ${version.eclipselink} - + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + javax.transaction javax.transaction-api - 1.2 + ${version.jta} + + + javax.activation + activation + ${version.activation} @@ -1012,6 +1308,10 @@ blaze-persistence-testsuite-base-datanucleus test + + ${project.groupId} + blaze-persistence-integration-datanucleus + @@ -1050,6 +1350,10 @@ blaze-persistence-testsuite-base-datanucleus ${project.version} + + ${project.groupId} + blaze-persistence-integration-datanucleus + @@ -1078,6 +1382,31 @@ datanucleus-jpa-query ${version.datanucleus.jpa-5} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -1144,6 +1473,10 @@ blaze-persistence-testsuite-base-datanucleus test + + ${project.groupId} + blaze-persistence-integration-datanucleus + @@ -1174,6 +1507,10 @@ blaze-persistence-testsuite-base-datanucleus ${project.version} + + ${project.groupId} + blaze-persistence-integration-datanucleus + @@ -1195,6 +1532,33 @@ + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + org.codehaus.mojo @@ -1217,6 +1581,160 @@ + + datanucleus-5.1 + + com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus + datanucleus + + + + DataNucleus Nightly + DataNucleus Repository Nightly + http://www.datanucleus.org/downloads/maven2-nightly + + + + + org.datanucleus + javax.persistence + 2.2.0-release + + + org.datanucleus + datanucleus-core + ${version.datanucleus.base-5.1} + + + org.datanucleus + datanucleus-api-jpa + ${version.datanucleus.api-jpa-5.1} + + + org.datanucleus + datanucleus-jpa-query + ${version.datanucleus.jpa-5.1} + + + org.datanucleus + datanucleus-rdbms + ${version.datanucleus.rdbms-5.1} + + + ${project.groupId} + blaze-persistence-testsuite-base-datanucleus + compile + + + ${project.groupId} + blaze-persistence-integration-datanucleus-5.1 + + + + + + org.datanucleus + datanucleus-maven-plugin + 4.0.0-release + + JPA + TestsuiteBase + false + true + ${basedir}/log4j.properties + ${project.build.outputDirectory} + true + + + + process-classes + + enhance + + + + + + ${project.groupId} + blaze-persistence-testsuite-base-datanucleus + ${project.version} + + + ${project.groupId} + blaze-persistence-integration-datanucleus-5.1 + ${project.version} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${additional.source.directory} + ${project.build.directory}/generated-sources/metamodel + + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/generated-sources/metamodel + + org.datanucleus.jpa.query.JPACriteriaProcessor + + + + + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + + openjpa @@ -1264,6 +1782,31 @@ openjpa-all ${version.openjpa} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + diff --git a/examples/showcase/runner/cdi/pom.xml b/examples/showcase/runner/cdi/pom.xml index a955e14500..87d1018448 100644 --- a/examples/showcase/runner/cdi/pom.xml +++ b/examples/showcase/runner/cdi/pom.xml @@ -161,9 +161,62 @@ junit junit + + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.annotation + javax.annotation-api + ${version.annotation} + + + deltaspike-1.7 + + true + + + + + org.apache.deltaspike.distribution + distributions-bom + ${version.deltaspike-1.7} + pom + import + + + + + + deltaspike-1.8 + + + + org.apache.deltaspike.distribution + distributions-bom + ${version.deltaspike-1.8} + pom + import + + + + showcase-basic @@ -186,6 +239,48 @@ + + datanucleus-4 + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + + + datanucleus-5 + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + + + datanucleus-5.1 + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + eclipselink diff --git a/examples/showcase/runner/spring/pom.xml b/examples/showcase/runner/spring/pom.xml index a244fe1847..091c3d60da 100644 --- a/examples/showcase/runner/spring/pom.xml +++ b/examples/showcase/runner/spring/pom.xml @@ -147,6 +147,28 @@ junit junit + + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.annotation + javax.annotation-api + ${version.annotation} + @@ -181,7 +203,50 @@ + + + datanucleus-4 + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + + + datanucleus-5 + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + + + datanucleus-5.1 + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + eclipselink diff --git a/examples/spring-data-rest/pom.xml b/examples/spring-data-rest/pom.xml index 53915c4823..62a0bb7800 100644 --- a/examples/spring-data-rest/pom.xml +++ b/examples/spring-data-rest/pom.xml @@ -133,6 +133,28 @@ spring-test test + + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.annotation + javax.annotation-api + ${version.annotation} + @@ -180,7 +202,7 @@ spring-data-2.0.x 5.0.4.RELEASE - 2.0.0.RC2 + 2.0.0.RELEASE diff --git a/integration/datanucleus-5.1/pom.xml b/integration/datanucleus-5.1/pom.xml new file mode 100644 index 0000000000..17af2bad2f --- /dev/null +++ b/integration/datanucleus-5.1/pom.xml @@ -0,0 +1,164 @@ + + + + + 4.0.0 + + + com.blazebit + blaze-persistence-integration + 1.2.0-SNAPSHOT + ../pom.xml + + + blaze-persistence-integration-datanucleus-5.1 + jar + + Blazebit Persistence Integration DataNucleus 5.1 + + + com.blazebit.persistence.integration.datanucleus + + + + + DataNucleus Nightly + DataNucleus Repository Nightly + http://www.datanucleus.org/downloads/maven2-nightly + + + + + + ${project.groupId} + blaze-persistence-core-api + + + + ${project.groupId} + blaze-apt-utils + provided + + + ${project.groupId} + blaze-common-utils + + + + ${project.groupId} + blaze-persistence-integration-jpa-base + + + + org.datanucleus + javax.persistence + 2.2.0-release + provided + + + org.datanucleus + datanucleus-core + ${version.datanucleus.base-5.1} + provided + + + org.datanucleus + datanucleus-api-jpa + ${version.datanucleus.api-jpa-5.1} + provided + + + org.datanucleus + datanucleus-jpa-query + ${version.datanucleus.jpa-5.1} + provided + + + org.datanucleus + datanucleus-rdbms + ${version.datanucleus.rdbms-5.1} + provided + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-resource + generate-resources + + add-resource + + + + + target/generated/resources + + + + + + + + org.bsc.maven + maven-processor-plugin + + + process-resources + + process + + generate-resources + + target/generated/resources + + + com.blazebit.apt.service.ServiceProviderAnnotationProcessor + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + + ${module.name} + 2 + blaze-persistence-integration-datanucleus + com.blazebit.blaze-persistence-integration-datanucleus + ${project.version} + Blazebit + org.datanucleus,org.datanucleus.api.jpa + + + + + + + diff --git a/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/CTEAnnotationReader.java b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/CTEAnnotationReader.java new file mode 100644 index 0000000000..a1dd90e3a0 --- /dev/null +++ b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/CTEAnnotationReader.java @@ -0,0 +1,77 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.datanucleus; + +import com.blazebit.persistence.CTE; +import com.blazebit.persistence.integration.datanucleus.function.DataNucleus51EntityManagerFactoryIntegrator; +import org.datanucleus.ClassLoaderResolver; +import org.datanucleus.api.jpa.metadata.JPAAnnotationReader; +import org.datanucleus.metadata.AbstractClassMetaData; +import org.datanucleus.metadata.AbstractMemberMetaData; +import org.datanucleus.metadata.IdentityType; +import org.datanucleus.metadata.MetaDataManager; +import org.datanucleus.metadata.PackageMetaData; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +public class CTEAnnotationReader extends JPAAnnotationReader { + + private final boolean isDataNucleus4; + + public CTEAnnotationReader(MetaDataManager mgr) { + super(mgr); + String[] supportedAnnotationPacakges = new String[supportedPackages.length + 1]; + System.arraycopy(supportedPackages, 0, supportedAnnotationPacakges, 0, supportedPackages.length); + supportedAnnotationPacakges[supportedAnnotationPacakges.length - 1] = "com.blazebit.persistence"; + setSupportedAnnotationPackages(supportedAnnotationPacakges); + isDataNucleus4 = DataNucleus51EntityManagerFactoryIntegrator.MAJOR < 5; + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public AbstractClassMetaData getMetaDataForClass(Class cls, PackageMetaData pmd, ClassLoaderResolver clr) { + AbstractClassMetaData cmd = super.getMetaDataForClass(cls, pmd, clr); + + if (cmd == null) { + return null; + } + + if (!cls.isAnnotationPresent(CTE.class)) { + return cmd; + } + + // TODO: check that no collections are mapped + if (isDataNucleus4) { + cmd.setIdentityType(IdentityType.NONDURABLE); + cmd.addExtension("view-definition", "--"); + + for (int i = 0; i < cmd.getNoOfMembers(); i++) { + AbstractMemberMetaData mmd = cmd.getMetaDataForMemberAtRelativePosition(i); + if (mmd.isPrimaryKey()) { + mmd.setPrimaryKey(false); + } + } + } else { + cmd.setIdentityType(IdentityType.APPLICATION); + cmd.addExtension("view-definition", "--"); + } + return cmd; + } + +} diff --git a/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/DataNucleus51ExtendedQuerySupport.java b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/DataNucleus51ExtendedQuerySupport.java new file mode 100644 index 0000000000..9eb0db9567 --- /dev/null +++ b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/DataNucleus51ExtendedQuerySupport.java @@ -0,0 +1,121 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.datanucleus; + +import com.blazebit.apt.service.ServiceProvider; +import com.blazebit.persistence.ReturningResult; +import com.blazebit.persistence.spi.ExtendedQuerySupport; +import org.datanucleus.store.rdbms.query.JPQLQuery; +import org.datanucleus.store.rdbms.query.RDBMSQueryCompilation; + +import javax.persistence.EntityManager; +import javax.persistence.Query; +import java.lang.reflect.Field; +import java.util.List; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +@ServiceProvider(ExtendedQuerySupport.class) +public class DataNucleus51ExtendedQuerySupport implements ExtendedQuerySupport { + + private static final Field DATASTORE_COMPILATION_FIELD; + + static { + try { + DATASTORE_COMPILATION_FIELD = JPQLQuery.class.getDeclaredField("datastoreCompilation"); + DATASTORE_COMPILATION_FIELD.setAccessible(true); + } catch (Exception e) { + throw new RuntimeException("Unsupported datanucleus version!", e); + } + } + + @Override + public boolean supportsAdvancedSql() { + return false; + } + + @Override + public String getSql(EntityManager em, Query query) { + org.datanucleus.store.query.Query dnQuery = query.unwrap(org.datanucleus.store.query.Query.class); + dnQuery.compile(); + return (String) dnQuery.getNativeQuery(); + } + + public List getCascadingDeleteSql(EntityManager em, Query query) { + // TODO: implement + throw new UnsupportedOperationException("Not yet implemeneted!"); + } + + @Override + public int getSqlSelectAliasPosition(EntityManager em, Query query, String alias) { + // TODO: implement + throw new UnsupportedOperationException("Not yet implemeneted!"); + } + + @Override + public String getSqlAlias(EntityManager em, Query query, String alias) { + // TODO: implement + throw new UnsupportedOperationException("Not yet implemeneted!"); + } + + @Override + public int getSqlSelectAttributePosition(EntityManager em, Query query, String alias) { + // TODO: implement + throw new UnsupportedOperationException("Not yet implemeneted!"); + } + + @Override + @SuppressWarnings("rawtypes") + public List getResultList(com.blazebit.persistence.spi.ServiceProvider serviceProvider, List participatingQueries, Query query, String sqlOverride) { + applySql(query, sqlOverride); + return query.getResultList(); + } + + @Override + public Object getSingleResult(com.blazebit.persistence.spi.ServiceProvider serviceProvider, List participatingQueries, Query query, String sqlOverride) { + applySql(query, sqlOverride); + return query.getSingleResult(); + } + + @Override + public int executeUpdate(com.blazebit.persistence.spi.ServiceProvider serviceProvider, List participatingQueries, Query query, String sqlOverride) { + applySql(query, sqlOverride); + return query.executeUpdate(); + } + + @Override + public ReturningResult executeReturning(com.blazebit.persistence.spi.ServiceProvider serviceProvider, List participatingQueries, Query exampleQuery, String sqlOverride) { + // TODO: implement + throw new UnsupportedOperationException("Not yet implemeneted!"); + } + + private void applySql(Query query, String sqlOverride) { + // TODO: parameter handling + org.datanucleus.store.query.Query dnQuery = query.unwrap(org.datanucleus.store.query.Query.class); + // Disable caching for these queries + dnQuery.addExtension("datanucleus.query.compilation.cached", Boolean.FALSE); + try { + RDBMSQueryCompilation datastoreCompilation = (RDBMSQueryCompilation) DATASTORE_COMPILATION_FIELD.get(dnQuery); + datastoreCompilation.setSQL(sqlOverride); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/DataNucleus51JpaProvider.java b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/DataNucleus51JpaProvider.java new file mode 100644 index 0000000000..6d4d9f0ed8 --- /dev/null +++ b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/DataNucleus51JpaProvider.java @@ -0,0 +1,410 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.datanucleus; + +import com.blazebit.persistence.JoinType; +import com.blazebit.persistence.spi.JoinTable; +import com.blazebit.persistence.spi.JpaProvider; +import org.datanucleus.ExecutionContext; +import org.datanucleus.api.jpa.metamodel.AttributeImpl; +import org.datanucleus.api.jpa.metamodel.ManagedTypeImpl; +import org.datanucleus.metadata.AbstractMemberMetaData; +import org.datanucleus.metadata.ColumnMetaData; +import org.datanucleus.metadata.EmbeddedMetaData; +import org.datanucleus.metadata.KeyMetaData; + +import javax.persistence.EntityManager; +import javax.persistence.Query; +import javax.persistence.metamodel.EntityType; +import javax.persistence.metamodel.ManagedType; +import javax.persistence.metamodel.PluralAttribute; +import javax.persistence.metamodel.SingularAttribute; +import javax.persistence.metamodel.Type; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + * + * @author Christian Beikov + * @since 1.0.0 + */ +public class DataNucleus51JpaProvider implements JpaProvider { + + private static final String[] EMPTY = {}; + private final int major; + private final int minor; + private final int fix; + + public DataNucleus51JpaProvider(int major, int minor, int fix) { + this.major = major; + this.minor = minor; + this.fix = fix; + } + + @Override + public boolean supportsJpa21() { + return true; + } + + @Override + public boolean supportsEntityJoin() { + return major >= 5; + } + + @Override + public boolean supportsInsertStatement() { + return false; + } + + @Override + public boolean needsBracketsForListParamter() { + return true; + } + + @Override + public boolean needsJoinSubqueryRewrite() { + return false; + } + + @Override + public String getBooleanExpression(boolean value) { + return value ? "TRUE" : "FALSE"; + } + + @Override + public String getBooleanConditionalExpression(boolean value) { + return value ? "TRUE" : "FALSE"; + } + + @Override + public String getNullExpression() { + return "NULL"; + } + + @Override + public String escapeCharacter(char character) { + return Character.toString(character); + } + + @Override + public boolean supportsNullPrecedenceExpression() { + return true; + } + + @Override + public void renderNullPrecedence(StringBuilder sb, String expression, String resolvedExpression, String order, String nulls) { + sb.append(expression); + if (order != null) { + sb.append(' ').append(order); + + if (nulls != null) { + sb.append(" NULLS ").append(nulls); + } + } + } + + @Override + public String getOnClause() { + return "ON"; + } + + @Override + public String getCollectionValueFunction() { + return "VALUE"; + } + + @Override + public boolean supportsCollectionValueDereference() { + return true; + } + + @Override + public Class getDefaultQueryResultType() { + return null; + } + + @Override + public String getCustomFunctionInvocation(String functionName, int argumentCount) { + // Careful, PaginatedCriteriaBuilder has some dependency on the "length" of the string for rendering in the count query + return functionName + "("; + } + + @Override + public boolean supportsRootTreat() { + // Although it might parse, it isn't really supported for JOINED inheritance as wrong SQL is generated + // TODO: create an issue for this + return true; + } + + @Override + public boolean supportsTreatJoin() { + return major >= 5; + } + + @Override + public boolean supportsTreatCorrelation() { + return false; + } + + @Override + public boolean supportsRootTreatJoin() { + return false; + } + + @Override + public boolean supportsRootTreatTreatJoin() { + return false; + } + + @Override + public boolean supportsSubtypePropertyResolving() { + return false; + } + + @Override + public boolean supportsSubtypeRelationResolving() { + // Interestingly, joining a relation that is only available on a subtype works + return true; + } + + @Override + public boolean supportsCountStar() { + return false; + } + + @Override + public boolean isForeignJoinColumn(EntityType ownerType, String attributeName) { + ManagedTypeImpl managedType = (ManagedTypeImpl) ownerType; + String[] parts = attributeName.split("\\."); + AbstractMemberMetaData metaData = managedType.getMetadata().getMetaDataForMember(parts[0]); + for (int i = 1; i < parts.length; i++) { + EmbeddedMetaData embeddedMetaData = metaData.getEmbeddedMetaData(); + if (embeddedMetaData == null) { + // Probably trying to access the id attribute of a ToMany relation + return metaData.getJoinMetaData() != null; + } else { + AbstractMemberMetaData[] metaDatas = embeddedMetaData.getMemberMetaData(); + metaData = null; + for (int j = 0; j < metaDatas.length; j++) { + if (parts[i].equals(metaDatas[j].getName())) { + metaData = metaDatas[j]; + break; + } + } + + if (metaData == null) { + throw new IllegalArgumentException("Could not find property '" + parts[i] + "' in embeddable type: " + ((AbstractMemberMetaData) embeddedMetaData.getParent()).getType().getName()); + } + } + } + + return metaData.getJoinMetaData() != null; + } + + @Override + public boolean isColumnShared(EntityType ownerType, String attributeName) { + return false; + } + + @Override + public ConstraintType requiresTreatFilter(EntityType ownerType, String attributeName, JoinType joinType) { + return ConstraintType.NONE; + } + + @Override + public String getMappedBy(EntityType ownerType, String attributeName) { + AbstractMemberMetaData metaData = getAttribute(ownerType, attributeName).getMetadata(); + return metaData.getMappedBy(); + } + + @Override + public Map getWritableMappedByMappings(EntityType inverseType, EntityType ownerType, String attributeName) { + return null; + } + + @Override + public String[] getColumnNames(EntityType ownerType, String attributeName) { + return EMPTY; + } + + @Override + public String[] getColumnTypes(EntityType ownerType, String attributeName) { + return EMPTY; + } + + private AttributeImpl getAttribute(ManagedType ownerType, String attributeName) { + if (attributeName.indexOf('.') == -1) { + return (AttributeImpl) ownerType.getAttribute(attributeName); + } + ManagedType t = ownerType; + SingularAttribute attr = null; + String[] parts = attributeName.split("\\."); + for (int i = 0; i < parts.length; i++) { + attr = t.getSingularAttribute(parts[i]); + if (attr.getType().getPersistenceType() != Type.PersistenceType.BASIC) { + t = (ManagedType) attr.getType(); + } else if (i + 1 != parts.length) { + throw new IllegalArgumentException("Illegal attribute name for type [" + ownerType.getJavaType().getName() + "]: " + attributeName); + } + } + + return (AttributeImpl) attr; + } + + @Override + public JoinTable getJoinTable(EntityType ownerType, String attributeName) { + AttributeImpl attribute = getAttribute(ownerType, attributeName); + AbstractMemberMetaData metaData = attribute.getMetadata(); + if (metaData.getJoinMetaData() != null) { + Map keyMapping = null; + KeyMetaData keyMetaData = metaData.getKeyMetaData(); + if (keyMetaData != null && keyMetaData.getColumnMetaData() != null) { + keyMapping = new HashMap<>(); + ColumnMetaData[] keyColumnMetaData = keyMetaData.getColumnMetaData(); + ColumnMetaData[] keyTargetPrimaryKeyColumnMetaData = keyMetaData.getForeignKeyMetaData() == null ? null : keyMetaData.getForeignKeyMetaData().getColumnMetaData(); + if (keyTargetPrimaryKeyColumnMetaData == null) { + keyMapping.put(keyMetaData.getColumnName(), keyMetaData.getColumnName()); + } else { + for (int i = 0; i < keyTargetPrimaryKeyColumnMetaData.length; i++) { + keyMapping.put(keyColumnMetaData[i].getName(), keyTargetPrimaryKeyColumnMetaData[i].getName()); + } + } + } else if (metaData.getOrderMetaData() != null) { + String columnName = metaData.getOrderMetaData().getColumnName(); + keyMapping = Collections.singletonMap(columnName, columnName); + } + + String tableName; + Map idColumnMapping; + Map targetIdColumnMapping; + if (metaData.getJoinMetaData().getTable() == null) { + tableName = metaData.getTable(); + idColumnMapping = Collections.emptyMap(); + targetIdColumnMapping = Collections.emptyMap(); + } else { + tableName = metaData.getJoinMetaData().getTable(); + ColumnMetaData[] primaryKeyColumnMetaData = metaData.getJoinMetaData().getPrimaryKeyMetaData().getColumnMetaData(); + ColumnMetaData[] foreignKeyColumnMetaData = metaData.getJoinMetaData().getForeignKeyMetaData().getColumnMetaData(); + idColumnMapping = new HashMap<>(primaryKeyColumnMetaData.length); + for (int i = 0; i < foreignKeyColumnMetaData.length; i++) { + idColumnMapping.put(foreignKeyColumnMetaData[i].getName(), primaryKeyColumnMetaData[i].getName()); + } + + ColumnMetaData[] targetColumnMetaData = metaData.getJoinMetaData().getColumnMetaData(); + ColumnMetaData[] targetPrimaryKeyColumnMetaData = metaData.getElementMetaData().getForeignKeyMetaData().getColumnMetaData(); + targetIdColumnMapping = new HashMap<>(targetPrimaryKeyColumnMetaData.length); + + for (int i = 0; i < targetColumnMetaData.length; i++) { + targetIdColumnMapping.put(targetColumnMetaData[i].getName(), targetPrimaryKeyColumnMetaData[i].getName()); + } + } + + return new JoinTable( + tableName, + idColumnMapping, + keyMapping, + targetIdColumnMapping + ); + } + + return null; + } + + @Override + public boolean isBag(EntityType ownerType, String attributeName) { + AttributeImpl attribute = getAttribute(ownerType, attributeName); + if (attribute instanceof PluralAttribute) { + PluralAttribute pluralAttr = (PluralAttribute) attribute; + if (pluralAttr.getCollectionType() == PluralAttribute.CollectionType.COLLECTION) { + return true; + } else if (pluralAttr.getCollectionType() == PluralAttribute.CollectionType.LIST) { + AbstractMemberMetaData metaData = attribute.getMetadata(); + return metaData.getOrderMetaData() == null; + } + } + return false; + } + + @Override + public boolean isOrphanRemoval(ManagedType ownerType, String attributeName) { + AttributeImpl attribute = getAttribute(ownerType, attributeName); + return attribute != null && attribute.getMetadata().isCascadeRemoveOrphans(); + } + + @Override + public boolean isDeleteCascaded(ManagedType ownerType, String attributeName) { + AttributeImpl attribute = getAttribute(ownerType, attributeName); + return attribute != null && attribute.getMetadata().isCascadeDelete(); + } + + @Override + public boolean containsEntity(EntityManager em, Class entityClass, Object id) { + ExecutionContext ec = em.unwrap(ExecutionContext.class); + return ec.getAttachedObjectForId(ec.newObjectId(entityClass, id)) != null; + } + + @Override + public boolean supportsSingleValuedAssociationIdExpressions() { + return false; + } + + @Override + public boolean supportsForeignAssociationInOnClause() { + return true; + } + + @Override + public boolean supportsUpdateSetEmbeddable() { + return true; + } + + @Override + public boolean supportsTransientEntityAsParameter() { + return false; + } + + @Override + public boolean needsAssociationToIdRewriteInOnClause() { + return false; + } + + @Override + public boolean needsBrokenAssociationToIdRewriteInOnClause() { + return false; + } + + @Override + public boolean needsTypeConstraintForColumnSharing() { + return false; + } + + @Override + public boolean supportsCollectionTableCleanupOnDelete() { + return false; + } + + @Override + public boolean supportsJoinTableCleanupOnDelete() { + return false; + } + + @Override + public void setCacheable(Query query) { + query.setHint("datanucleus.query.results.cached", true); + } +} diff --git a/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/AbstractJpqlFunctionSQLMethod.java b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/AbstractJpqlFunctionSQLMethod.java new file mode 100644 index 0000000000..58e1de62fc --- /dev/null +++ b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/AbstractJpqlFunctionSQLMethod.java @@ -0,0 +1,94 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.datanucleus.function; + +import com.blazebit.persistence.spi.FunctionRenderContext; +import com.blazebit.persistence.spi.JpqlFunction; +import org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping; +import org.datanucleus.store.rdbms.sql.SQLStatement; +import org.datanucleus.store.rdbms.sql.expression.BooleanExpression; +import org.datanucleus.store.rdbms.sql.expression.ByteExpression; +import org.datanucleus.store.rdbms.sql.expression.CharacterExpression; +import org.datanucleus.store.rdbms.sql.expression.NumericExpression; +import org.datanucleus.store.rdbms.sql.expression.SQLExpression; +import org.datanucleus.store.rdbms.sql.expression.StringExpression; +import org.datanucleus.store.rdbms.sql.expression.TemporalExpression; +import org.datanucleus.store.rdbms.sql.method.SQLMethod; + +import java.util.logging.Logger; + +/** + * + * @author Christian + * @since 1.2.0 + */ +public abstract class AbstractJpqlFunctionSQLMethod implements JpqlFunction { + + private static final Logger LOG = Logger.getLogger(JpqlFunctionSQLMethod.class.getName()); + protected final SQLStatement stmt; + protected final SQLMethod function; + + public AbstractJpqlFunctionSQLMethod(SQLStatement stmt, SQLMethod function) { + this.stmt = stmt; + this.function = function; + } + + @Override + public boolean hasArguments() { + // Not sure how to determine that + return true; + } + + @Override + public boolean hasParenthesesIfNoArguments() { + // Not sure how to determine that + return true; + } + + @Override + public Class getReturnType(Class firstArgumentType) { + if (firstArgumentType == null) { + return null; + } + SQLExpression expression; + JavaTypeMapping argumentTypeMapping = stmt.getSQLExpressionFactory().getMappingForType(firstArgumentType, true); + if (java.sql.Date.class.isAssignableFrom(firstArgumentType)) { + expression = new TemporalExpression(stmt, argumentTypeMapping, "", null); + } else if (Byte.class.isAssignableFrom(firstArgumentType)) { + expression = new ByteExpression(stmt, null, argumentTypeMapping); + } else if (Number.class.isAssignableFrom(firstArgumentType)) { + expression = new NumericExpression(stmt, argumentTypeMapping, ""); + } else if (String.class.isAssignableFrom(firstArgumentType)) { + expression = new StringExpression(stmt, null, argumentTypeMapping); + } else if (Character.class.isAssignableFrom(firstArgumentType)) { + expression = new CharacterExpression(stmt, null, argumentTypeMapping); + } else if (Boolean.class.isAssignableFrom(firstArgumentType)) { + expression = new BooleanExpression(stmt, argumentTypeMapping, ""); + } else { + throw new UnsupportedOperationException("Unsupported data type: " + firstArgumentType.getName()); + } + SQLExpression resultExpression = getExpression(stmt, expression); + return resultExpression.getJavaTypeMapping().getJavaType(); + } + + protected abstract SQLExpression getExpression(SQLStatement stmt, SQLExpression argumentExpression); + + @Override + public void render(FunctionRenderContext context) { + throw new UnsupportedOperationException("Rendering functions through this API is not possible!"); + } +} diff --git a/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/CustomSQLText.java b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/CustomSQLText.java new file mode 100644 index 0000000000..5b388c8d33 --- /dev/null +++ b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/CustomSQLText.java @@ -0,0 +1,51 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.datanucleus.function; + +import org.datanucleus.store.rdbms.sql.SQLText; +import org.datanucleus.store.rdbms.sql.expression.SQLExpression; + +import java.util.List; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +public class CustomSQLText extends SQLText { + + private final String sql; + + public CustomSQLText(String sql, SQLExpression expr, List expressions) { + this.sql = sql; + + if (expr != null) { + append(expr); + } + + for (SQLExpression expression : expressions) { + append(expression); + } + } + + @Override + public String toSQL() { + // Call super to trigger parameter handling + super.toSQL(); + return sql; + } + +} diff --git a/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/DataNucleus51EntityManagerFactoryIntegrator.java b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/DataNucleus51EntityManagerFactoryIntegrator.java new file mode 100644 index 0000000000..96789199ab --- /dev/null +++ b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/DataNucleus51EntityManagerFactoryIntegrator.java @@ -0,0 +1,333 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.datanucleus.function; + +import com.blazebit.apt.service.ServiceProvider; +import com.blazebit.persistence.integration.datanucleus.DataNucleus51JpaProvider; +import com.blazebit.persistence.integration.jpa.function.CountStarFunction; +import com.blazebit.persistence.spi.EntityManagerFactoryIntegrator; +import com.blazebit.persistence.spi.JpaProvider; +import com.blazebit.persistence.spi.JpaProviderFactory; +import com.blazebit.persistence.spi.JpqlFunction; +import com.blazebit.persistence.spi.JpqlFunctionGroup; +import org.datanucleus.NucleusContext; +import org.datanucleus.store.StoreManager; +import org.datanucleus.store.rdbms.RDBMSStoreManager; +import org.datanucleus.store.rdbms.identifier.DatastoreIdentifier; +import org.datanucleus.store.rdbms.query.QueryGenerator; +import org.datanucleus.store.rdbms.sql.SQLStatement; +import org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory; +import org.datanucleus.store.rdbms.sql.method.SQLMethod; +import org.datanucleus.store.rdbms.table.Table; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.logging.Logger; + +/** + * + * @author Christian Beikov + * @author Moritz Becker + * + * @since 1.2.0 + */ +@ServiceProvider(EntityManagerFactoryIntegrator.class) +public class DataNucleus51EntityManagerFactoryIntegrator implements EntityManagerFactoryIntegrator { + + public static final String VERSION; + public static final int MAJOR; + public static final int MINOR; + public static final int FIX; + + private static final Logger LOG = Logger.getLogger(DataNucleus51EntityManagerFactoryIntegrator.class.getName()); + private static final Map VENDOR_TO_DBMS_MAPPING = new HashMap(); + private static final String[] BUILTIN_FUNCTIONS = { + "abs", + "acos", + "asin", + "atan", + "avg", + "ceil", + "cos", + "count", + "exp", + "floor", + "log", + "max", + "min", + "power", + "sin", + "sqrt", + "sum", + "tan", + "degrees", + "radians", + "ABS", + "ACOS", + "ASIN", + "ATAN", + "AVG", + "CEIL", + "COS", + "COUNT", + "COUNTSTAR", + "EXP", + "FLOOR", + "LOG", + "MAX", + "MIN", + "POWER", + "SIN", + "SQRT", + "SUM", + "TAN", + "RADIANS", + "DEGREES", + "COALESCE", + "NULLIF", + "INDEX", + "CURRENT_DATE", + "CURRENT_TIME", + "CURRENT_TIMESTAMP", + "SQL_boolean", + "SQL_numeric", + "SQL_function", + "YEAR", + "MONTH", + "MONTH_JAVA", + "DAY", + "HOUR", + "MINUTE", + "SECOND" + }; + + static { + VENDOR_TO_DBMS_MAPPING.put("h2", "h2"); + VENDOR_TO_DBMS_MAPPING.put("mysql", "mysql"); + VENDOR_TO_DBMS_MAPPING.put("db2", "db2"); + VENDOR_TO_DBMS_MAPPING.put("firebird", "firebird"); + VENDOR_TO_DBMS_MAPPING.put("postgresql", "postgresql"); + VENDOR_TO_DBMS_MAPPING.put("oracle", "oracle"); + VENDOR_TO_DBMS_MAPPING.put("sqlite", "sqlite"); + VENDOR_TO_DBMS_MAPPING.put("sqlserver", "microsoft"); + VENDOR_TO_DBMS_MAPPING.put("sybase", "sybase"); +// VENDOR_TO_DBMS_MAPPING.put("", "cubrid"); + VENDOR_TO_DBMS_MAPPING.put("hsql", "hsql"); + VENDOR_TO_DBMS_MAPPING.put("informix", "informix"); +// VENDOR_TO_DBMS_MAPPING.put("", "ingres"); +// VENDOR_TO_DBMS_MAPPING.put("", "interbase"); + + VERSION = readMavenPropertiesVersion("META-INF/maven/org.datanucleus/datanucleus-core/pom.properties"); + + String[] versionParts = VERSION.split("[\\.-]"); + MAJOR = Integer.parseInt(versionParts[0]); + MINOR = Integer.parseInt(versionParts[1]); + FIX = Integer.parseInt(versionParts[2]); + } + + @Override + public String getDbms(EntityManagerFactory entityManagerFactory) { + RDBMSStoreManager storeMgr = (RDBMSStoreManager) entityManagerFactory.unwrap(StoreManager.class); + return VENDOR_TO_DBMS_MAPPING.get(storeMgr.getDatastoreAdapter().getVendorID()); + } + + @Override + public JpaProviderFactory getJpaProviderFactory(EntityManagerFactory entityManagerFactory) { + return new JpaProviderFactory() { + @Override + public JpaProvider createJpaProvider(EntityManager em) { + return new DataNucleus51JpaProvider(MAJOR, MINOR, FIX); + } + }; + } + + @SuppressWarnings("unchecked") + @Override + public EntityManagerFactory registerFunctions(EntityManagerFactory entityManagerFactory, Map dbmsFunctions) { + RDBMSStoreManager storeMgr = (RDBMSStoreManager) entityManagerFactory.unwrap(StoreManager.class); + SQLExpressionFactory exprFactory = storeMgr.getSQLExpressionFactory(); + String dbms = VENDOR_TO_DBMS_MAPPING.get(storeMgr.getDatastoreAdapter().getVendorID()); + + // Register compatibility functions + if (!exprFactory.isMethodRegistered(null, CountStarFunction.FUNCTION_NAME)) { + exprFactory.registerMethod(null, CountStarFunction.FUNCTION_NAME, new DataNucleusJpqlFunctionAdapter(new CountStarFunction(), true)); + } + + // construct map for checking existence of functions in a case-insensitive way + Map registeredFunctions = getRegisteredFunctions(entityManagerFactory); + Map caseInsensitiveRegisteredFunctions = new HashMap<>(registeredFunctions.size()); + for (String registeredFunctionName : registeredFunctions.keySet()) { + caseInsensitiveRegisteredFunctions.put(registeredFunctionName.toLowerCase(), registeredFunctionName); + } + + for (Map.Entry functionEntry : dbmsFunctions.entrySet()) { + String functionName = functionEntry.getKey(); + JpqlFunctionGroup dbmsFunctionGroup = functionEntry.getValue(); + JpqlFunction function = dbmsFunctionGroup.get(dbms); + + if (function == null && !dbmsFunctionGroup.contains(dbms)) { + function = dbmsFunctionGroup.get(null); + } + if (function == null) { + LOG.warning("Could not register the function '" + functionName + "' because there is neither an implementation for the dbms '" + dbms + "' nor a default implementation!"); + } else if (!caseInsensitiveRegisteredFunctions.containsKey(functionName.toLowerCase())) { + exprFactory.registerMethod(null, functionName, new DataNucleusJpqlFunctionAdapter(function, dbmsFunctionGroup.isAggregate())); + } + } + + return entityManagerFactory; + } + + @Override + public Map getRegisteredFunctions(EntityManagerFactory entityManagerFactory) { + NucleusContext context = entityManagerFactory.unwrap(NucleusContext.class); + RDBMSStoreManager storeMgr = (RDBMSStoreManager) entityManagerFactory.unwrap(StoreManager.class); + String storeName = storeMgr.getDatastoreAdapter().getVendorID(); + SQLExpressionFactory exprFactory = storeMgr.getSQLExpressionFactory(); + + Set methodKeys = fieldGet("pluginSqlMethodsKeysSupported", exprFactory); + Map functions = new HashMap<>(); + + // We need to construct a statement object and how this is done changed between 4 and 5 so we have to do a little reflection hack + // We need this because the function methods retrieve the expression factory through it + Class[] parameterTypes = {RDBMSStoreManager.class, Table.class, DatastoreIdentifier.class, String.class}; + SQLStatement stmt; + + try { + Constructor c = Class.forName("org.datanucleus.store.rdbms.sql.SelectStatement").getConstructor(parameterTypes); + stmt = (SQLStatement) c.newInstance(storeMgr, null, null, null); + } catch (Exception e) { + try { + Constructor c = Class.forName("org.datanucleus.store.rdbms.sql.SQLStatement").getConstructor(parameterTypes); + stmt = (SQLStatement) c.newInstance(storeMgr, null, null, null); + } catch (Exception e2) { + throw new RuntimeException("Could not access the required methods to dynamically retrieve registered functions. Please report this version of datanucleus(" + VERSION + ") so we can provide support for it!", e2); + } + } + + // Well apparently expressions get their class loader resolver by asking the statement they are part of + // which in turn asks the query generator that is responsible for it + // So this is the most non-hackish way to get this to work... + QueryGenerator noopGenerator = (QueryGenerator) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{ QueryGenerator.class }, new QueryGeneratorInvocationHandler(context)); + stmt.setQueryGenerator(noopGenerator); + + try { + Method getMethod = SQLExpressionFactory.class.getDeclaredMethod("getMethod", String.class, String.class, List.class); + getMethod.setAccessible(true); + + for (Object methodKey : methodKeys) { + String className = fieldGet("clsName", methodKey); + String datastoreName = fieldGet("datastoreName", methodKey); + String name = fieldGet("methodName", methodKey); + if (className.isEmpty() + && name.indexOf('.') == -1 + && ("ALL".equals(datastoreName) || storeName.equals(datastoreName))) { + // Only consider normal functions + SQLMethod method = (SQLMethod) getMethod.invoke(exprFactory, null, name, Collections.emptyList()); + if (method instanceof DataNucleusJpqlFunctionAdapter) { + functions.put(name, ((DataNucleusJpqlFunctionAdapter) method).unwrap()); + } else { + functions.put(name, new JpqlFunctionSQLMethod(stmt, method)); + } + } + } + + for (String name : BUILTIN_FUNCTIONS) { + SQLMethod method = (SQLMethod) getMethod.invoke(exprFactory, null, name, Collections.emptyList()); + if (method instanceof DataNucleusJpqlFunctionAdapter) { + functions.put(name, ((DataNucleusJpqlFunctionAdapter) method).unwrap()); + } else { + functions.put(name, new JpqlFunctionSQLMethod(stmt, method)); + } + } + + // The length function is the single exception to all functions that is based on a class + SQLMethod method = (SQLMethod) getMethod.invoke(exprFactory, "java.lang.String", "length", Collections.emptyList()); + functions.put("length", new JpqlFunctionInstanceSQLMethod(stmt, method)); + } catch (Exception ex) { + throw new RuntimeException("Could not access the required methods to dynamically retrieve registered functions. Please report this version of datanucleus(" + VERSION + ") so we can provide support for it!", ex); + } + + return functions; + } + + private static String readMavenPropertiesVersion(String name) { + InputStream is = null; + try { + is = NucleusContext.class.getClassLoader().getResourceAsStream(name); + Properties p = new Properties(); + p.load(is); + return p.getProperty("version"); + } catch (IOException e) { + throw new RuntimeException("Could not access the maven version properties of datanucleus!", e); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + // Ignore + } + } + } + } + + @SuppressWarnings("unchecked") + private static T fieldGet(String fieldName, Object value) { + Exception ex; + Field field = null; + boolean madeAccessible = false; + + try { + field = value.getClass().getDeclaredField(fieldName); + madeAccessible = !field.isAccessible(); + + if (madeAccessible) { + field.setAccessible(true); + } + + return (T) field.get(value); + } catch (NoSuchFieldException e) { + ex = e; + } catch (SecurityException e) { + ex = e; + } catch (IllegalArgumentException e) { + ex = e; + } catch (IllegalAccessException e) { + ex = e; + } finally { + if (madeAccessible) { + field.setAccessible(false); + } + } + + throw new RuntimeException("Could not access the required methods to dynamically retrieve registered functions. Please report this version of datanucleus(" + VERSION + ") so we can provide support for it!", ex); + } + +} diff --git a/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/DataNucleusFunctionRenderContext.java b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/DataNucleusFunctionRenderContext.java new file mode 100644 index 0000000000..e90ddc290a --- /dev/null +++ b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/DataNucleusFunctionRenderContext.java @@ -0,0 +1,66 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.datanucleus.function; + +import com.blazebit.persistence.spi.FunctionRenderContext; + +import java.util.List; + +/** + * + * @author Christian Beikov + * @since 1.0.0 + */ +public class DataNucleusFunctionRenderContext implements FunctionRenderContext { + + private final StringBuilder sb = new StringBuilder(); + private final List arguments; + + public DataNucleusFunctionRenderContext(List arguments) { + this.arguments = arguments; + } + + @Override + public int getArgumentsSize() { + return arguments.size(); + } + + @Override + public String getArgument(int index) { + return arguments.get(index).toString(); + } + + @Override + public void addArgument(int index) { + sb.append(arguments.get(index)); + } + + @Override + public void addChunk(String chunk) { + sb.append(chunk); + } + + public String renderToString() { + return sb.toString(); + } + + @Override + public String toString() { + return "HibernateFunctionRenderContext{" + "arguments=" + arguments + '}'; + } + +} diff --git a/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/DataNucleusJpqlFunctionAdapter.java b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/DataNucleusJpqlFunctionAdapter.java new file mode 100644 index 0000000000..3d14901a93 --- /dev/null +++ b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/DataNucleusJpqlFunctionAdapter.java @@ -0,0 +1,182 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.datanucleus.function; + +import com.blazebit.persistence.spi.JpqlFunction; +import org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping; +import org.datanucleus.store.rdbms.mapping.java.TemporalMapping; +import org.datanucleus.store.rdbms.sql.SQLStatement; +import org.datanucleus.store.rdbms.sql.SQLText; +import org.datanucleus.store.rdbms.sql.expression.AggregateNumericExpression; +import org.datanucleus.store.rdbms.sql.expression.AggregateStringExpression; +import org.datanucleus.store.rdbms.sql.expression.AggregateTemporalExpression; +import org.datanucleus.store.rdbms.sql.expression.BooleanExpression; +import org.datanucleus.store.rdbms.sql.expression.ByteExpression; +import org.datanucleus.store.rdbms.sql.expression.CharacterExpression; +import org.datanucleus.store.rdbms.sql.expression.NumericExpression; +import org.datanucleus.store.rdbms.sql.expression.SQLExpression; +import org.datanucleus.store.rdbms.sql.expression.StringExpression; +import org.datanucleus.store.rdbms.sql.expression.TemporalExpression; +import org.datanucleus.store.rdbms.sql.method.SQLMethod; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +public class DataNucleusJpqlFunctionAdapter implements SQLMethod { + + private static final Logger LOG = Logger.getLogger(DataNucleusJpqlFunctionAdapter.class.getName()); + private final JpqlFunction function; + private final boolean aggregate; + + public DataNucleusJpqlFunctionAdapter(JpqlFunction function, boolean aggregate) { + this.function = function; + this.aggregate = aggregate; + } + + public JpqlFunction unwrap() { + return function; + } + + @Override + public SQLExpression getExpression(SQLStatement stmt, SQLExpression expr, List args) { + // NOTE: expr will be the first argument for class methods like getMonth! + int argsSize = args.size(); + List newArgs = new ArrayList(argsSize + (expr == null ? 0 : 1)); + Class firstArgumentType = null; + JavaTypeMapping firstArgumentTypeMapping = null; + + if (expr != null) { + firstArgumentTypeMapping = expr.getJavaTypeMapping(); + firstArgumentType = firstArgumentTypeMapping.getJavaType(); + newArgs.add(expr.toSQLText().toSQL()); + for (int i = 0; i < argsSize; i++) { + newArgs.add(args.get(i).toSQLText().toSQL()); + } + } else if (argsSize > 0) { + firstArgumentTypeMapping = args.get(0).getJavaTypeMapping(); + firstArgumentType = firstArgumentTypeMapping.getJavaType(); + newArgs.add(args.get(0).toSQLText().toSQL()); + for (int i = 1; i < argsSize; i++) { + newArgs.add(args.get(i).toSQLText().toSQL()); + } + } + + Class returnType = function.getReturnType(firstArgumentType); + JavaTypeMapping returnTypeMapping; + + if (returnType == firstArgumentType) { + returnTypeMapping = firstArgumentTypeMapping; + } else { + returnTypeMapping = stmt.getSQLExpressionFactory().getMappingForType(returnType); + } + + if (returnTypeMapping == null) { + throw new IllegalArgumentException("Invalid return type null returned from function: " + function); + } + + final DataNucleusFunctionRenderContext context = new DataNucleusFunctionRenderContext(newArgs); + function.render(context); + + final SQLText sqlText = new CustomSQLText(context.renderToString(), expr, args); + + if (aggregate) { + if (returnTypeMapping instanceof TemporalMapping) { + return new AggregateTemporalExpression(stmt, returnTypeMapping, "", null) { + @Override + public SQLText toSQLText() { + return sqlText; + } + }; + } else if (Number.class.isAssignableFrom(returnTypeMapping.getJavaType())) { + return new AggregateNumericExpression(stmt, returnTypeMapping, "") { + @Override + public SQLText toSQLText() { + return sqlText; + } + }; + } else if (String.class.isAssignableFrom(returnTypeMapping.getJavaType())) { + return new AggregateStringExpression(stmt, returnTypeMapping, "", null) { + @Override + public SQLText toSQLText() { + return sqlText; + } + }; + } else { + LOG.warning("Aggregate type [" + returnType + "] could not be represented as aggregate. Please report this so we can support the type! Falling back to normal expression."); + } + } else { + if (returnTypeMapping instanceof TemporalMapping) { + return new TemporalExpression(stmt, returnTypeMapping, "", null) { + @Override + public SQLText toSQLText() { + return sqlText; + } + }; + } else if (Byte.class.isAssignableFrom(returnTypeMapping.getJavaType())) { + return new ByteExpression(stmt, null, returnTypeMapping) { + @Override + public SQLText toSQLText() { + return sqlText; + } + }; + } else if (Number.class.isAssignableFrom(returnTypeMapping.getJavaType())) { + return new NumericExpression(stmt, returnTypeMapping, "") { + @Override + public SQLText toSQLText() { + return sqlText; + } + }; + } else if (String.class.isAssignableFrom(returnTypeMapping.getJavaType())) { + return new StringExpression(stmt, null, returnTypeMapping) { + @Override + public SQLText toSQLText() { + return sqlText; + } + }; + } else if (Character.class.isAssignableFrom(returnTypeMapping.getJavaType())) { + return new CharacterExpression(stmt, null, returnTypeMapping) { + @Override + public SQLText toSQLText() { + return sqlText; + } + }; + } else if (Boolean.class.isAssignableFrom(returnTypeMapping.getJavaType())) { + return new BooleanExpression(stmt, returnTypeMapping, "") { + @Override + public SQLText toSQLText() { + return sqlText; + } + }; + } else { + LOG.warning("Type [" + returnType + "] could not be represented as aggregate. Please report this so we can support the type! Falling back to normal expression."); + } + } + + return new SQLExpression(stmt, null, returnTypeMapping) { + @Override + public SQLText toSQLText() { + return sqlText; + } + }; + } + +} diff --git a/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/JpqlFunctionInstanceSQLMethod.java b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/JpqlFunctionInstanceSQLMethod.java new file mode 100644 index 0000000000..876bf18738 --- /dev/null +++ b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/JpqlFunctionInstanceSQLMethod.java @@ -0,0 +1,40 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.datanucleus.function; + +import com.blazebit.persistence.spi.JpqlFunction; +import org.datanucleus.store.rdbms.sql.SQLStatement; +import org.datanucleus.store.rdbms.sql.expression.SQLExpression; +import org.datanucleus.store.rdbms.sql.method.SQLMethod; + +import java.util.Collections; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +public class JpqlFunctionInstanceSQLMethod extends AbstractJpqlFunctionSQLMethod implements JpqlFunction { + + public JpqlFunctionInstanceSQLMethod(SQLStatement stmt, SQLMethod function) { + super(stmt, function); + } + + @Override + protected SQLExpression getExpression(SQLStatement stmt, SQLExpression argumentExpression) { + return function.getExpression(stmt, argumentExpression, Collections.EMPTY_LIST); + } +} diff --git a/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/JpqlFunctionSQLMethod.java b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/JpqlFunctionSQLMethod.java new file mode 100644 index 0000000000..d16b90cc67 --- /dev/null +++ b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/JpqlFunctionSQLMethod.java @@ -0,0 +1,41 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.datanucleus.function; + +import com.blazebit.persistence.spi.JpqlFunction; +import org.datanucleus.store.rdbms.sql.SQLStatement; +import org.datanucleus.store.rdbms.sql.expression.SQLExpression; +import org.datanucleus.store.rdbms.sql.method.SQLMethod; + +import java.util.Arrays; + +/** + * + * @author Christian + * @since 1.2.0 + */ +public class JpqlFunctionSQLMethod extends AbstractJpqlFunctionSQLMethod implements JpqlFunction { + + public JpqlFunctionSQLMethod(SQLStatement stmt, SQLMethod function) { + super(stmt, function); + } + + @Override + protected SQLExpression getExpression(SQLStatement stmt, SQLExpression argumentExpression) { + return function.getExpression(stmt, null, Arrays.asList(argumentExpression)); + } +} diff --git a/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/QueryGeneratorInvocationHandler.java b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/QueryGeneratorInvocationHandler.java new file mode 100644 index 0000000000..aa55f0d318 --- /dev/null +++ b/integration/datanucleus-5.1/src/main/java/com/blazebit/persistence/integration/datanucleus/function/QueryGeneratorInvocationHandler.java @@ -0,0 +1,44 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.datanucleus.function; + +import org.datanucleus.NucleusContext; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; + +/** + * + * @author Christian + * @since 1.2.0 + */ +public class QueryGeneratorInvocationHandler implements InvocationHandler { + + private final NucleusContext context; + + public QueryGeneratorInvocationHandler(NucleusContext context) { + this.context = context; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + if ("getClassLoaderResolver".equals(method.getName())) { + return context.getClassLoaderResolver(null); + } + return null; + } +} diff --git a/integration/datanucleus-5.1/src/main/resources/META-INF/MANIFEST.MF b/integration/datanucleus-5.1/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..4b3b8d80bb --- /dev/null +++ b/integration/datanucleus-5.1/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: blaze-persistence-integration-datanucleus +Bundle-SymbolicName: com.blazebit.blaze-persistence-integration-datanucleus +Bundle-Version: 1.0.0 +Bundle-Vendor: Blazebit +Require-Bundle: org.datanucleus,org.datanucleus.api.jpa diff --git a/integration/datanucleus-5.1/src/main/resources/plugin.xml b/integration/datanucleus-5.1/src/main/resources/plugin.xml new file mode 100644 index 0000000000..c4b656b432 --- /dev/null +++ b/integration/datanucleus-5.1/src/main/resources/plugin.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/integration/deltaspike-data/api/pom.xml b/integration/deltaspike-data/api/pom.xml index 0843270016..27b562080c 100644 --- a/integration/deltaspike-data/api/pom.xml +++ b/integration/deltaspike-data/api/pom.xml @@ -16,6 +16,18 @@ com.blazebit.persistence.integration.deltaspike.data + + + + org.apache.deltaspike.distribution + distributions-bom + ${version.deltaspike-1.7} + pom + import + + + + javax diff --git a/integration/deltaspike-data/impl/pom.xml b/integration/deltaspike-data/impl/pom.xml index 6e40b41b39..e87b0338b9 100644 --- a/integration/deltaspike-data/impl/pom.xml +++ b/integration/deltaspike-data/impl/pom.xml @@ -16,6 +16,18 @@ com.blazebit.persistence.integration.deltaspike.data.impl + + + + org.apache.deltaspike.distribution + distributions-bom + ${version.deltaspike-1.7} + pom + import + + + + ${project.groupId} diff --git a/integration/deltaspike-data/testsuite/pom.xml b/integration/deltaspike-data/testsuite/pom.xml index 5f818e26be..9c3a430089 100644 --- a/integration/deltaspike-data/testsuite/pom.xml +++ b/integration/deltaspike-data/testsuite/pom.xml @@ -16,12 +16,6 @@ - - org.hibernate - hibernate-entitymanager - ${version.hibernate-5.2} - - ${project.groupId} blaze-persistence-integration-deltaspike-data-impl @@ -37,16 +31,6 @@ blaze-persistence-entity-view-impl test - - ${project.groupId} - blaze-persistence-integration-hibernate-5.2 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - test - org.apache.deltaspike.core deltaspike-core-impl @@ -82,74 +66,1874 @@ weld-se-core test - - com.h2database - h2 - test - junit junit test - + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.2} - provided + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.annotation + javax.annotation-api + ${version.annotation} - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources + + + + h2 + + true + + + + + org.apache.maven.plugins + maven-surefire-plugin + + com.blazebit.persistence.testsuite.base.jpa.category.NoH2,${jpa.excludedGroups} + + jdbc:h2:mem:test + admin + admin + org.h2.Driver + ${spring.activeProfiles} + + + + + org.apache.maven.surefire + surefire-junit47 + ${version.surefire.plugin} + + + + + + + + com.h2database + h2 + test + + + + + mysql + + + + org.apache.maven.plugins + maven-surefire-plugin + + com.blazebit.persistence.testsuite.base.jpa.category.NoMySQL,${jpa.excludedGroups} + + jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 + root + + com.mysql.jdbc.Driver + ${spring.activeProfiles} + + + + + org.apache.maven.surefire + surefire-junit47 + ${version.surefire.plugin} + + + + + + + + mysql + mysql-connector-java + test + + + + + postgresql + + + + org.apache.maven.plugins + maven-surefire-plugin + + com.blazebit.persistence.testsuite.base.jpa.category.NoPostgreSQL,${jpa.excludedGroups} + + jdbc:postgresql://localhost:5432/test + postgres + postgres + org.postgresql.Driver + ${spring.activeProfiles} + + + + + org.apache.maven.surefire + surefire-junit47 + ${version.surefire.plugin} + + + + + + + + org.postgresql + postgresql + test + + + + + sqlite + + + + org.apache.maven.plugins + maven-surefire-plugin + + com.blazebit.persistence.testsuite.base.jpa.category.NoSQLite,${jpa.excludedGroups} + + jdbc:sqlite:test.db + + + org.sqlite.JDBC + ${spring.activeProfiles} + + + + + org.apache.maven.surefire + surefire-junit47 + ${version.surefire.plugin} + + + + + + + + org.xerial + sqlite-jdbc + test + + + + + db2 + + + + + org.apache.maven.plugins + maven-surefire-plugin + + com.blazebit.persistence.testsuite.base.jpa.category.NoDB2,${jpa.excludedGroups} + + jdbc:db2://localhost:50000/test + db2inst1 + db2inst1-pwd + com.ibm.db2.jcc.DB2Driver + ${spring.activeProfiles} + + + + + org.apache.maven.surefire + surefire-junit47 + ${version.surefire.plugin} + + + + + + + + com.ibm.db2 + db2jcc4 + 9.7 + test + + + com.ibm.db2 + db2jcc_license_cu + 9.7 + test + + + + + firebird + + + + org.apache.maven.plugins + maven-surefire-plugin + + com.blazebit.persistence.testsuite.base.jpa.category.NoFirebird,${jpa.excludedGroups} + + jdbc:firebirdsql:localhost:/tmp/test.fdb + SYSDBA + masterkey + org.firebirdsql.jdbc.FBDriver + ${spring.activeProfiles} + + + + + org.apache.maven.surefire + surefire-junit47 + ${version.surefire.plugin} + + + + + + + + org.firebirdsql.jdbc + jaybird-jdk16 + test + + + + + oracle + + + + org.apache.maven.plugins + maven-surefire-plugin + + com.blazebit.persistence.testsuite.base.jpa.category.NoOracle,${jpa.excludedGroups} + + jdbc:oracle:thin:@localhost:1521/xe + travis + travis + oracle.jdbc.driver.OracleDriver + ${spring.activeProfiles} + + + + + org.apache.maven.surefire + surefire-junit47 + ${version.surefire.plugin} + + + + + + + + com.oracle + ojdbc14 + test + + + + + + + hibernate + + com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate42 + hibernate + + + + org.hibernate + hibernate-entitymanager + ${version.hibernate-4.2} + + + ${project.groupId} + blaze-persistence-integration-hibernate-4.2 + test + + + ${project.groupId} + blaze-persistence-testsuite-base-hibernate + compile + + + + org.hibernate + hibernate-jpamodelgen + 1.3.0.Final + provided + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/test-metamodel + + org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor + + + + + + + + org.hibernate + hibernate-jpamodelgen + 1.3.0.Final + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/test-metamodel + + + + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + + + + + + + + hibernate-4.3 + + com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate43 + hibernate + + + + org.hibernate + hibernate-entitymanager + ${version.hibernate-4.3} + + + ${project.groupId} + blaze-persistence-integration-hibernate-4.3 + test + + + ${project.groupId} + blaze-persistence-testsuite-base-hibernate + compile + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-4.3} + provided + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/test-metamodel + + org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor + + + + + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-4.3} + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/test-metamodel + + + + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + + + + + + + + hibernate-5.0 + + com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate50 + hibernate + + + + org.hibernate + hibernate-entitymanager + ${version.hibernate-5} + + + ${project.groupId} + blaze-persistence-integration-hibernate-5 + test + + + ${project.groupId} + blaze-persistence-testsuite-base-hibernate + compile + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5} + provided + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/test-metamodel + + org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor + + + + + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5} + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/test-metamodel + + + + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + + + + + + + + hibernate-5.1 + + com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate51 + hibernate + + + + org.hibernate + hibernate-entitymanager + ${version.hibernate-5.1} + + + ${project.groupId} + blaze-persistence-integration-hibernate-5 + test + + + ${project.groupId} + blaze-persistence-testsuite-base-hibernate + compile + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5.1} + provided + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/test-metamodel + + org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor + + + + + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5.1} + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/test-metamodel + + + + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + + + + + + + + hibernate-5.2 + + com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate52 + hibernate + + + true + + + + org.hibernate + hibernate-entitymanager + ${version.hibernate-5.2} + + + ${project.groupId} + blaze-persistence-integration-hibernate-5.2 + test + + + ${project.groupId} + blaze-persistence-testsuite-base-hibernate + compile + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5.2} + provided + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/test-metamodel + + org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor + + + + + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5.2} + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/test-metamodel + + + + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + + + + + + + + hibernate-5.3 + + com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate52 + hibernate + + + + org.hibernate + hibernate-entitymanager + ${version.hibernate-5.3} + + + ${project.groupId} + blaze-persistence-integration-hibernate-5.2 + test + + + ${project.groupId} + blaze-persistence-testsuite-base-hibernate + compile + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5.3} + provided + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/test-metamodel + + org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor + + + + + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5.3} + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/test-metamodel + + + + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + + + + + + + + hibernate-6.0 + + com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate + hibernate + + + + JBoss Snapshots + JBoss Snapshots + http://repository.jboss.org/nexus/content/groups/public/ + + + + + org.hibernate + hibernate-entitymanager + ${version.hibernate-6.0} + + + ${project.groupId} + blaze-persistence-integration-hibernate-6.0 + test + + + ${project.groupId} + blaze-persistence-testsuite-base-hibernate + compile + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-6.0} + provided + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/test-metamodel + + org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor + + + + + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-6.0} + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/test-metamodel + + + + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + + + + + + + + eclipselink + + com.blazebit.persistence.testsuite.base.jpa.category.NoEclipselink + eclipselink + -Xms1024m -Xmx2048m -javaagent:${project.build.directory}/agents/spring-instrumentation-agent.jar + + + + org.eclipse.persistence + eclipselink + ${version.eclipselink} + + + ${project.groupId} + blaze-persistence-testsuite-base-eclipselink + compile + + + + org.eclipse.persistence + org.eclipse.persistence.jpa.modelgen.processor + ${version.eclipselink} + provided + + + org.hibernate + hibernate-entitymanager + 3.6.10.Final + provided + + + jaxen + jaxen + 1.1.6 + provided + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/test-metamodel + + org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor + + + ${basedir}/src/main/resources/META-INF/persistence.xml + + + + + + + + org.eclipse.persistence + org.eclipse.persistence.jpa.modelgen.processor + ${version.eclipselink} + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/test-metamodel + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-agent + process-test-classes + + copy + + + + + org.springframework + spring-instrument + ${project.build.directory}/agents + spring-instrumentation-agent.jar + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + -javaagent:${project.build.directory}/agents/spring-instrumentation-agent.jar + + + + + + + datanucleus-4 + + com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus,com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus4 + datanucleus + + + + DataNucleus Nightly + DataNucleus Repository Nightly + http://www.datanucleus.org/downloads/maven2-nightly + + + + + org.datanucleus + javax.persistence + 2.1.2 + + + org.datanucleus + datanucleus-core + ${version.datanucleus.base-4} + + + org.datanucleus + datanucleus-api-jpa + ${version.datanucleus.api-jpa-4} + + + org.datanucleus + datanucleus-jpa-query + ${version.datanucleus.jpa-4} + + + org.datanucleus + datanucleus-rdbms + ${version.datanucleus.rdbms-4} + + + ${project.groupId} + blaze-persistence-testsuite-base-datanucleus + test + + + ${project.groupId} + blaze-persistence-integration-datanucleus + + + + + + org.datanucleus + datanucleus-maven-plugin + 4.0.0-release + + JPA + TEST-PU + false + true + ${basedir}/log4j.properties + ${project.build.testOutputDirectory} + true + + + + process-test-classes + + enhance + + + + + + ${project.groupId} + blaze-persistence-testsuite-base-datanucleus + ${project.version} + + + ${project.groupId} + blaze-persistence-integration-datanucleus + + + + + org.bsc.maven + maven-processor-plugin + + + process-test + + process-test + + generate-test-sources + + + ${project.build.directory}/test-metamodel + + org.datanucleus.jpa.query.JPACriteriaProcessor + + + + + + + + org.datanucleus + datanucleus-jpa-query + ${version.datanucleus.jpa-5} + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-test-source-metamodel + generate-test-sources + + add-test-source + + + + ${project.build.directory}/test-metamodel + + + + + + + + + + datanucleus-5 + + com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus + datanucleus + + + + DataNucleus Nightly + DataNucleus Repository Nightly + http://www.datanucleus.org/downloads/maven2-nightly + + + + + org.datanucleus + javax.persistence + 2.1.2 + + + org.datanucleus + datanucleus-core + ${version.datanucleus.base-5} + + + org.datanucleus + datanucleus-api-jpa + ${version.datanucleus.api-jpa-5} + + + org.datanucleus + datanucleus-jpa-query + ${version.datanucleus.jpa-5} + + + org.datanucleus + datanucleus-rdbms + ${version.datanucleus.rdbms-5} + + + ${project.groupId} + blaze-persistence-testsuite-base-datanucleus + test + + + ${project.groupId} + blaze-persistence-integration-datanucleus + + + + + + org.datanucleus + datanucleus-maven-plugin + 4.0.0-release - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - + JPA + TEST-PU + false + true + ${basedir}/log4j.properties + ${project.build.testOutputDirectory} + true - - + + + process-test-classes + + enhance + + + + + + ${project.groupId} + blaze-persistence-testsuite-base-datanucleus + ${project.version} + + + ${project.groupId} + blaze-persistence-integration-datanucleus + + + + + org.bsc.maven + maven-processor-plugin + + + process-test + + process-test + + generate-test-sources + + + ${project.build.directory}/test-metamodel + + org.datanucleus.jpa.query.JPACriteriaProcessor + + + + + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-test-source-metamodel + generate-test-sources + + add-test-source + + + + ${project.build.directory}/test-metamodel + + + + + + + + + + datanucleus-5.1 + + com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus + datanucleus + + + + DataNucleus Nightly + DataNucleus Repository Nightly + http://www.datanucleus.org/downloads/maven2-nightly + + + + + org.datanucleus + javax.persistence + 2.2.0-release + + + org.datanucleus + datanucleus-core + ${version.datanucleus.base-5.1} + + + org.datanucleus + datanucleus-api-jpa + ${version.datanucleus.api-jpa-5.1} + + + org.datanucleus + datanucleus-jpa-query + ${version.datanucleus.jpa-5.1} + + + org.datanucleus + datanucleus-rdbms + ${version.datanucleus.rdbms-5.1} + + + ${project.groupId} + blaze-persistence-testsuite-base-datanucleus + compile + + + ${project.groupId} + blaze-persistence-integration-datanucleus-5.1 + + + + + + org.datanucleus + datanucleus-maven-plugin + 4.0.0-release + + JPA + TestsuiteBase + false + true + ${basedir}/log4j.properties + ${project.build.outputDirectory} + true + + + + process-classes + + enhance + + + + + + ${project.groupId} + blaze-persistence-testsuite-base-datanucleus + ${project.version} + + + ${project.groupId} + blaze-persistence-integration-datanucleus-5.1 + ${project.version} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${additional.source.directory} + ${project.build.directory}/generated-sources/metamodel + + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/generated-sources/metamodel + + org.datanucleus.jpa.query.JPACriteriaProcessor + + + + + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + + + + openjpa + + com.blazebit.persistence.testsuite.base.jpa.category.NoOpenJPA + openjpa + + + + org.apache.openjpa + openjpa-all + ${version.openjpa} + + + ${project.groupId} + blaze-persistence-testsuite-base-openjpa + compile + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/test-metamodel + + org.apache.openjpa.persistence.meta.AnnotationProcessor6 + + + true + + + + + + + org.apache.openjpa + openjpa-all + ${version.openjpa} + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/test-metamodel + + + + + + + + + + + deltaspike-1.7 + + true + + - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.2} + org.apache.deltaspike.distribution + distributions-bom + ${version.deltaspike-1.7} + pom + import - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source-metamodel - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - - - + + + + deltaspike-1.8 + + + + org.apache.deltaspike.distribution + distributions-bom + ${version.deltaspike-1.8} + pom + import + + + + + \ No newline at end of file diff --git a/integration/deltaspike-data/testsuite/src/main/resources/META-INF/persistence.xml b/integration/deltaspike-data/testsuite/src/main/resources/META-INF/persistence.xml index 62dc9b2aef..a6932f6621 100644 --- a/integration/deltaspike-data/testsuite/src/main/resources/META-INF/persistence.xml +++ b/integration/deltaspike-data/testsuite/src/main/resources/META-INF/persistence.xml @@ -22,14 +22,5 @@ com.blazebit.persistence.deltaspike.data.testsuite.entity.Address true - - - - - - - - - \ No newline at end of file diff --git a/integration/deltaspike-data/testsuite/src/test/java/com/blazebit/persistence/deltaspike/data/testsuite/AbstractEntityViewRepositoryTest.java b/integration/deltaspike-data/testsuite/src/test/java/com/blazebit/persistence/deltaspike/data/testsuite/AbstractEntityViewRepositoryTest.java index 94afaa18bc..cab4efca01 100644 --- a/integration/deltaspike-data/testsuite/src/test/java/com/blazebit/persistence/deltaspike/data/testsuite/AbstractEntityViewRepositoryTest.java +++ b/integration/deltaspike-data/testsuite/src/test/java/com/blazebit/persistence/deltaspike/data/testsuite/AbstractEntityViewRepositoryTest.java @@ -19,6 +19,7 @@ import com.blazebit.persistence.CriteriaBuilder; import com.blazebit.persistence.deltaspike.data.testsuite.entity.Address; import com.blazebit.persistence.deltaspike.data.testsuite.entity.Person; +import com.blazebit.persistence.deltaspike.data.testsuite.producer.EntityManagerProducer; import com.blazebit.persistence.testsuite.base.AbstractPersistenceTest; import com.blazebit.persistence.view.EntityViewManager; import com.blazebit.persistence.view.EntityViewSetting; @@ -26,16 +27,11 @@ import org.apache.deltaspike.cdise.api.CdiContainer; import org.apache.deltaspike.cdise.api.CdiContainerLoader; import org.apache.deltaspike.core.api.provider.BeanProvider; -import org.hibernate.engine.spi.SessionImplementor; import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; import javax.inject.Inject; -import javax.persistence.EntityManager; import javax.persistence.EntityTransaction; -import java.sql.Connection; import java.util.logging.Level; import java.util.logging.Logger; @@ -60,18 +56,6 @@ protected Class[] getEntityClasses() { }; } - @BeforeClass - public static void bootContainer() { - CdiContainer container = CdiContainerLoader.getCdiContainer(); - container.boot(); - } - - @AfterClass - public static void shutdownContainer() { - CdiContainer container = CdiContainerLoader.getCdiContainer(); - container.shutdown(); - } - @Before public void startContexts() { CdiContainer container = CdiContainerLoader.getCdiContainer(); @@ -83,11 +67,7 @@ public void startContexts() { public void stopContexts() { CdiContainer container = CdiContainerLoader.getCdiContainer(); container.getContextControl().stopContexts(); - } - - @Override - protected Connection getConnection(EntityManager em) { - return em.unwrap(SessionImplementor.class).connection(); + container.shutdown(); } @Override @@ -98,6 +78,10 @@ protected boolean runTestInTransaction() { @Override public void init() { super.init(); + EntityManagerProducer.setEmf(emf); + // Boot the container after publishing the entity manager factory + CdiContainer container = CdiContainerLoader.getCdiContainer(); + container.boot(); persons = cbf.create(em, Person.class) .orderByAsc("id") .getResultList().toArray(new Person[0]); diff --git a/integration/deltaspike-data/testsuite/src/test/java/com/blazebit/persistence/deltaspike/data/testsuite/producer/EntityManagerProducer.java b/integration/deltaspike-data/testsuite/src/test/java/com/blazebit/persistence/deltaspike/data/testsuite/producer/EntityManagerProducer.java index 72f987e94d..6f82fc45da 100644 --- a/integration/deltaspike-data/testsuite/src/test/java/com/blazebit/persistence/deltaspike/data/testsuite/producer/EntityManagerProducer.java +++ b/integration/deltaspike-data/testsuite/src/test/java/com/blazebit/persistence/deltaspike/data/testsuite/producer/EntityManagerProducer.java @@ -16,12 +16,10 @@ package com.blazebit.persistence.deltaspike.data.testsuite.producer; -import javax.enterprise.inject.Disposes; import javax.enterprise.inject.Produces; import javax.inject.Singleton; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; /** * @author Moritz Becker @@ -29,20 +27,20 @@ */ public class EntityManagerProducer { + private static EntityManagerFactory emf; + @Produces - public EntityManager createEm(EntityManagerFactory emf) { + public EntityManager createEm() { return emf.createEntityManager(); } @Produces @Singleton public EntityManagerFactory getEntityManagerFactory() { - return Persistence.createEntityManagerFactory("TestsuiteBase", null); + return emf; } - public void onShutdown(@Disposes EntityManagerFactory emf) { - if (emf.isOpen()) { - emf.close(); - } + public static void setEmf( EntityManagerFactory emf) { + EntityManagerProducer.emf = emf; } } \ No newline at end of file diff --git a/integration/entity-view-cdi/pom.xml b/integration/entity-view-cdi/pom.xml index 7afcff29a8..8c5b9e84d4 100644 --- a/integration/entity-view-cdi/pom.xml +++ b/integration/entity-view-cdi/pom.xml @@ -30,8 +30,26 @@ com.blazebit.persistence.integration.view.cdi + + + + + org.apache.deltaspike.distribution + distributions-bom + ${version.deltaspike-1.7} + pom + import + + + + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + 1.0.1.Final + provided + ${project.groupId} blaze-persistence-core-api @@ -47,12 +65,6 @@ provided - - - org.apache.openejb - javaee-api - provided - ${project.groupId} blaze-persistence-core-impl @@ -80,19 +92,55 @@ org.apache.deltaspike.cdictrl - deltaspike-cdictrl-openejb + deltaspike-cdictrl-weld test + + + weld-api + org.jboss.weld + + + jboss-logging + org.jboss.logging + + - org.apache.openejb - openejb-core - test + org.jboss.weld.se + weld-se-core + provided junit junit test + + + + javax.xml.bind + jaxb-api + ${version.jaxb} + provided + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + provided + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + provided + + + javax.transaction + javax.transaction-api + 1.2 + provided + @@ -137,20 +185,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - default-test - - - ${surefire.jvm.params} ${surefire.openejb.jvm.params} - ${skipTests} - - - - \ No newline at end of file diff --git a/integration/hibernate-4.2/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate4Access.java b/integration/hibernate-4.2/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate4Access.java index 0be2a8e478..728e549c09 100644 --- a/integration/hibernate-4.2/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate4Access.java +++ b/integration/hibernate-4.2/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate4Access.java @@ -37,9 +37,11 @@ import org.hibernate.engine.spi.TypedValue; import org.hibernate.engine.transaction.spi.TransactionCoordinator; import org.hibernate.event.spi.EventSource; +import org.hibernate.hql.internal.ast.ParameterTranslationsImpl; import org.hibernate.hql.internal.ast.exec.BasicExecutor; import org.hibernate.hql.internal.ast.exec.StatementExecutor; import org.hibernate.hql.internal.classic.ParserHelper; +import org.hibernate.hql.spi.ParameterTranslations; import org.hibernate.internal.util.StringHelper; import org.hibernate.loader.hql.QueryLoader; import org.hibernate.param.ParameterSpecification; @@ -307,4 +309,9 @@ public QueryParameters createQueryParameters( null ); } + + @Override + public ParameterTranslations createParameterTranslations(List queryParameterSpecifications) { + return new ParameterTranslationsImpl(queryParameterSpecifications); + } } diff --git a/integration/hibernate-4.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate43Access.java b/integration/hibernate-4.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate43Access.java index 016c0f76f3..6215924dc3 100644 --- a/integration/hibernate-4.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate43Access.java +++ b/integration/hibernate-4.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate43Access.java @@ -37,9 +37,11 @@ import org.hibernate.engine.spi.TypedValue; import org.hibernate.engine.transaction.spi.TransactionCoordinator; import org.hibernate.event.spi.EventSource; +import org.hibernate.hql.internal.ast.ParameterTranslationsImpl; import org.hibernate.hql.internal.ast.exec.BasicExecutor; import org.hibernate.hql.internal.ast.exec.StatementExecutor; import org.hibernate.hql.internal.classic.ParserHelper; +import org.hibernate.hql.spi.ParameterTranslations; import org.hibernate.internal.util.StringHelper; import org.hibernate.loader.hql.QueryLoader; import org.hibernate.param.ParameterSpecification; @@ -308,4 +310,9 @@ public QueryParameters createQueryParameters( null ); } + + @Override + public ParameterTranslations createParameterTranslations(List queryParameterSpecifications) { + return new ParameterTranslationsImpl(queryParameterSpecifications); + } } diff --git a/integration/hibernate-5.2/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate52Access.java b/integration/hibernate-5.2/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate52Access.java index bf2d62e146..80ddca7aea 100644 --- a/integration/hibernate-5.2/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate52Access.java +++ b/integration/hibernate-5.2/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate52Access.java @@ -34,8 +34,10 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.TypedValue; import org.hibernate.event.spi.EventSource; +import org.hibernate.hql.internal.ast.ParameterTranslationsImpl; import org.hibernate.hql.internal.ast.exec.BasicExecutor; import org.hibernate.hql.internal.ast.exec.StatementExecutor; +import org.hibernate.hql.spi.ParameterTranslations; import org.hibernate.loader.hql.QueryLoader; import org.hibernate.param.ParameterSpecification; import org.hibernate.query.internal.AbstractProducedQuery; @@ -207,4 +209,9 @@ public QueryParameters createQueryParameters( ); } + @Override + public ParameterTranslations createParameterTranslations(List queryParameterSpecifications) { + return new ParameterTranslationsImpl(queryParameterSpecifications); + } + } diff --git a/integration/hibernate-5.3/pom.xml b/integration/hibernate-5.3/pom.xml new file mode 100644 index 0000000000..1999e4d914 --- /dev/null +++ b/integration/hibernate-5.3/pom.xml @@ -0,0 +1,105 @@ + + + + + 4.0.0 + + + com.blazebit + blaze-persistence-integration + 1.2.0-SNAPSHOT + ../pom.xml + + + blaze-persistence-integration-hibernate-5.3 + jar + + Blazebit Persistence Integration Hibernate 5.3 + + + com.blazebit.persistence.integration.hibernate + + + + + ${project.groupId} + blaze-persistence-core-api + + + ${project.groupId} + blaze-persistence-integration-hibernate-base + + + + ${project.groupId} + blaze-apt-utils + provided + + + + org.hibernate + hibernate-core + 5.3.0.CR1 + provided + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-resource + generate-resources + + add-resource + + + + + target/generated/resources + + + + + + + + org.bsc.maven + maven-processor-plugin + + + process-resources + + process + + generate-resources + + target/generated/resources + + + com.blazebit.apt.service.ServiceProviderAnnotationProcessor + + + + + + + + diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/CustomBasicCollectionPersister.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/CustomBasicCollectionPersister.java new file mode 100644 index 0000000000..f0d0c77fdd --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/CustomBasicCollectionPersister.java @@ -0,0 +1,54 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import com.blazebit.persistence.integration.hibernate.base.CustomCollectionPersister; +import com.blazebit.persistence.integration.hibernate.base.CustomSubselectCollectionLoader; +import org.hibernate.MappingException; +import org.hibernate.cache.CacheException; +import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy; +import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.engine.spi.SubselectFetch; +import org.hibernate.loader.collection.CollectionInitializer; +import org.hibernate.mapping.Collection; +import org.hibernate.persister.collection.BasicCollectionPersister; +import org.hibernate.persister.spi.PersisterCreationContext; + +/** + * @author Jan-Willem Gmelig Meyling + * @since 1.2.0 + */ +public class CustomBasicCollectionPersister extends BasicCollectionPersister implements CustomCollectionPersister { + + public CustomBasicCollectionPersister(Collection collectionBinding, CollectionRegionAccessStrategy cacheAccessStrategy, PersisterCreationContext creationContext) throws MappingException, CacheException { + super(collectionBinding, cacheAccessStrategy, creationContext); + } + + @Override + protected CollectionInitializer createSubselectInitializer(SubselectFetch subselect, SharedSessionContractImplementor session) { + return new CustomSubselectCollectionLoader( + this, + subselect.toSubselectString( getCollectionType().getLHSPropertyName() ), + subselect.getResult(), + subselect.getQueryParameters(), + subselect.getNamedParameterLocMap(), + session.getFactory(), + session.getLoadQueryInfluencers() + ); + } + +} diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/CustomOneToManyPersister.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/CustomOneToManyPersister.java new file mode 100644 index 0000000000..623e076320 --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/CustomOneToManyPersister.java @@ -0,0 +1,54 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import com.blazebit.persistence.integration.hibernate.base.CustomCollectionPersister; +import com.blazebit.persistence.integration.hibernate.base.CustomSubselectOneToManyLoader; +import org.hibernate.MappingException; +import org.hibernate.cache.CacheException; +import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy; +import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.engine.spi.SubselectFetch; +import org.hibernate.loader.collection.CollectionInitializer; +import org.hibernate.mapping.Collection; +import org.hibernate.persister.collection.OneToManyPersister; +import org.hibernate.persister.spi.PersisterCreationContext; + +/** + * + * @author Christian Beikov + * @since 1.2.0 + */ +public class CustomOneToManyPersister extends OneToManyPersister implements CustomCollectionPersister { + + public CustomOneToManyPersister(Collection collectionBinding, CollectionRegionAccessStrategy cacheAccessStrategy, PersisterCreationContext creationContext) throws MappingException, CacheException { + super(collectionBinding, cacheAccessStrategy, creationContext); + } + + @Override + protected CollectionInitializer createSubselectInitializer(SubselectFetch subselect, SharedSessionContractImplementor session) { + return new CustomSubselectOneToManyLoader( + this, + subselect.toSubselectString( getCollectionType().getLHSPropertyName() ), + subselect.getResult(), + subselect.getQueryParameters(), + subselect.getNamedParameterLocMap(), + session.getFactory(), + session.getLoadQueryInfluencers() + ); + } +} \ No newline at end of file diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/CustomPersisterClassResolver.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/CustomPersisterClassResolver.java new file mode 100644 index 0000000000..e8147c2813 --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/CustomPersisterClassResolver.java @@ -0,0 +1,37 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import com.blazebit.apt.service.ServiceProvider; +import org.hibernate.mapping.Collection; +import org.hibernate.persister.collection.CollectionPersister; +import org.hibernate.persister.internal.StandardPersisterClassResolver; +import org.hibernate.persister.spi.PersisterClassResolver; + +/** + * @author Jan-Willem Gmelig Meyling + * @since 1.2.0 + */ +@ServiceProvider(PersisterClassResolver.class) +public class CustomPersisterClassResolver extends StandardPersisterClassResolver implements PersisterClassResolver { + + @Override + public Class getCollectionPersisterClass(Collection metadata) { + return metadata.isOneToMany() ? CustomOneToManyPersister.class : CustomBasicCollectionPersister.class; + } + +} diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53Access.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53Access.java new file mode 100644 index 0000000000..058fac9791 --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53Access.java @@ -0,0 +1,228 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import com.blazebit.apt.service.ServiceProvider; +import com.blazebit.persistence.integration.hibernate.base.HibernateAccess; +import com.blazebit.persistence.integration.hibernate.base.HibernateExtendedQuerySupport; +import com.blazebit.persistence.integration.hibernate.base.HibernateReturningResult; +import com.blazebit.persistence.spi.DbmsDialect; +import org.hibernate.HibernateException; +import org.hibernate.LockOptions; +import org.hibernate.Query; +import org.hibernate.engine.jdbc.spi.JdbcCoordinator; +import org.hibernate.engine.query.spi.HQLQueryPlan; +import org.hibernate.engine.spi.ExceptionConverter; +import org.hibernate.engine.spi.QueryParameters; +import org.hibernate.engine.spi.RowSelection; +import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.engine.spi.TypedValue; +import org.hibernate.event.spi.EventSource; +import org.hibernate.hql.internal.ast.ParameterTranslationsImpl; +import org.hibernate.hql.internal.ast.exec.BasicExecutor; +import org.hibernate.hql.internal.ast.exec.StatementExecutor; +import org.hibernate.hql.spi.ParameterTranslations; +import org.hibernate.loader.hql.QueryLoader; +import org.hibernate.param.ParameterSpecification; +import org.hibernate.query.internal.AbstractProducedQuery; +import org.hibernate.query.internal.QueryParameterBindingsImpl; +import org.hibernate.query.spi.QueryImplementor; +import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl; +import org.hibernate.resource.transaction.spi.TransactionCoordinator; +import org.hibernate.type.Type; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceException; +import java.io.Serializable; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +@ServiceProvider(HibernateAccess.class) +public class Hibernate53Access implements HibernateAccess { + + private static final Logger LOG = Logger.getLogger(HibernateExtendedQuerySupport.class.getName()); + private static final Method DO_EXECUTE_METHOD; + private static final Constructor PARAMETER_TRANSLATIONS_CONSTRUCTOR; + + static { + try { + Method m = BasicExecutor.class.getDeclaredMethod("doExecute", QueryParameters.class, SharedSessionContractImplementor.class, String.class, List.class); + m.setAccessible(true); + DO_EXECUTE_METHOD = m; + Constructor c = ParameterTranslationsImpl.class.getDeclaredConstructor(List.class); + c.setAccessible(true); + PARAMETER_TRANSLATIONS_CONSTRUCTOR = c; + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + @Override + public SessionImplementor wrapSession(SessionImplementor session, DbmsDialect dbmsDialect, String[][] columns, int[] returningSqlTypes, HibernateReturningResult returningResult) { + JdbcCoordinator jdbcCoordinator = session.getJdbcCoordinator(); + + Object jdbcCoordinatorProxy = Proxy.newProxyInstance(jdbcCoordinator.getClass().getClassLoader(), new Class[]{ JdbcCoordinator.class }, new JdbcCoordinatorInvocationHandler(jdbcCoordinator, session.getFactory(), dbmsDialect, columns, returningSqlTypes, returningResult)); + Object sessionProxy = Proxy.newProxyInstance(session.getClass().getClassLoader(), new Class[]{ SessionImplementor.class, EventSource.class }, new Hibernate53SessionInvocationHandler(session, jdbcCoordinatorProxy)); + return (SessionImplementor) sessionProxy; + } + + @Override + public SessionFactoryImplementor wrapSessionFactory(SessionFactoryImplementor sessionFactory, DbmsDialect dbmsDialect) { + Object dialectProxy = new Hibernate53LimitHandlingDialect(sessionFactory.getDialect(), dbmsDialect); + Object sessionFactoryProxy = Proxy.newProxyInstance(sessionFactory.getClass().getClassLoader(), new Class[]{ SessionFactoryImplementor.class }, new Hibernate53SessionFactoryInvocationHandler(sessionFactory, dialectProxy)); + return (SessionFactoryImplementor) sessionFactoryProxy; + } + + @Override + public void checkTransactionSynchStatus(SessionImplementor session) { + TransactionCoordinator coordinator = session.getTransactionCoordinator(); + coordinator.pulse(); + if (coordinator instanceof JtaTransactionCoordinatorImpl) { + ((JtaTransactionCoordinatorImpl) coordinator).getSynchronizationCallbackCoordinator().processAnyDelayedAfterCompletion(); + } + } + + @Override + public void afterTransaction(SessionImplementor session, boolean success) { + TransactionCoordinator coordinator = session.getTransactionCoordinator(); + if (!session.isTransactionInProgress() ) { + session.getJdbcCoordinator().afterTransaction(); + } + if (coordinator instanceof JtaTransactionCoordinatorImpl) { + ((JtaTransactionCoordinatorImpl) coordinator).getSynchronizationCallbackCoordinator().processAnyDelayedAfterCompletion(); + } + } + + @Override + @SuppressWarnings({ "unchecked" }) + public List list(QueryLoader queryLoader, SessionImplementor sessionImplementor, QueryParameters queryParameters) { + return queryLoader.list(sessionImplementor, queryParameters); + } + + @Override + public List performList(HQLQueryPlan queryPlan, SessionImplementor sessionImplementor, QueryParameters queryParameters) { + return queryPlan.performList(queryParameters, sessionImplementor); + } + + @Override + public int performExecuteUpdate(HQLQueryPlan queryPlan, SessionImplementor sessionImplementor, QueryParameters queryParameters) { + return queryPlan.performExecuteUpdate(queryParameters, sessionImplementor); + } + + @Override + public void doExecute(StatementExecutor executor, String delete, QueryParameters parameters, SessionImplementor session, List parameterSpecifications) { + try { + DO_EXECUTE_METHOD.invoke(executor, parameters, session, delete, parameterSpecifications); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + @Override + public QueryParameters getQueryParameters(Query hibernateQuery, Map namedParams) { + return ((AbstractProducedQuery) hibernateQuery).getQueryParameters(); + } + + @Override + public Map getNamedParams(Query hibernateQuery) { + QueryParameterBindingsImpl queryParameterBindings = hibernateQuery.unwrap(QueryParameterBindingsImpl.class); + return queryParameterBindings.collectNamedParameterBindings(); + } + + @Override + public String expandParameterLists(SessionImplementor session, org.hibernate.Query hibernateQuery, Map namedParamsCopy) { + QueryParameterBindingsImpl queryParameterBindings = hibernateQuery.unwrap(QueryParameterBindingsImpl.class); + SharedSessionContractImplementor producer = (SharedSessionContractImplementor) ((QueryImplementor) hibernateQuery).getProducer(); + String query = hibernateQuery.getQueryString(); + + // NOTE: In Hibernate 5.3.0.CR1 this is call causes a side effect which is why this is essentially unusable for us + query = queryParameterBindings.expandListValuedParameters(query, producer); + return query; + } + + private ExceptionConverter getExceptionConverter(EntityManager em) { + return em.unwrap(SharedSessionContractImplementor.class).getExceptionConverter(); + } + + @Override + public RuntimeException convert(EntityManager em, HibernateException e) { + return getExceptionConverter(em).convert(e); + } + + @Override + public void handlePersistenceException(EntityManager em, PersistenceException e) { + getExceptionConverter(em).convert(e); + } + + @Override + public void throwPersistenceException(EntityManager em, HibernateException e) { + getExceptionConverter(em).convert(e); + } + + @Override + public QueryParameters createQueryParameters( + final Type[] positionalParameterTypes, + final Object[] positionalParameterValues, + final Map namedParameters, + final LockOptions lockOptions, + final RowSelection rowSelection, + final boolean isReadOnlyInitialized, + final boolean readOnly, + final boolean cacheable, + final String cacheRegion, + //final boolean forceCacheRefresh, + final String comment, + final List queryHints, + final Serializable[] collectionKeys) { + return new QueryParameters( + positionalParameterTypes, + positionalParameterValues, + namedParameters, + lockOptions, + rowSelection, + isReadOnlyInitialized, + readOnly, + cacheable, + cacheRegion, + comment, + queryHints, + collectionKeys, + null + ); + } + + @Override + public ParameterTranslations createParameterTranslations(List queryParameterSpecifications) { + try { + return PARAMETER_TRANSLATIONS_CONSTRUCTOR.newInstance(queryParameterSpecifications); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53DelegatingDialect.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53DelegatingDialect.java new file mode 100644 index 0000000000..d48249b1a4 --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53DelegatingDialect.java @@ -0,0 +1,909 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import org.hibernate.HibernateException; +import org.hibernate.LockMode; +import org.hibernate.LockOptions; +import org.hibernate.MappingException; +import org.hibernate.NullPrecedence; +import org.hibernate.ScrollMode; +import org.hibernate.boot.model.TypeContributions; +import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject; +import org.hibernate.boot.model.relational.Sequence; +import org.hibernate.dialect.ColumnAliasExtractor; +import org.hibernate.dialect.Dialect; +import org.hibernate.dialect.LobMergeStrategy; +import org.hibernate.dialect.identity.IdentityColumnSupport; +import org.hibernate.dialect.lock.LockingStrategy; +import org.hibernate.dialect.pagination.LimitHandler; +import org.hibernate.dialect.unique.UniqueDelegate; +import org.hibernate.engine.jdbc.env.spi.IdentifierHelper; +import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder; +import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport; +import org.hibernate.engine.jdbc.env.spi.SchemaNameResolver; +import org.hibernate.exception.spi.SQLExceptionConversionDelegate; +import org.hibernate.exception.spi.SQLExceptionConverter; +import org.hibernate.exception.spi.ViolatedConstraintNameExtracter; +import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy; +import org.hibernate.loader.BatchLoadSizingStrategy; +import org.hibernate.mapping.Constraint; +import org.hibernate.mapping.ForeignKey; +import org.hibernate.mapping.Index; +import org.hibernate.mapping.Table; +import org.hibernate.persister.entity.Lockable; +import org.hibernate.procedure.spi.CallableStatementSupport; +import org.hibernate.service.ServiceRegistry; +import org.hibernate.sql.CaseFragment; +import org.hibernate.sql.JoinFragment; +import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor; +import org.hibernate.tool.schema.spi.Exporter; +import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; + +import java.sql.CallableStatement; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +public class Hibernate53DelegatingDialect extends Dialect { + + private final Dialect delegate; + + public Hibernate53DelegatingDialect(Dialect delegate) { + this.delegate = delegate; + } + + @Override + public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) { + delegate.contributeTypes(typeContributions, serviceRegistry); + } + + @Override + public String getTypeName(int code) throws HibernateException { + return delegate.getTypeName(code); + } + + @Override + public String getTypeName(int code, long length, int precision, int scale) throws HibernateException { + return delegate.getTypeName(code, length, precision, scale); + } + + @Override + public String getCastTypeName(int code) { + return delegate.getCastTypeName(code); + } + + @Override + public String cast(String value, int jdbcTypeCode, int length, int precision, int scale) { + return delegate.cast(value, jdbcTypeCode, length, precision, scale); + } + + @Override + public String cast(String value, int jdbcTypeCode, int length) { + return delegate.cast(value, jdbcTypeCode, length); + } + + @Override + public String cast(String value, int jdbcTypeCode, int precision, int scale) { + return delegate.cast(value, jdbcTypeCode, precision, scale); + } + + @Override + public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) { + return delegate.remapSqlTypeDescriptor(sqlTypeDescriptor); + } + + @Override + public LobMergeStrategy getLobMergeStrategy() { + return delegate.getLobMergeStrategy(); + } + + @Override + public String getHibernateTypeName(int code) throws HibernateException { + return delegate.getHibernateTypeName(code); + } + + @Override + public boolean isTypeNameRegistered(String typeName) { + return delegate.isTypeNameRegistered(typeName); + } + + @Override + public String getHibernateTypeName(int code, int length, int precision, int scale) throws HibernateException { + return delegate.getHibernateTypeName(code, length, precision, scale); + } + + @Override + public Class getNativeIdentifierGeneratorClass() { + return delegate.getNativeIdentifierGeneratorClass(); + } + + @Override + public IdentityColumnSupport getIdentityColumnSupport() { + return delegate.getIdentityColumnSupport(); + } + + @Override + public boolean supportsSequences() { + return delegate.supportsSequences(); + } + + @Override + public boolean supportsPooledSequences() { + return delegate.supportsPooledSequences(); + } + + @Override + public String getSequenceNextValString(String sequenceName) throws MappingException { + return delegate.getSequenceNextValString(sequenceName); + } + + @Override + public String getSelectSequenceNextValString(String sequenceName) throws MappingException { + return delegate.getSelectSequenceNextValString(sequenceName); + } + + @Override + @Deprecated + public String[] getCreateSequenceStrings(String sequenceName) throws MappingException { + return delegate.getCreateSequenceStrings(sequenceName); + } + + @Override + public String[] getCreateSequenceStrings(String sequenceName, int initialValue, int incrementSize) throws MappingException { + return delegate.getCreateSequenceStrings(sequenceName, initialValue, incrementSize); + } + + @Override + public String[] getDropSequenceStrings(String sequenceName) throws MappingException { + return delegate.getDropSequenceStrings(sequenceName); + } + + @Override + public String getQuerySequencesString() { + return delegate.getQuerySequencesString(); + } + + @Override + public SequenceInformationExtractor getSequenceInformationExtractor() { + return delegate.getSequenceInformationExtractor(); + } + + @Override + public String getSelectGUIDString() { + return delegate.getSelectGUIDString(); + } + + @Override + public LimitHandler getLimitHandler() { + return delegate.getLimitHandler(); + } + + @Override + @Deprecated + public boolean supportsLimit() { + return delegate.supportsLimit(); + } + + @Override + @Deprecated + public boolean supportsLimitOffset() { + return delegate.supportsLimitOffset(); + } + + @Override + @Deprecated + public boolean supportsVariableLimit() { + return delegate.supportsVariableLimit(); + } + + @Override + @Deprecated + public boolean bindLimitParametersInReverseOrder() { + return delegate.bindLimitParametersInReverseOrder(); + } + + @Override + @Deprecated + public boolean bindLimitParametersFirst() { + return delegate.bindLimitParametersFirst(); + } + + @Override + @Deprecated + public boolean useMaxForLimit() { + return delegate.useMaxForLimit(); + } + + @Override + @Deprecated + public boolean forceLimitUsage() { + return delegate.forceLimitUsage(); + } + + @Override + @Deprecated + public String getLimitString(String query, int offset, int limit) { + return delegate.getLimitString(query, offset, limit); + } + + @Override + @Deprecated + public int convertToFirstRowValue(int zeroBasedFirstResult) { + return delegate.convertToFirstRowValue(zeroBasedFirstResult); + } + + @Override + public boolean supportsLockTimeouts() { + return delegate.supportsLockTimeouts(); + } + + @Override + public boolean isLockTimeoutParameterized() { + return delegate.isLockTimeoutParameterized(); + } + + @Override + public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) { + return delegate.getLockingStrategy(lockable, lockMode); + } + + @Override + public String getForUpdateString(LockOptions lockOptions) { + return delegate.getForUpdateString(lockOptions); + } + + @Override + public String getForUpdateString(LockMode lockMode) { + return delegate.getForUpdateString(lockMode); + } + + @Override + public String getForUpdateString() { + return delegate.getForUpdateString(); + } + + @Override + public String getWriteLockString(int timeout) { + return delegate.getWriteLockString(timeout); + } + + @Override + public String getReadLockString(int timeout) { + return delegate.getReadLockString(timeout); + } + + @Override + public boolean forUpdateOfColumns() { + return delegate.forUpdateOfColumns(); + } + + @Override + public boolean supportsOuterJoinForUpdate() { + return delegate.supportsOuterJoinForUpdate(); + } + + @Override + public String getForUpdateString(String aliases) { + return delegate.getForUpdateString(aliases); + } + + @Override + public String getForUpdateString(String aliases, LockOptions lockOptions) { + return delegate.getForUpdateString(aliases, lockOptions); + } + + @Override + public String getForUpdateNowaitString() { + return delegate.getForUpdateNowaitString(); + } + + @Override + public String getForUpdateSkipLockedString() { + return delegate.getForUpdateSkipLockedString(); + } + + @Override + public String getForUpdateNowaitString(String aliases) { + return delegate.getForUpdateNowaitString(aliases); + } + + @Override + public String getForUpdateSkipLockedString(String aliases) { + return delegate.getForUpdateSkipLockedString(aliases); + } + + @Override + @Deprecated + public String appendLockHint(LockMode mode, String tableName) { + return delegate.appendLockHint(mode, tableName); + } + + @Override + public String appendLockHint(LockOptions lockOptions, String tableName) { + return delegate.appendLockHint(lockOptions, tableName); + } + + @Override + public String applyLocksToSql(String sql, LockOptions aliasedLockOptions, Map keyColumnNames) { + return delegate.applyLocksToSql(sql, aliasedLockOptions, keyColumnNames); + } + + @Override + public String getCreateTableString() { + return delegate.getCreateTableString(); + } + + @Override + public String getCreateMultisetTableString() { + return delegate.getCreateMultisetTableString(); + } + + @Override + public MultiTableBulkIdStrategy getDefaultMultiTableBulkIdStrategy() { + return delegate.getDefaultMultiTableBulkIdStrategy(); + } + + @Override + public int registerResultSetOutParameter(CallableStatement statement, int position) throws SQLException { + return delegate.registerResultSetOutParameter(statement, position); + } + + @Override + public int registerResultSetOutParameter(CallableStatement statement, String name) throws SQLException { + return delegate.registerResultSetOutParameter(statement, name); + } + + @Override + public ResultSet getResultSet(CallableStatement statement) throws SQLException { + return delegate.getResultSet(statement); + } + + @Override + public ResultSet getResultSet(CallableStatement statement, int position) throws SQLException { + return delegate.getResultSet(statement, position); + } + + @Override + public ResultSet getResultSet(CallableStatement statement, String name) throws SQLException { + return delegate.getResultSet(statement, name); + } + + @Override + public boolean supportsCurrentTimestampSelection() { + return delegate.supportsCurrentTimestampSelection(); + } + + @Override + public boolean isCurrentTimestampSelectStringCallable() { + return delegate.isCurrentTimestampSelectStringCallable(); + } + + @Override + public String getCurrentTimestampSelectString() { + return delegate.getCurrentTimestampSelectString(); + } + + @Override + public String getCurrentTimestampSQLFunctionName() { + return delegate.getCurrentTimestampSQLFunctionName(); + } + + @Override + @Deprecated + public SQLExceptionConverter buildSQLExceptionConverter() { + return delegate.buildSQLExceptionConverter(); + } + + @Override + public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() { + return delegate.buildSQLExceptionConversionDelegate(); + } + + @Override + public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() { + return delegate.getViolatedConstraintNameExtracter(); + } + + @Override + public String getSelectClauseNullString(int sqlType) { + return delegate.getSelectClauseNullString(sqlType); + } + + @Override + public boolean supportsUnionAll() { + return delegate.supportsUnionAll(); + } + + @Override + public JoinFragment createOuterJoinFragment() { + return delegate.createOuterJoinFragment(); + } + + @Override + public CaseFragment createCaseFragment() { + return delegate.createCaseFragment(); + } + + @Override + public String getNoColumnsInsertString() { + return delegate.getNoColumnsInsertString(); + } + + @Override + public String getLowercaseFunction() { + return delegate.getLowercaseFunction(); + } + + @Override + public String getCaseInsensitiveLike() { + return delegate.getCaseInsensitiveLike(); + } + + @Override + public boolean supportsCaseInsensitiveLike() { + return delegate.supportsCaseInsensitiveLike(); + } + + @Override + public String transformSelectString(String select) { + return delegate.transformSelectString(select); + } + + @Override + public int getMaxAliasLength() { + return delegate.getMaxAliasLength(); + } + + @Override + public String toBooleanValueString(boolean bool) { + return delegate.toBooleanValueString(bool); + } + + @Override + @Deprecated + public Set getKeywords() { + return delegate.getKeywords(); + } + + @Override + public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData) throws SQLException { + return delegate.buildIdentifierHelper(builder, dbMetaData); + } + + @Override + public char openQuote() { + return delegate.openQuote(); + } + + @Override + public char closeQuote() { + return delegate.closeQuote(); + } + + @Override + public Exporter getTableExporter() { + return delegate.getTableExporter(); + } + + @Override + public Exporter getSequenceExporter() { + return delegate.getSequenceExporter(); + } + + @Override + public Exporter getIndexExporter() { + return delegate.getIndexExporter(); + } + + @Override + public Exporter getForeignKeyExporter() { + return delegate.getForeignKeyExporter(); + } + + @Override + public Exporter getUniqueKeyExporter() { + return delegate.getUniqueKeyExporter(); + } + + @Override + public Exporter getAuxiliaryDatabaseObjectExporter() { + return delegate.getAuxiliaryDatabaseObjectExporter(); + } + + @Override + public boolean canCreateCatalog() { + return delegate.canCreateCatalog(); + } + + @Override + public String[] getCreateCatalogCommand(String catalogName) { + return delegate.getCreateCatalogCommand(catalogName); + } + + @Override + public String[] getDropCatalogCommand(String catalogName) { + return delegate.getDropCatalogCommand(catalogName); + } + + @Override + public boolean canCreateSchema() { + return delegate.canCreateSchema(); + } + + @Override + public String[] getCreateSchemaCommand(String schemaName) { + return delegate.getCreateSchemaCommand(schemaName); + } + + @Override + public String[] getDropSchemaCommand(String schemaName) { + return delegate.getDropSchemaCommand(schemaName); + } + + @Override + public String getCurrentSchemaCommand() { + return delegate.getCurrentSchemaCommand(); + } + + @Override + public SchemaNameResolver getSchemaNameResolver() { + return delegate.getSchemaNameResolver(); + } + + @Override + public boolean hasAlterTable() { + return delegate.hasAlterTable(); + } + + @Override + public boolean dropConstraints() { + return delegate.dropConstraints(); + } + + @Override + public boolean qualifyIndexName() { + return delegate.qualifyIndexName(); + } + + @Override + public String getAddColumnString() { + return delegate.getAddColumnString(); + } + + @Override + public String getAddColumnSuffixString() { + return delegate.getAddColumnSuffixString(); + } + + @Override + public String getDropForeignKeyString() { + return delegate.getDropForeignKeyString(); + } + + @Override + public String getTableTypeString() { + return delegate.getTableTypeString(); + } + + @Override + public String getAddForeignKeyConstraintString(String constraintName, String[] foreignKey, String referencedTable, String[] primaryKey, boolean referencesPrimaryKey) { + return delegate.getAddForeignKeyConstraintString(constraintName, foreignKey, referencedTable, primaryKey, referencesPrimaryKey); + } + + @Override + public String getAddPrimaryKeyConstraintString(String constraintName) { + return delegate.getAddPrimaryKeyConstraintString(constraintName); + } + + @Override + public boolean hasSelfReferentialForeignKeyBug() { + return delegate.hasSelfReferentialForeignKeyBug(); + } + + @Override + public String getNullColumnString() { + return delegate.getNullColumnString(); + } + + @Override + public boolean supportsCommentOn() { + return delegate.supportsCommentOn(); + } + + @Override + public String getTableComment(String comment) { + return delegate.getTableComment(comment); + } + + @Override + public String getColumnComment(String comment) { + return delegate.getColumnComment(comment); + } + + @Override + public boolean supportsIfExistsBeforeTableName() { + return delegate.supportsIfExistsBeforeTableName(); + } + + @Override + public boolean supportsIfExistsAfterTableName() { + return delegate.supportsIfExistsAfterTableName(); + } + + @Override + public boolean supportsIfExistsBeforeConstraintName() { + return delegate.supportsIfExistsBeforeConstraintName(); + } + + @Override + public boolean supportsIfExistsAfterConstraintName() { + return delegate.supportsIfExistsAfterConstraintName(); + } + + @Override + public String getDropTableString(String tableName) { + return delegate.getDropTableString(tableName); + } + + @Override + public boolean supportsColumnCheck() { + return delegate.supportsColumnCheck(); + } + + @Override + public boolean supportsTableCheck() { + return delegate.supportsTableCheck(); + } + + @Override + public boolean supportsCascadeDelete() { + return delegate.supportsCascadeDelete(); + } + + @Override + public String getCascadeConstraintsString() { + return delegate.getCascadeConstraintsString(); + } + + @Override + public String getCrossJoinSeparator() { + return delegate.getCrossJoinSeparator(); + } + + @Override + public ColumnAliasExtractor getColumnAliasExtractor() { + return delegate.getColumnAliasExtractor(); + } + + @Override + public boolean supportsEmptyInList() { + return delegate.supportsEmptyInList(); + } + + @Override + public boolean areStringComparisonsCaseInsensitive() { + return delegate.areStringComparisonsCaseInsensitive(); + } + + @Override + public boolean supportsRowValueConstructorSyntax() { + return delegate.supportsRowValueConstructorSyntax(); + } + + @Override + public boolean supportsRowValueConstructorSyntaxInInList() { + return delegate.supportsRowValueConstructorSyntaxInInList(); + } + + @Override + public boolean useInputStreamToInsertBlob() { + return delegate.useInputStreamToInsertBlob(); + } + + @Override + public boolean supportsParametersInInsertSelect() { + return delegate.supportsParametersInInsertSelect(); + } + + @Override + public boolean replaceResultVariableInOrderByClauseWithPosition() { + return delegate.replaceResultVariableInOrderByClauseWithPosition(); + } + + @Override + public String renderOrderByElement(String expression, String collation, String order, NullPrecedence nulls) { + return delegate.renderOrderByElement(expression, collation, order, nulls); + } + + @Override + public boolean requiresCastingOfParametersInSelectClause() { + return delegate.requiresCastingOfParametersInSelectClause(); + } + + @Override + public boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() { + return delegate.supportsResultSetPositionQueryMethodsOnForwardOnlyCursor(); + } + + @Override + public boolean supportsCircularCascadeDeleteConstraints() { + return delegate.supportsCircularCascadeDeleteConstraints(); + } + + @Override + public boolean supportsSubselectAsInPredicateLHS() { + return delegate.supportsSubselectAsInPredicateLHS(); + } + + @Override + public boolean supportsExpectedLobUsagePattern() { + return delegate.supportsExpectedLobUsagePattern(); + } + + @Override + public boolean supportsLobValueChangePropogation() { + return delegate.supportsLobValueChangePropogation(); + } + + @Override + public boolean supportsUnboundedLobLocatorMaterialization() { + return delegate.supportsUnboundedLobLocatorMaterialization(); + } + + @Override + public boolean supportsSubqueryOnMutatingTable() { + return delegate.supportsSubqueryOnMutatingTable(); + } + + @Override + public boolean supportsExistsInSelect() { + return delegate.supportsExistsInSelect(); + } + + @Override + public boolean doesReadCommittedCauseWritersToBlockReaders() { + return delegate.doesReadCommittedCauseWritersToBlockReaders(); + } + + @Override + public boolean doesRepeatableReadCauseReadersToBlockWriters() { + return delegate.doesRepeatableReadCauseReadersToBlockWriters(); + } + + @Override + public boolean supportsBindAsCallableArgument() { + return delegate.supportsBindAsCallableArgument(); + } + + @Override + public boolean supportsTupleCounts() { + return delegate.supportsTupleCounts(); + } + + @Override + public boolean supportsTupleDistinctCounts() { + return delegate.supportsTupleDistinctCounts(); + } + + @Override + public boolean requiresParensForTupleDistinctCounts() { + return delegate.requiresParensForTupleDistinctCounts(); + } + + @Override + public int getInExpressionCountLimit() { + return delegate.getInExpressionCountLimit(); + } + + @Override + public boolean forceLobAsLastValue() { + return delegate.forceLobAsLastValue(); + } + + @Override + public boolean useFollowOnLocking() { + return delegate.useFollowOnLocking(); + } + + @Override + public String getNotExpression(String expression) { + return delegate.getNotExpression(expression); + } + + @Override + public UniqueDelegate getUniqueDelegate() { + return delegate.getUniqueDelegate(); + } + + @Override + @Deprecated + public boolean supportsUnique() { + return delegate.supportsUnique(); + } + + @Override + @Deprecated + public boolean supportsUniqueConstraintInCreateAlterTable() { + return delegate.supportsUniqueConstraintInCreateAlterTable(); + } + + @Override + @Deprecated + public String getAddUniqueConstraintString(String constraintName) { + return delegate.getAddUniqueConstraintString(constraintName); + } + + @Override + @Deprecated + public boolean supportsNotNullUnique() { + return delegate.supportsNotNullUnique(); + } + + @Override + public String getQueryHintString(String query, List hints) { + return delegate.getQueryHintString(query, hints); + } + + @Override + public ScrollMode defaultScrollMode() { + return delegate.defaultScrollMode(); + } + + @Override + public boolean supportsTuplesInSubqueries() { + return delegate.supportsTuplesInSubqueries(); + } + + @Override + public CallableStatementSupport getCallableStatementSupport() { + return delegate.getCallableStatementSupport(); + } + + @Override + public NameQualifierSupport getNameQualifierSupport() { + return delegate.getNameQualifierSupport(); + } + + @Override + public BatchLoadSizingStrategy getDefaultBatchLoadSizingStrategy() { + return delegate.getDefaultBatchLoadSizingStrategy(); + } + + @Override + public boolean isJdbcLogWarningsEnabledByDefault() { + return delegate.isJdbcLogWarningsEnabledByDefault(); + } + + @Override + public void augmentRecognizedTableTypes(List tableTypesList) { + delegate.augmentRecognizedTableTypes(tableTypesList); + } + + @Override + public boolean supportsPartitionBy() { + // NOTE: we can't delegate because this is called in constructor + return false; + } +} diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53EntityManagerFactoryIntegrator.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53EntityManagerFactoryIntegrator.java new file mode 100644 index 0000000000..c5959d74d8 --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53EntityManagerFactoryIntegrator.java @@ -0,0 +1,102 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import com.blazebit.apt.service.ServiceProvider; +import com.blazebit.persistence.integration.hibernate.base.HibernateJpa21Provider; +import com.blazebit.persistence.integration.hibernate.base.function.AbstractHibernateEntityManagerFactoryIntegrator; +import com.blazebit.persistence.spi.EntityManagerFactoryIntegrator; +import com.blazebit.persistence.spi.JpaProvider; +import com.blazebit.persistence.spi.JpaProviderFactory; +import org.hibernate.Session; +import org.hibernate.dialect.Dialect; +import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.jpa.HibernateEntityManagerFactory; +import org.hibernate.persister.collection.CollectionPersister; +import org.hibernate.persister.entity.EntityPersister; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import java.util.Map; + +/** + * + * @author Christian Beikov + * @since 1.2.0 + */ +@ServiceProvider(EntityManagerFactoryIntegrator.class) +public class Hibernate53EntityManagerFactoryIntegrator extends AbstractHibernateEntityManagerFactoryIntegrator { + + @Override + public String getDbms(EntityManagerFactory entityManagerFactory) { + if (entityManagerFactory == null) { + return null; + } + + return getDbmsName(entityManagerFactory.unwrap(SessionFactoryImplementor.class).getDialect()); + } + + private String getDbms(EntityManager entityManager) { + if (entityManager == null) { + return null; + } + Session s = entityManager.unwrap(Session.class); + Dialect dialect = getDialect(s); + return getDbmsName(dialect); + } + + private Map getCollectionPersisters(EntityManager em) { + if (em == null) { + return null; + } + + return em.unwrap(SessionImplementor.class).getFactory().getCollectionPersisters(); + } + + private Map getEntityPersisters(EntityManager em) { + if (em == null) { + return null; + } + + return em.unwrap(SessionImplementor.class).getFactory().getEntityPersisters(); + } + + @Override + public JpaProviderFactory getJpaProviderFactory(final EntityManagerFactory entityManagerFactory) { + return new JpaProviderFactory() { + @Override + public JpaProvider createJpaProvider(EntityManager em) { + SessionFactoryImplementor factory = null; + if (em == null) { + if (entityManagerFactory instanceof SessionFactoryImplementor) { + factory = (SessionFactoryImplementor) entityManagerFactory; + } else if (entityManagerFactory instanceof HibernateEntityManagerFactory) { + factory = (SessionFactoryImplementor) ((HibernateEntityManagerFactory) entityManagerFactory).getSessionFactory(); + } + if (factory == null && entityManagerFactory != null) { + factory = entityManagerFactory.unwrap(SessionFactoryImplementor.class); + } + if (factory != null) { + return new HibernateJpa21Provider(getDbmsName(factory.getDialect()), factory.getEntityPersisters(), factory.getCollectionPersisters(), MAJOR, MINOR, FIX); + } + } + return new HibernateJpa21Provider(getDbms(em), getEntityPersisters(em), getCollectionPersisters(em), MAJOR, MINOR, FIX); + } + }; + } +} diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53Integrator.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53Integrator.java new file mode 100644 index 0000000000..68e8f2c5a9 --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53Integrator.java @@ -0,0 +1,80 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import com.blazebit.apt.service.ServiceProvider; +import com.blazebit.persistence.CTE; +import com.blazebit.persistence.integration.hibernate.base.Database; +import com.blazebit.persistence.integration.hibernate.base.MultiIterator; +import com.blazebit.persistence.integration.hibernate.base.SimpleDatabase; +import com.blazebit.persistence.integration.hibernate.base.TableNameFormatter; +import org.hibernate.boot.Metadata; +import org.hibernate.boot.model.relational.Namespace; +import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.integrator.spi.Integrator; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Table; +import org.hibernate.persister.spi.PersisterClassResolver; +import org.hibernate.service.spi.SessionFactoryServiceRegistry; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.logging.Logger; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +@ServiceProvider(Integrator.class) +public class Hibernate53Integrator implements Integrator { + + private static final Logger LOG = Logger.getLogger(Hibernate53Integrator.class.getName()); + + @Override + public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { + // TODO: remember metadata for exact column types + for (PersistentClass clazz : metadata.getEntityBindings()) { + Class entityClass = clazz.getMappedClass(); + + if (entityClass.isAnnotationPresent(CTE.class)) { + clazz.getTable().setSubselect("select * from " + clazz.getJpaEntityName()); + // TODO: check that no collections are mapped + } + } + + serviceRegistry.locateServiceBinding(PersisterClassResolver.class).setService(new CustomPersisterClassResolver()); + TableNameFormatter formatter = new NativeTableNameFormatter(sessionFactory.getJdbcServices().getJdbcEnvironment().getQualifiedObjectNameFormatter()); + serviceRegistry.locateServiceBinding(Database.class).setService(new SimpleDatabase(getTableIterator(metadata.getDatabase().getNamespaces()), sessionFactory.getDialect(), formatter, metadata)); + } + + private Iterator
getTableIterator(Iterable namespaces) { + List> iterators = new ArrayList<>(); + Iterator namespaceIterator = namespaces.iterator(); + + while (namespaceIterator.hasNext()) { + iterators.add(namespaceIterator.next().getTables().iterator()); + } + + return new MultiIterator<>(iterators); + } + + @Override + public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { + } + +} diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53LimitHandler.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53LimitHandler.java new file mode 100644 index 0000000000..c0a33e5ac7 --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53LimitHandler.java @@ -0,0 +1,81 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import com.blazebit.persistence.spi.DbmsDialect; +import com.blazebit.persistence.spi.DbmsLimitHandler; +import org.hibernate.dialect.Dialect; +import org.hibernate.dialect.pagination.LimitHandler; +import org.hibernate.engine.spi.RowSelection; + +import java.sql.PreparedStatement; +import java.sql.SQLException; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +public class Hibernate53LimitHandler implements LimitHandler { + + private final DbmsLimitHandler limitHandler; + private Integer limit; + private Integer offset; + + public Hibernate53LimitHandler(Dialect dialect, DbmsDialect dbmsDialect) { + this.limitHandler = dbmsDialect.createLimitHandler(); + } + + @Override + public boolean supportsLimit() { + return limitHandler.supportsLimit(); + } + + @Override + public boolean supportsLimitOffset() { + return limitHandler.supportsLimitOffset(); + } + + @Override + public String processSql(String sql, RowSelection selection) { + if (selection == null || selection.getMaxRows() == null || selection.getMaxRows().intValue() == Integer.MAX_VALUE) { + this.limit = null; + } else { + this.limit = selection.getMaxRows(); + } + if (selection == null || selection.getFirstRow() == null || selection.getFirstRow().intValue() < 1) { + this.offset = null; + } else { + this.offset = selection.getFirstRow(); + } + return limitHandler.applySql(sql, false, limit, offset); + } + + @Override + public int bindLimitParametersAtStartOfQuery(RowSelection selection, PreparedStatement statement, int index) throws SQLException { + return limitHandler.bindLimitParametersAtStartOfQuery(limit, offset, statement, index); + } + + @Override + public int bindLimitParametersAtEndOfQuery(RowSelection selection, PreparedStatement statement, int index) throws SQLException { + return limitHandler.bindLimitParametersAtEndOfQuery(limit, offset, statement, index); + } + + @Override + public void setMaxRows(RowSelection selection, PreparedStatement statement) throws SQLException { + limitHandler.setMaxRows(limit, offset, statement); + } +} diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53LimitHandlingDialect.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53LimitHandlingDialect.java new file mode 100644 index 0000000000..d6524d0305 --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53LimitHandlingDialect.java @@ -0,0 +1,41 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import com.blazebit.persistence.spi.DbmsDialect; +import org.hibernate.dialect.Dialect; +import org.hibernate.dialect.pagination.LimitHandler; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +public class Hibernate53LimitHandlingDialect extends Hibernate53DelegatingDialect { + + private final DbmsDialect dbmsDialect; + + public Hibernate53LimitHandlingDialect(Dialect delegate, DbmsDialect dbmsDialect) { + super(delegate); + this.dbmsDialect = dbmsDialect; + } + + @Override + public LimitHandler getLimitHandler() { + return new Hibernate53LimitHandler(this, dbmsDialect); + } + +} diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53MetadataContributor.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53MetadataContributor.java new file mode 100644 index 0000000000..bcb9a0b0c8 --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53MetadataContributor.java @@ -0,0 +1,88 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import org.hibernate.boot.internal.ClassLoaderAccessImpl; +import org.hibernate.boot.internal.MetadataBuildingContextRootImpl; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.spi.ClassLoaderAccess; +import org.hibernate.boot.spi.InFlightMetadataCollector; +import org.hibernate.boot.spi.MetadataBuildingContext; +import org.hibernate.boot.spi.MetadataBuildingOptions; +import org.hibernate.boot.spi.MetadataContributor; +import org.hibernate.cfg.AnnotationBinder; +import org.hibernate.cfg.InheritanceState; +import org.jboss.jandex.IndexView; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +public class Hibernate53MetadataContributor implements MetadataContributor { + + @Override + public void contribute(InFlightMetadataCollector metadataCollector, IndexView jandexIndex) { + // Skip if already registered + if (metadataCollector.getEntityBinding("com.blazebit.persistence.impl.function.entity.ValuesEntity") != null) { + return; + } + + MetadataBuildingOptions options = metadataCollector.getMetadataBuildingOptions(); + final ClassLoaderService classLoaderService = options.getServiceRegistry().getService( ClassLoaderService.class ); + + final ClassLoaderAccess classLoaderAccess = new ClassLoaderAccessImpl( + options.getTempClassLoader(), + classLoaderService + ); + + MetadataBuildingContext metadataBuildingContext = new MetadataBuildingContextRootImpl( + options, + classLoaderAccess, + metadataCollector); + + addEntity("com.blazebit.persistence.impl.function.entity.ValuesEntity", metadataBuildingContext); + } + + private void addEntity(String className, MetadataBuildingContext metadataBuildingContext) { + try { + MetadataBuildingOptions options = metadataBuildingContext.getBuildingOptions(); + Object /*ReflectionManager*/ reflectionManager = MetadataBuildingOptions.class.getMethod("getReflectionManager").invoke(options); + // Object /*XClass*/ clazz = reflectionManager.classForName(className); + Method classForName = reflectionManager.getClass().getMethod("classForName", String.class); + Object /*XClass*/ clazz = classForName.invoke(reflectionManager, className); + Map inheritanceStatePerClass = new HashMap(1); + + // InheritanceState state = new InheritanceState(clazz, inheritanceStatePerClass, metadataBuildingContext); + InheritanceState state = InheritanceState.class.getConstructor(classForName.getReturnType(), Map.class, MetadataBuildingContext.class) + .newInstance(clazz, inheritanceStatePerClass, metadataBuildingContext); + + inheritanceStatePerClass.put(clazz, state); + + // AnnotationBinder.bindClass(clazz, inheritanceStatePerClass, metadataBuildingContext); + AnnotationBinder.class.getMethod("bindClass", classForName.getReturnType(), Map.class, MetadataBuildingContext.class) + .invoke(null, clazz, inheritanceStatePerClass, metadataBuildingContext); + } catch (RuntimeException ex) { + throw ex; + } catch (Exception ex) { + throw new RuntimeException("Could not add entity", ex); + } + } +} diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53ServiceContributor.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53ServiceContributor.java new file mode 100644 index 0000000000..dca4b23ea0 --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53ServiceContributor.java @@ -0,0 +1,50 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import com.blazebit.apt.service.ServiceProvider; +import com.blazebit.persistence.integration.hibernate.base.Database; +import org.hibernate.boot.registry.StandardServiceInitiator; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.service.Service; +import org.hibernate.service.spi.ServiceContributor; +import org.hibernate.service.spi.ServiceRegistryImplementor; + +import java.util.Map; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +@ServiceProvider(ServiceContributor.class) +public class Hibernate53ServiceContributor implements ServiceContributor { + + @Override + public void contribute(StandardServiceRegistryBuilder serviceRegistryBuilder) { + serviceRegistryBuilder.addInitiator(new StandardServiceInitiator() { + @Override + public Service initiateService(Map configurationValues, ServiceRegistryImplementor registry) { + return null; + } + + @Override + public Class getServiceInitiated() { + return Database.class; + } + }); + } +} diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53SessionFactoryInvocationHandler.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53SessionFactoryInvocationHandler.java new file mode 100644 index 0000000000..6bc89029a7 --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53SessionFactoryInvocationHandler.java @@ -0,0 +1,47 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import org.hibernate.engine.spi.SessionFactoryImplementor; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +public class Hibernate53SessionFactoryInvocationHandler implements InvocationHandler { + + private final SessionFactoryImplementor delegate; + private final Object dialect; + + public Hibernate53SessionFactoryInvocationHandler(SessionFactoryImplementor delegate, Object dialect) { + this.delegate = delegate; + this.dialect = dialect; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + if ("getDialect".equals(method.getName())) { + return dialect; + } + + return method.invoke(delegate, args); + } + +} diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53SessionInvocationHandler.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53SessionInvocationHandler.java new file mode 100644 index 0000000000..1fa8826c6e --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate53SessionInvocationHandler.java @@ -0,0 +1,47 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import org.hibernate.engine.spi.SessionImplementor; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +public class Hibernate53SessionInvocationHandler implements InvocationHandler { + + private final SessionImplementor delegate; + private final Object jdbcCoordinatorProxy; + + public Hibernate53SessionInvocationHandler(SessionImplementor delegate, Object jdbcCoordinatorProxy) { + this.delegate = delegate; + this.jdbcCoordinatorProxy = jdbcCoordinatorProxy; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + if ("getJdbcCoordinator".equals(method.getName())) { + return jdbcCoordinatorProxy; + } + + return method.invoke(delegate, args); + } + +} diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/JdbcCoordinatorInvocationHandler.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/JdbcCoordinatorInvocationHandler.java new file mode 100644 index 0000000000..fead1a48ab --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/JdbcCoordinatorInvocationHandler.java @@ -0,0 +1,64 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import com.blazebit.persistence.integration.hibernate.base.HibernateReturningResult; +import com.blazebit.persistence.spi.DbmsDialect; +import org.hibernate.engine.jdbc.spi.JdbcCoordinator; +import org.hibernate.engine.jdbc.spi.StatementPreparer; +import org.hibernate.engine.spi.SessionFactoryImplementor; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +public class JdbcCoordinatorInvocationHandler implements InvocationHandler { + + private final JdbcCoordinator delegate; + private final SessionFactoryImplementor sessionFactoryImplementor; + private final DbmsDialect dbmsDialect; + private final String[][] columns; + private final int[] returningSqlTypes; + private final HibernateReturningResult returningResult; + private transient StatementPreparer statementPreparer; + + public JdbcCoordinatorInvocationHandler(JdbcCoordinator delegate, SessionFactoryImplementor sessionFactoryImplementor, DbmsDialect dbmsDialect, String[][] columns, int[] returningSqlTypes, HibernateReturningResult returningResult) { + this.delegate = delegate; + this.sessionFactoryImplementor = sessionFactoryImplementor; + this.dbmsDialect = dbmsDialect; + this.columns = columns; + this.returningSqlTypes = returningSqlTypes; + this.returningResult = returningResult; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + if ("getStatementPreparer".equals(method.getName())) { + if (statementPreparer == null) { + statementPreparer = new StatementPreparerImpl(delegate, sessionFactoryImplementor, dbmsDialect, columns, returningSqlTypes, returningResult); + } + + return statementPreparer; + } + + return method.invoke(delegate, args); + } + +} diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/NativeTableNameFormatter.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/NativeTableNameFormatter.java new file mode 100644 index 0000000000..69e234cee0 --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/NativeTableNameFormatter.java @@ -0,0 +1,41 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import com.blazebit.persistence.integration.hibernate.base.TableNameFormatter; +import org.hibernate.dialect.Dialect; +import org.hibernate.engine.jdbc.env.spi.QualifiedObjectNameFormatter; +import org.hibernate.mapping.Table; + +/** + * + * @author Christian Beikov + * @since 1.2.0 + */ +public class NativeTableNameFormatter implements TableNameFormatter { + + private final QualifiedObjectNameFormatter formatter; + + public NativeTableNameFormatter(QualifiedObjectNameFormatter formatter) { + this.formatter = formatter; + } + + @Override + public String getQualifiedTableName(Dialect dialect, Table table) { + return formatter.format(table.getQualifiedTableName(), dialect); + } +} diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/PreparedStatementInvocationHandler.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/PreparedStatementInvocationHandler.java new file mode 100644 index 0000000000..cd2449bdeb --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/PreparedStatementInvocationHandler.java @@ -0,0 +1,74 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import com.blazebit.persistence.integration.hibernate.base.HibernateReturningResult; +import com.blazebit.persistence.integration.hibernate.base.ResultSetInvocationHandler; +import com.blazebit.persistence.spi.DbmsDialect; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.HashMap; +import java.util.Map; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +public class PreparedStatementInvocationHandler implements InvocationHandler { + + private final PreparedStatement delegate; + private final DbmsDialect dbmsDialect; + private final Map aliasIndex; + private final HibernateReturningResult returningResult; + + public PreparedStatementInvocationHandler(PreparedStatement delegate, DbmsDialect dbmsDialect, String[][] columns, HibernateReturningResult returningResult) { + this.delegate = delegate; + this.dbmsDialect = dbmsDialect; + this.aliasIndex = new HashMap(columns.length); + this.returningResult = returningResult; + + for (int i = 0; i < columns.length; i++) { + aliasIndex.put(columns[i][1], i + 1); + } + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + if ("executeQuery".equals(method.getName()) && method.getParameterTypes().length == 0) { + ResultSet rs; + HibernateReturningResult result; + + if (delegate.execute()) { + rs = delegate.getResultSet(); + result = returningResult; + } else { + result = null; + returningResult.setUpdateCount(delegate.getUpdateCount()); + rs = dbmsDialect.extractReturningResult(delegate); + } + + return Proxy.newProxyInstance(rs.getClass().getClassLoader(), new Class[]{ ResultSet.class }, new ResultSetInvocationHandler(rs, aliasIndex, result)); + } + + return method.invoke(delegate, args); + } + +} diff --git a/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/StatementPreparerImpl.java b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/StatementPreparerImpl.java new file mode 100644 index 0000000000..4a23f83c4c --- /dev/null +++ b/integration/hibernate-5.3/src/main/java/com/blazebit/persistence/integration/hibernate/StatementPreparerImpl.java @@ -0,0 +1,200 @@ +/* + * Copyright 2014 - 2018 Blazebit. + * + * 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.blazebit.persistence.integration.hibernate; + +import com.blazebit.persistence.integration.hibernate.base.HibernateReturningResult; +import com.blazebit.persistence.spi.DbmsDialect; +import org.hibernate.ScrollMode; +import org.hibernate.boot.spi.SessionFactoryOptions; +import org.hibernate.engine.jdbc.spi.JdbcCoordinator; +import org.hibernate.engine.jdbc.spi.JdbcServices; +import org.hibernate.engine.jdbc.spi.SqlExceptionHelper; +import org.hibernate.engine.jdbc.spi.StatementPreparer; +import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor; + +import java.lang.reflect.Proxy; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Statement; + +/** + * @author Christian Beikov + * @since 1.2.0 + */ +public class StatementPreparerImpl implements StatementPreparer { + + private JdbcCoordinator jdbcCoordinator; + private SessionFactoryImplementor sessionFactoryImplementor; + private DbmsDialect dbmsDialect; + private String[][] columns; + private int[] returningSqlTypes; + private HibernateReturningResult returningResult; + + public StatementPreparerImpl(JdbcCoordinator jdbcCoordinator, SessionFactoryImplementor sessionFactoryImplementor, DbmsDialect dbmsDialect, String[][] columns, int[] returningSqlTypes, HibernateReturningResult returningResult) { + this.jdbcCoordinator = jdbcCoordinator; + this.sessionFactoryImplementor = sessionFactoryImplementor; + this.dbmsDialect = dbmsDialect; + this.columns = columns; + this.returningSqlTypes = returningSqlTypes; + this.returningResult = returningResult; + } + + protected final SessionFactoryOptions settings() { + return sessionFactoryImplementor.getSessionFactoryOptions(); + } + + protected final Connection connection() { + return logicalConnection().getPhysicalConnection(); + } + + protected final LogicalConnectionImplementor logicalConnection() { + return jdbcCoordinator.getLogicalConnection(); + } + + protected final SqlExceptionHelper sqlExceptionHelper() { + return getJdbcService().getSqlExceptionHelper(); + } + + @Override + public Statement createStatement() { + throw new UnsupportedOperationException("Not yet implemented!"); + } + + @Override + public PreparedStatement prepareStatement(String sql) { + throw new UnsupportedOperationException("Not yet implemented!"); + } + + @Override + public PreparedStatement prepareStatement(String sql, final boolean isCallable) { + throw new UnsupportedOperationException("Not yet implemented!"); + } + + private void checkAutoGeneratedKeysSupportEnabled() { + // Not sure if we should respect this +// if (!settings().isGetGeneratedKeysEnabled()) { +// throw new AssertionFailure("getGeneratedKeys() support is not enabled"); +// } + } + + @Override + public PreparedStatement prepareStatement(String sql, final int autoGeneratedKeys) { + throw new UnsupportedOperationException("Not yet implemented!"); + } + + @Override + public PreparedStatement prepareStatement(String sql, final String[] columnNames) { + throw new UnsupportedOperationException("Not yet implemented!"); + } + + @Override + public PreparedStatement prepareQueryStatement(String sql, final boolean isCallable, final ScrollMode scrollMode) { + checkAutoGeneratedKeysSupportEnabled(); + jdbcCoordinator.executeBatch(); + PreparedStatement ps = new QueryStatementPreparationTemplate(sql) { + + public PreparedStatement doPrepare() throws SQLException { + PreparedStatement ps; + ps = connection().prepareStatement(sql, dbmsDialect.getPrepareFlags()); + return dbmsDialect.prepare(ps, returningSqlTypes); + } + }.prepareStatement(); + ps = (PreparedStatement) Proxy.newProxyInstance(ps.getClass().getClassLoader(), new Class[]{PreparedStatement.class}, new PreparedStatementInvocationHandler(ps, dbmsDialect, columns, returningResult)); + jdbcCoordinator.registerLastQuery(ps); + return ps; + } + + /** + * @author Christian Beikov + * @since 1.2.0 + */ + private abstract class StatementPreparationTemplate { + + protected final String sql; + + protected StatementPreparationTemplate(String incomingSql) { + final String inspectedSql = jdbcCoordinator.getJdbcSessionOwner().getJdbcSessionContext().getStatementInspector().inspect(incomingSql); + this.sql = inspectedSql == null ? incomingSql : inspectedSql; + } + + public PreparedStatement prepareStatement() { + try { + getJdbcService().getSqlStatementLogger().logStatement(sql); + + final PreparedStatement preparedStatement; + try { + jdbcCoordinator.getJdbcSessionOwner().getJdbcSessionContext().getObserver().jdbcPrepareStatementStart(); + preparedStatement = doPrepare(); + setStatementTimeout(preparedStatement); + } finally { + jdbcCoordinator.getJdbcSessionOwner().getJdbcSessionContext().getObserver().jdbcPrepareStatementEnd(); + } + postProcess(preparedStatement); + return preparedStatement; + } catch (SQLException e) { + throw sqlExceptionHelper().convert(e, "could not prepare statement", sql); + } + } + + protected abstract PreparedStatement doPrepare() throws SQLException; + + public void postProcess(PreparedStatement preparedStatement) throws SQLException { + jdbcCoordinator.getResourceRegistry().register(preparedStatement, true); + // logicalConnection().notifyObserversStatementPrepared(); + } + + private void setStatementTimeout(PreparedStatement preparedStatement) throws SQLException { + final int remainingTransactionTimeOutPeriod = jdbcCoordinator.determineRemainingTransactionTimeOutPeriod(); + if (remainingTransactionTimeOutPeriod > 0) { + preparedStatement.setQueryTimeout(remainingTransactionTimeOutPeriod); + } + } + } + + private JdbcServices getJdbcService() { + return jdbcCoordinator + .getJdbcSessionOwner() + .getJdbcSessionContext() + .getServiceRegistry() + .getService(JdbcServices.class); + } + + /** + * @author Christian Beikov + * @since 1.2.0 + */ + private abstract class QueryStatementPreparationTemplate extends StatementPreparationTemplate { + + protected QueryStatementPreparationTemplate(String sql) { + super(sql); + } + + public void postProcess(PreparedStatement preparedStatement) throws SQLException { + super.postProcess(preparedStatement); + setStatementFetchSize(preparedStatement); + } + } + + private void setStatementFetchSize(PreparedStatement statement) throws SQLException { + if (settings().getJdbcFetchSize() != null) { + statement.setFetchSize(settings().getJdbcFetchSize()); + } + } + +} diff --git a/integration/hibernate-5.3/src/main/resources/META-INF/services/org.hibernate.boot.spi.MetadataContributor b/integration/hibernate-5.3/src/main/resources/META-INF/services/org.hibernate.boot.spi.MetadataContributor new file mode 100644 index 0000000000..ae1f7f3ebd --- /dev/null +++ b/integration/hibernate-5.3/src/main/resources/META-INF/services/org.hibernate.boot.spi.MetadataContributor @@ -0,0 +1,16 @@ +# +# Copyright 2014 - 2018 Blazebit. +# +# 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. +# +com.blazebit.persistence.integration.hibernate.Hibernate53MetadataContributor \ No newline at end of file diff --git a/integration/hibernate-5/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate5Access.java b/integration/hibernate-5/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate5Access.java index c75069be0d..69d7bf53a0 100644 --- a/integration/hibernate-5/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate5Access.java +++ b/integration/hibernate-5/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate5Access.java @@ -36,9 +36,11 @@ import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.TypedValue; import org.hibernate.event.spi.EventSource; +import org.hibernate.hql.internal.ast.ParameterTranslationsImpl; import org.hibernate.hql.internal.ast.exec.BasicExecutor; import org.hibernate.hql.internal.ast.exec.StatementExecutor; import org.hibernate.hql.internal.classic.ParserHelper; +import org.hibernate.hql.spi.ParameterTranslations; import org.hibernate.internal.util.StringHelper; import org.hibernate.loader.hql.QueryLoader; import org.hibernate.param.ParameterSpecification; @@ -313,4 +315,9 @@ public QueryParameters createQueryParameters( ); } + @Override + public ParameterTranslations createParameterTranslations(List queryParameterSpecifications) { + return new ParameterTranslationsImpl(queryParameterSpecifications); + } + } diff --git a/integration/hibernate-6.0/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate60Access.java b/integration/hibernate-6.0/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate60Access.java index ef72f8c0c0..35fb6e71f3 100644 --- a/integration/hibernate-6.0/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate60Access.java +++ b/integration/hibernate-6.0/src/main/java/com/blazebit/persistence/integration/hibernate/Hibernate60Access.java @@ -34,8 +34,10 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.TypedValue; import org.hibernate.event.spi.EventSource; +import org.hibernate.hql.internal.ast.ParameterTranslationsImpl; import org.hibernate.hql.internal.ast.exec.BasicExecutor; import org.hibernate.hql.internal.ast.exec.StatementExecutor; +import org.hibernate.hql.spi.ParameterTranslations; import org.hibernate.loader.hql.QueryLoader; import org.hibernate.param.ParameterSpecification; import org.hibernate.query.internal.AbstractProducedQuery; @@ -207,4 +209,9 @@ public QueryParameters createQueryParameters( ); } + @Override + public ParameterTranslations createParameterTranslations(List queryParameterSpecifications) { + return new ParameterTranslationsImpl(queryParameterSpecifications); + } + } diff --git a/integration/hibernate-base/src/main/java/com/blazebit/persistence/integration/hibernate/base/HibernateAccess.java b/integration/hibernate-base/src/main/java/com/blazebit/persistence/integration/hibernate/base/HibernateAccess.java index a2718141b2..2134e635b8 100644 --- a/integration/hibernate-base/src/main/java/com/blazebit/persistence/integration/hibernate/base/HibernateAccess.java +++ b/integration/hibernate-base/src/main/java/com/blazebit/persistence/integration/hibernate/base/HibernateAccess.java @@ -27,6 +27,7 @@ import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.TypedValue; import org.hibernate.hql.internal.ast.exec.StatementExecutor; +import org.hibernate.hql.spi.ParameterTranslations; import org.hibernate.loader.hql.QueryLoader; import org.hibernate.param.ParameterSpecification; import org.hibernate.type.Type; @@ -85,4 +86,6 @@ public QueryParameters createQueryParameters( final String comment, final List queryHints, final Serializable[] collectionKeys); + + public ParameterTranslations createParameterTranslations(List queryParameterSpecifications); } diff --git a/integration/hibernate-base/src/main/java/com/blazebit/persistence/integration/hibernate/base/HibernateExtendedQuerySupport.java b/integration/hibernate-base/src/main/java/com/blazebit/persistence/integration/hibernate/base/HibernateExtendedQuerySupport.java index b657d63ce6..2010e4bf6e 100644 --- a/integration/hibernate-base/src/main/java/com/blazebit/persistence/integration/hibernate/base/HibernateExtendedQuerySupport.java +++ b/integration/hibernate-base/src/main/java/com/blazebit/persistence/integration/hibernate/base/HibernateExtendedQuerySupport.java @@ -43,7 +43,6 @@ import org.hibernate.event.spi.EventType; import org.hibernate.hql.internal.QueryExecutionRequestException; import org.hibernate.hql.internal.antlr.SqlTokenTypes; -import org.hibernate.hql.internal.ast.ParameterTranslationsImpl; import org.hibernate.hql.internal.ast.exec.BasicExecutor; import org.hibernate.hql.internal.ast.exec.DeleteExecutor; import org.hibernate.hql.internal.ast.exec.StatementExecutor; @@ -893,7 +892,7 @@ private void prepareQueryPlan(HQLQueryPlan queryPlan, Listhibernate-4.3 hibernate-5 hibernate-5.2 + hibernate-5.3 hibernate-6.0 datanucleus + datanucleus-5.1 eclipselink openjpa entity-view-cdi diff --git a/integration/spring-data/1.x/pom.xml b/integration/spring-data/1.x/pom.xml index 42b40f2153..fd89cdc980 100644 --- a/integration/spring-data/1.x/pom.xml +++ b/integration/spring-data/1.x/pom.xml @@ -93,1275 +93,4 @@ - - - - h2 - - true - - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoH2,${jpa.excludedGroups} - - jdbc:h2:mem:test - admin - admin - org.h2.Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - com.h2database - h2 - test - - - - - mysql - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoMySQL,${jpa.excludedGroups} - - jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 - root - - com.mysql.jdbc.Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - mysql - mysql-connector-java - test - - - - - postgresql - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoPostgreSQL,${jpa.excludedGroups} - - jdbc:postgresql://localhost:5432/test - postgres - postgres - org.postgresql.Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - org.postgresql - postgresql - test - - - - - sqlite - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoSQLite,${jpa.excludedGroups} - - jdbc:sqlite:test.db - - - org.sqlite.JDBC - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - org.xerial - sqlite-jdbc - test - - - - - db2 - - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoDB2,${jpa.excludedGroups} - - jdbc:db2://localhost:50000/test - db2inst1 - db2inst1-pwd - com.ibm.db2.jcc.DB2Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - com.ibm.db2 - db2jcc4 - 9.7 - test - - - com.ibm.db2 - db2jcc_license_cu - 9.7 - test - - - - - firebird - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoFirebird,${jpa.excludedGroups} - - jdbc:firebirdsql:localhost:/tmp/test.fdb - SYSDBA - masterkey - org.firebirdsql.jdbc.FBDriver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - org.firebirdsql.jdbc - jaybird-jdk16 - test - - - - - oracle - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoOracle,${jpa.excludedGroups} - - jdbc:oracle:thin:@localhost:1521/xe - travis - travis - oracle.jdbc.driver.OracleDriver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - com.oracle - ojdbc14 - test - - - - - - - hibernate - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate42 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-4.2} - - - ${project.groupId} - blaze-persistence-integration-hibernate-4.2 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - 1.3.0.Final - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - ${processor.plugin.compilerArguments} - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - 1.3.0.Final - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-4.3 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate43 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-4.3} - - - ${project.groupId} - blaze-persistence-integration-hibernate-4.3 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-4.3} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-4.3} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-5.0 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate50 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-5} - - - ${project.groupId} - blaze-persistence-integration-hibernate-5 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-5.1 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate51 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-5.1} - - - ${project.groupId} - blaze-persistence-integration-hibernate-5 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.1} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.1} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-5.2 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate52 - hibernate - - - true - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-5.2} - - - ${project.groupId} - blaze-persistence-integration-hibernate-5.2 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.2} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.2} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-6.0 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate - hibernate - - - - JBoss Snapshots - JBoss Snapshots - http://repository.jboss.org/nexus/content/groups/public/ - - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-6.0} - - - ${project.groupId} - blaze-persistence-integration-hibernate-6.0 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-6.0} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-6.0} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - eclipselink - - com.blazebit.persistence.testsuite.base.jpa.category.NoEclipselink - eclipselink - -Xms1024m -Xmx2048m -javaagent:${project.build.directory}/agents/spring-instrumentation-agent.jar - - - - org.eclipse.persistence - eclipselink - ${version.eclipselink} - - - ${project.groupId} - blaze-persistence-testsuite-base-eclipselink - compile - - - - org.eclipse.persistence - org.eclipse.persistence.jpa.modelgen.processor - ${version.eclipselink} - provided - - - org.hibernate - hibernate-entitymanager - 3.6.10.Final - provided - - - jaxen - jaxen - 1.1.6 - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor - - - ${basedir}/src/main/resources/META-INF/persistence.xml - - - - - - - - org.eclipse.persistence - org.eclipse.persistence.jpa.modelgen.processor - ${version.eclipselink} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-agent - process-test-classes - - copy - - - - - org.springframework - spring-instrument - ${project.build.directory}/agents - spring-instrumentation-agent.jar - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - -javaagent:${project.build.directory}/agents/spring-instrumentation-agent.jar - - - - - - - datanucleus-4 - - com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus,com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus4 - datanucleus - - - - DataNucleus Nightly - DataNucleus Repository Nightly - http://www.datanucleus.org/downloads/maven2-nightly - - - - - org.datanucleus - javax.persistence - 2.1.2 - - - org.datanucleus - datanucleus-core - ${version.datanucleus.base-4} - - - org.datanucleus - datanucleus-api-jpa - ${version.datanucleus.api-jpa-4} - - - org.datanucleus - datanucleus-jpa-query - ${version.datanucleus.jpa-4} - - - org.datanucleus - datanucleus-rdbms - ${version.datanucleus.rdbms-4} - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - test - - - - - - org.datanucleus - datanucleus-maven-plugin - 4.0.0-release - - JPA - TEST-PU - false - true - ${basedir}/log4j.properties - ${project.build.testOutputDirectory} - true - - - - process-test-classes - - enhance - - - - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - ${project.version} - - - - - org.bsc.maven - maven-processor-plugin - - - process-test - - process-test - - generate-test-sources - - - ${project.build.directory}/test-metamodel - - org.datanucleus.jpa.query.JPACriteriaProcessor - - - - - - - - org.datanucleus - datanucleus-jpa-query - ${version.datanucleus.jpa-5} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-test-source-metamodel - generate-test-sources - - add-test-source - - - - ${project.build.directory}/test-metamodel - - - - - - - - - - datanucleus-5 - - com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus - datanucleus - - - - DataNucleus Nightly - DataNucleus Repository Nightly - http://www.datanucleus.org/downloads/maven2-nightly - - - - - org.datanucleus - javax.persistence - 2.1.2 - - - org.datanucleus - datanucleus-core - ${version.datanucleus.base-5} - - - org.datanucleus - datanucleus-api-jpa - ${version.datanucleus.api-jpa-5} - - - org.datanucleus - datanucleus-jpa-query - ${version.datanucleus.jpa-5} - - - org.datanucleus - datanucleus-rdbms - ${version.datanucleus.rdbms-5} - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - test - - - - - - org.datanucleus - datanucleus-maven-plugin - 4.0.0-release - - JPA - TEST-PU - false - true - ${basedir}/log4j.properties - ${project.build.testOutputDirectory} - true - - - - process-test-classes - - enhance - - - - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - ${project.version} - - - - - org.bsc.maven - maven-processor-plugin - - - process-test - - process-test - - generate-test-sources - - - ${project.build.directory}/test-metamodel - - org.datanucleus.jpa.query.JPACriteriaProcessor - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-test-source-metamodel - generate-test-sources - - add-test-source - - - - ${project.build.directory}/test-metamodel - - - - - - - - - - openjpa - - com.blazebit.persistence.testsuite.base.jpa.category.NoOpenJPA - openjpa - - - - org.apache.openjpa - openjpa-all - ${version.openjpa} - - - ${project.groupId} - blaze-persistence-testsuite-base-openjpa - compile - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.apache.openjpa.persistence.meta.AnnotationProcessor6 - - - true - - - - - - - org.apache.openjpa - openjpa-all - ${version.openjpa} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - - - - - - \ No newline at end of file diff --git a/integration/spring-data/2.x/pom.xml b/integration/spring-data/2.x/pom.xml index 3806879f38..56695368ff 100644 --- a/integration/spring-data/2.x/pom.xml +++ b/integration/spring-data/2.x/pom.xml @@ -95,1275 +95,4 @@ - - - - h2 - - true - - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoH2,${jpa.excludedGroups} - - jdbc:h2:mem:test - admin - admin - org.h2.Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - com.h2database - h2 - test - - - - - mysql - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoMySQL,${jpa.excludedGroups} - - jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 - root - - com.mysql.jdbc.Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - mysql - mysql-connector-java - test - - - - - postgresql - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoPostgreSQL,${jpa.excludedGroups} - - jdbc:postgresql://localhost:5432/test - postgres - postgres - org.postgresql.Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - org.postgresql - postgresql - test - - - - - sqlite - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoSQLite,${jpa.excludedGroups} - - jdbc:sqlite:test.db - - - org.sqlite.JDBC - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - org.xerial - sqlite-jdbc - test - - - - - db2 - - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoDB2,${jpa.excludedGroups} - - jdbc:db2://localhost:50000/test - db2inst1 - db2inst1-pwd - com.ibm.db2.jcc.DB2Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - com.ibm.db2 - db2jcc4 - 9.7 - test - - - com.ibm.db2 - db2jcc_license_cu - 9.7 - test - - - - - firebird - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoFirebird,${jpa.excludedGroups} - - jdbc:firebirdsql:localhost:/tmp/test.fdb - SYSDBA - masterkey - org.firebirdsql.jdbc.FBDriver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - org.firebirdsql.jdbc - jaybird-jdk16 - test - - - - - oracle - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoOracle,${jpa.excludedGroups} - - jdbc:oracle:thin:@localhost:1521/xe - travis - travis - oracle.jdbc.driver.OracleDriver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - com.oracle - ojdbc14 - test - - - - - - - hibernate - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate42 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-4.2} - - - ${project.groupId} - blaze-persistence-integration-hibernate-4.2 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - 1.3.0.Final - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - ${processor.plugin.compilerArguments} - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - 1.3.0.Final - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-4.3 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate43 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-4.3} - - - ${project.groupId} - blaze-persistence-integration-hibernate-4.3 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-4.3} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-4.3} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-5.0 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate50 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-5} - - - ${project.groupId} - blaze-persistence-integration-hibernate-5 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-5.1 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate51 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-5.1} - - - ${project.groupId} - blaze-persistence-integration-hibernate-5 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.1} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.1} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-5.2 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate52 - hibernate - - - true - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-5.2} - - - ${project.groupId} - blaze-persistence-integration-hibernate-5.2 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.2} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.2} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-6.0 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate - hibernate - - - - JBoss Snapshots - JBoss Snapshots - http://repository.jboss.org/nexus/content/groups/public/ - - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-6.0} - - - ${project.groupId} - blaze-persistence-integration-hibernate-6.0 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-6.0} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-6.0} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - eclipselink - - com.blazebit.persistence.testsuite.base.jpa.category.NoEclipselink - eclipselink - -Xms1024m -Xmx2048m -javaagent:${project.build.directory}/agents/spring-instrumentation-agent.jar - - - - org.eclipse.persistence - eclipselink - ${version.eclipselink} - - - ${project.groupId} - blaze-persistence-testsuite-base-eclipselink - compile - - - - org.eclipse.persistence - org.eclipse.persistence.jpa.modelgen.processor - ${version.eclipselink} - provided - - - org.hibernate - hibernate-entitymanager - 3.6.10.Final - provided - - - jaxen - jaxen - 1.1.6 - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor - - - ${basedir}/src/main/resources/META-INF/persistence.xml - - - - - - - - org.eclipse.persistence - org.eclipse.persistence.jpa.modelgen.processor - ${version.eclipselink} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-agent - process-test-classes - - copy - - - - - org.springframework - spring-instrument - ${project.build.directory}/agents - spring-instrumentation-agent.jar - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - -javaagent:${project.build.directory}/agents/spring-instrumentation-agent.jar - - - - - - - datanucleus-4 - - com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus,com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus4 - datanucleus - - - - DataNucleus Nightly - DataNucleus Repository Nightly - http://www.datanucleus.org/downloads/maven2-nightly - - - - - org.datanucleus - javax.persistence - 2.1.2 - - - org.datanucleus - datanucleus-core - ${version.datanucleus.base-4} - - - org.datanucleus - datanucleus-api-jpa - ${version.datanucleus.api-jpa-4} - - - org.datanucleus - datanucleus-jpa-query - ${version.datanucleus.jpa-4} - - - org.datanucleus - datanucleus-rdbms - ${version.datanucleus.rdbms-4} - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - test - - - - - - org.datanucleus - datanucleus-maven-plugin - 4.0.0-release - - JPA - TEST-PU - false - true - ${basedir}/log4j.properties - ${project.build.testOutputDirectory} - true - - - - process-test-classes - - enhance - - - - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - ${project.version} - - - - - org.bsc.maven - maven-processor-plugin - - - process-test - - process-test - - generate-test-sources - - - ${project.build.directory}/test-metamodel - - org.datanucleus.jpa.query.JPACriteriaProcessor - - - - - - - - org.datanucleus - datanucleus-jpa-query - ${version.datanucleus.jpa-5} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-test-source-metamodel - generate-test-sources - - add-test-source - - - - ${project.build.directory}/test-metamodel - - - - - - - - - - datanucleus-5 - - com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus - datanucleus - - - - DataNucleus Nightly - DataNucleus Repository Nightly - http://www.datanucleus.org/downloads/maven2-nightly - - - - - org.datanucleus - javax.persistence - 2.1.2 - - - org.datanucleus - datanucleus-core - ${version.datanucleus.base-5} - - - org.datanucleus - datanucleus-api-jpa - ${version.datanucleus.api-jpa-5} - - - org.datanucleus - datanucleus-jpa-query - ${version.datanucleus.jpa-5} - - - org.datanucleus - datanucleus-rdbms - ${version.datanucleus.rdbms-5} - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - test - - - - - - org.datanucleus - datanucleus-maven-plugin - 4.0.0-release - - JPA - TEST-PU - false - true - ${basedir}/log4j.properties - ${project.build.testOutputDirectory} - true - - - - process-test-classes - - enhance - - - - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - ${project.version} - - - - - org.bsc.maven - maven-processor-plugin - - - process-test - - process-test - - generate-test-sources - - - ${project.build.directory}/test-metamodel - - org.datanucleus.jpa.query.JPACriteriaProcessor - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-test-source-metamodel - generate-test-sources - - add-test-source - - - - ${project.build.directory}/test-metamodel - - - - - - - - - - openjpa - - com.blazebit.persistence.testsuite.base.jpa.category.NoOpenJPA - openjpa - - - - org.apache.openjpa - openjpa-all - ${version.openjpa} - - - ${project.groupId} - blaze-persistence-testsuite-base-openjpa - compile - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.apache.openjpa.persistence.meta.AnnotationProcessor6 - - - true - - - - - - - org.apache.openjpa - openjpa-all - ${version.openjpa} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - - - - - - \ No newline at end of file diff --git a/integration/spring-data/base/pom.xml b/integration/spring-data/base/pom.xml index 20db9f8ad7..b8350cb366 100644 --- a/integration/spring-data/base/pom.xml +++ b/integration/spring-data/base/pom.xml @@ -81,1275 +81,6 @@ - - - h2 - - true - - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoH2,${jpa.excludedGroups} - - jdbc:h2:mem:test - admin - admin - org.h2.Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - com.h2database - h2 - test - - - - - mysql - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoMySQL,${jpa.excludedGroups} - - jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 - root - - com.mysql.jdbc.Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - mysql - mysql-connector-java - test - - - - - postgresql - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoPostgreSQL,${jpa.excludedGroups} - - jdbc:postgresql://localhost:5432/test - postgres - postgres - org.postgresql.Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - org.postgresql - postgresql - test - - - - - sqlite - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoSQLite,${jpa.excludedGroups} - - jdbc:sqlite:test.db - - - org.sqlite.JDBC - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - org.xerial - sqlite-jdbc - test - - - - - db2 - - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoDB2,${jpa.excludedGroups} - - jdbc:db2://localhost:50000/test - db2inst1 - db2inst1-pwd - com.ibm.db2.jcc.DB2Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - com.ibm.db2 - db2jcc4 - 9.7 - test - - - com.ibm.db2 - db2jcc_license_cu - 9.7 - test - - - - - firebird - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoFirebird,${jpa.excludedGroups} - - jdbc:firebirdsql:localhost:/tmp/test.fdb - SYSDBA - masterkey - org.firebirdsql.jdbc.FBDriver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - org.firebirdsql.jdbc - jaybird-jdk16 - test - - - - - oracle - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoOracle,${jpa.excludedGroups} - - jdbc:oracle:thin:@localhost:1521/xe - travis - travis - oracle.jdbc.driver.OracleDriver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - com.oracle - ojdbc14 - test - - - - - - - hibernate - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate42 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-4.2} - - - ${project.groupId} - blaze-persistence-integration-hibernate-4.2 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - 1.3.0.Final - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - ${processor.plugin.compilerArguments} - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - 1.3.0.Final - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-4.3 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate43 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-4.3} - - - ${project.groupId} - blaze-persistence-integration-hibernate-4.3 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-4.3} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-4.3} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-5.0 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate50 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-5} - - - ${project.groupId} - blaze-persistence-integration-hibernate-5 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-5.1 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate51 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-5.1} - - - ${project.groupId} - blaze-persistence-integration-hibernate-5 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.1} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.1} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-5.2 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate52 - hibernate - - - true - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-5.2} - - - ${project.groupId} - blaze-persistence-integration-hibernate-5.2 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.2} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.2} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-6.0 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate - hibernate - - - - JBoss Snapshots - JBoss Snapshots - http://repository.jboss.org/nexus/content/groups/public/ - - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-6.0} - - - ${project.groupId} - blaze-persistence-integration-hibernate-6.0 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-6.0} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-6.0} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - eclipselink - - com.blazebit.persistence.testsuite.base.jpa.category.NoEclipselink - eclipselink - -Xms1024m -Xmx2048m -javaagent:${project.build.directory}/agents/spring-instrumentation-agent.jar - - - - org.eclipse.persistence - eclipselink - ${version.eclipselink} - - - ${project.groupId} - blaze-persistence-testsuite-base-eclipselink - compile - - - - org.eclipse.persistence - org.eclipse.persistence.jpa.modelgen.processor - ${version.eclipselink} - provided - - - org.hibernate - hibernate-entitymanager - 3.6.10.Final - provided - - - jaxen - jaxen - 1.1.6 - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor - - - ${basedir}/src/main/resources/META-INF/persistence.xml - - - - - - - - org.eclipse.persistence - org.eclipse.persistence.jpa.modelgen.processor - ${version.eclipselink} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-agent - process-test-classes - - copy - - - - - org.springframework - spring-instrument - ${project.build.directory}/agents - spring-instrumentation-agent.jar - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - -javaagent:${project.build.directory}/agents/spring-instrumentation-agent.jar - - - - - - - datanucleus-4 - - com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus,com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus4 - datanucleus - - - - DataNucleus Nightly - DataNucleus Repository Nightly - http://www.datanucleus.org/downloads/maven2-nightly - - - - - org.datanucleus - javax.persistence - 2.1.2 - - - org.datanucleus - datanucleus-core - ${version.datanucleus.base-4} - - - org.datanucleus - datanucleus-api-jpa - ${version.datanucleus.api-jpa-4} - - - org.datanucleus - datanucleus-jpa-query - ${version.datanucleus.jpa-4} - - - org.datanucleus - datanucleus-rdbms - ${version.datanucleus.rdbms-4} - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - test - - - - - - org.datanucleus - datanucleus-maven-plugin - 4.0.0-release - - JPA - TEST-PU - false - true - ${basedir}/log4j.properties - ${project.build.testOutputDirectory} - true - - - - process-test-classes - - enhance - - - - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - ${project.version} - - - - - org.bsc.maven - maven-processor-plugin - - - process-test - - process-test - - generate-test-sources - - - ${project.build.directory}/test-metamodel - - org.datanucleus.jpa.query.JPACriteriaProcessor - - - - - - - - org.datanucleus - datanucleus-jpa-query - ${version.datanucleus.jpa-5} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-test-source-metamodel - generate-test-sources - - add-test-source - - - - ${project.build.directory}/test-metamodel - - - - - - - - - - datanucleus-5 - - com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus - datanucleus - - - - DataNucleus Nightly - DataNucleus Repository Nightly - http://www.datanucleus.org/downloads/maven2-nightly - - - - - org.datanucleus - javax.persistence - 2.1.2 - - - org.datanucleus - datanucleus-core - ${version.datanucleus.base-5} - - - org.datanucleus - datanucleus-api-jpa - ${version.datanucleus.api-jpa-5} - - - org.datanucleus - datanucleus-jpa-query - ${version.datanucleus.jpa-5} - - - org.datanucleus - datanucleus-rdbms - ${version.datanucleus.rdbms-5} - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - test - - - - - - org.datanucleus - datanucleus-maven-plugin - 4.0.0-release - - JPA - TEST-PU - false - true - ${basedir}/log4j.properties - ${project.build.testOutputDirectory} - true - - - - process-test-classes - - enhance - - - - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - ${project.version} - - - - - org.bsc.maven - maven-processor-plugin - - - process-test - - process-test - - generate-test-sources - - - ${project.build.directory}/test-metamodel - - org.datanucleus.jpa.query.JPACriteriaProcessor - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-test-source-metamodel - generate-test-sources - - add-test-source - - - - ${project.build.directory}/test-metamodel - - - - - - - - - - openjpa - - com.blazebit.persistence.testsuite.base.jpa.category.NoOpenJPA - openjpa - - - - org.apache.openjpa - openjpa-all - ${version.openjpa} - - - ${project.groupId} - blaze-persistence-testsuite-base-openjpa - compile - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.apache.openjpa.persistence.meta.AnnotationProcessor6 - - - true - - - - - - - org.apache.openjpa - openjpa-all - ${version.openjpa} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - - - - - spring-data-1.11.x diff --git a/integration/spring-data/rest/pom.xml b/integration/spring-data/rest/pom.xml index 9dc5ac32aa..ba1986896f 100644 --- a/integration/spring-data/rest/pom.xml +++ b/integration/spring-data/rest/pom.xml @@ -63,1275 +63,6 @@ - - - h2 - - true - - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoH2,${jpa.excludedGroups} - - jdbc:h2:mem:test - admin - admin - org.h2.Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - com.h2database - h2 - test - - - - - mysql - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoMySQL,${jpa.excludedGroups} - - jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 - root - - com.mysql.jdbc.Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - mysql - mysql-connector-java - test - - - - - postgresql - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoPostgreSQL,${jpa.excludedGroups} - - jdbc:postgresql://localhost:5432/test - postgres - postgres - org.postgresql.Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - org.postgresql - postgresql - test - - - - - sqlite - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoSQLite,${jpa.excludedGroups} - - jdbc:sqlite:test.db - - - org.sqlite.JDBC - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - org.xerial - sqlite-jdbc - test - - - - - db2 - - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoDB2,${jpa.excludedGroups} - - jdbc:db2://localhost:50000/test - db2inst1 - db2inst1-pwd - com.ibm.db2.jcc.DB2Driver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - com.ibm.db2 - db2jcc4 - 9.7 - test - - - com.ibm.db2 - db2jcc_license_cu - 9.7 - test - - - - - firebird - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoFirebird,${jpa.excludedGroups} - - jdbc:firebirdsql:localhost:/tmp/test.fdb - SYSDBA - masterkey - org.firebirdsql.jdbc.FBDriver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - org.firebirdsql.jdbc - jaybird-jdk16 - test - - - - - oracle - - - - org.apache.maven.plugins - maven-surefire-plugin - - com.blazebit.persistence.testsuite.base.jpa.category.NoOracle,${jpa.excludedGroups} - - jdbc:oracle:thin:@localhost:1521/xe - travis - travis - oracle.jdbc.driver.OracleDriver - ${spring.activeProfiles} - - - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - - - - - - com.oracle - ojdbc14 - test - - - - - - - hibernate - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate42 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-4.2} - - - ${project.groupId} - blaze-persistence-integration-hibernate-4.2 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - 1.3.0.Final - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - ${processor.plugin.compilerArguments} - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - 1.3.0.Final - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-4.3 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate43 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-4.3} - - - ${project.groupId} - blaze-persistence-integration-hibernate-4.3 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-4.3} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-4.3} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-5.0 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate50 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-5} - - - ${project.groupId} - blaze-persistence-integration-hibernate-5 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-5.1 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate51 - hibernate - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-5.1} - - - ${project.groupId} - blaze-persistence-integration-hibernate-5 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.1} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.1} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-5.2 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate52 - hibernate - - - true - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-5.2} - - - ${project.groupId} - blaze-persistence-integration-hibernate-5.2 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.2} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-5.2} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - hibernate-6.0 - - com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate - hibernate - - - - JBoss Snapshots - JBoss Snapshots - http://repository.jboss.org/nexus/content/groups/public/ - - - - - org.hibernate - hibernate-entitymanager - ${version.hibernate-6.0} - - - ${project.groupId} - blaze-persistence-integration-hibernate-6.0 - test - - - ${project.groupId} - blaze-persistence-testsuite-base-hibernate - compile - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-6.0} - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor - - - - - - - - org.hibernate - hibernate-jpamodelgen - ${version.hibernate-6.0} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - add-test-source-hibernate - generate-test-sources - - add-test-source - - - - src/test/hibernate - - - - - - - - - - eclipselink - - com.blazebit.persistence.testsuite.base.jpa.category.NoEclipselink - eclipselink - -Xms1024m -Xmx2048m -javaagent:${project.build.directory}/agents/spring-instrumentation-agent.jar - - - - org.eclipse.persistence - eclipselink - ${version.eclipselink} - - - ${project.groupId} - blaze-persistence-testsuite-base-eclipselink - compile - - - - org.eclipse.persistence - org.eclipse.persistence.jpa.modelgen.processor - ${version.eclipselink} - provided - - - org.hibernate - hibernate-entitymanager - 3.6.10.Final - provided - - - jaxen - jaxen - 1.1.6 - provided - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor - - - ${basedir}/src/main/resources/META-INF/persistence.xml - - - - - - - - org.eclipse.persistence - org.eclipse.persistence.jpa.modelgen.processor - ${version.eclipselink} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-agent - process-test-classes - - copy - - - - - org.springframework - spring-instrument - ${project.build.directory}/agents - spring-instrumentation-agent.jar - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - -javaagent:${project.build.directory}/agents/spring-instrumentation-agent.jar - - - - - - - datanucleus-4 - - com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus,com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus4 - datanucleus - - - - DataNucleus Nightly - DataNucleus Repository Nightly - http://www.datanucleus.org/downloads/maven2-nightly - - - - - org.datanucleus - javax.persistence - 2.1.2 - - - org.datanucleus - datanucleus-core - ${version.datanucleus.base-4} - - - org.datanucleus - datanucleus-api-jpa - ${version.datanucleus.api-jpa-4} - - - org.datanucleus - datanucleus-jpa-query - ${version.datanucleus.jpa-4} - - - org.datanucleus - datanucleus-rdbms - ${version.datanucleus.rdbms-4} - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - test - - - - - - org.datanucleus - datanucleus-maven-plugin - 4.0.0-release - - JPA - TEST-PU - false - true - ${basedir}/log4j.properties - ${project.build.testOutputDirectory} - true - - - - process-test-classes - - enhance - - - - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - ${project.version} - - - - - org.bsc.maven - maven-processor-plugin - - - process-test - - process-test - - generate-test-sources - - - ${project.build.directory}/test-metamodel - - org.datanucleus.jpa.query.JPACriteriaProcessor - - - - - - - - org.datanucleus - datanucleus-jpa-query - ${version.datanucleus.jpa-5} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-test-source-metamodel - generate-test-sources - - add-test-source - - - - ${project.build.directory}/test-metamodel - - - - - - - - - - datanucleus-5 - - com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus - datanucleus - - - - DataNucleus Nightly - DataNucleus Repository Nightly - http://www.datanucleus.org/downloads/maven2-nightly - - - - - org.datanucleus - javax.persistence - 2.1.2 - - - org.datanucleus - datanucleus-core - ${version.datanucleus.base-5} - - - org.datanucleus - datanucleus-api-jpa - ${version.datanucleus.api-jpa-5} - - - org.datanucleus - datanucleus-jpa-query - ${version.datanucleus.jpa-5} - - - org.datanucleus - datanucleus-rdbms - ${version.datanucleus.rdbms-5} - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - test - - - - - - org.datanucleus - datanucleus-maven-plugin - 4.0.0-release - - JPA - TEST-PU - false - true - ${basedir}/log4j.properties - ${project.build.testOutputDirectory} - true - - - - process-test-classes - - enhance - - - - - - ${project.groupId} - blaze-persistence-testsuite-base-datanucleus - ${project.version} - - - - - org.bsc.maven - maven-processor-plugin - - - process-test - - process-test - - generate-test-sources - - - ${project.build.directory}/test-metamodel - - org.datanucleus.jpa.query.JPACriteriaProcessor - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-test-source-metamodel - generate-test-sources - - add-test-source - - - - ${project.build.directory}/test-metamodel - - - - - - - - - - openjpa - - com.blazebit.persistence.testsuite.base.jpa.category.NoOpenJPA - openjpa - - - - org.apache.openjpa - openjpa-all - ${version.openjpa} - - - ${project.groupId} - blaze-persistence-testsuite-base-openjpa - compile - - - - - - org.bsc.maven - maven-processor-plugin - - - process - - process - - generate-sources - - - ${project.build.directory}/test-metamodel - - org.apache.openjpa.persistence.meta.AnnotationProcessor6 - - - true - - - - - - - org.apache.openjpa - openjpa-all - ${version.openjpa} - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/test-metamodel - - - - - - - - - spring-data-1.11.x diff --git a/integration/spring-data/testsuite/pom.xml b/integration/spring-data/testsuite/pom.xml index 66bcab2747..5cfc298328 100644 --- a/integration/spring-data/testsuite/pom.xml +++ b/integration/spring-data/testsuite/pom.xml @@ -78,6 +78,28 @@ junit test + + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.annotation + javax.annotation-api + ${version.annotation} + @@ -387,7 +409,6 @@ generate-sources - ${processor.plugin.compilerArguments} ${project.build.directory}/test-metamodel @@ -403,6 +424,31 @@ hibernate-jpamodelgen 1.3.0.Final + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -496,6 +542,31 @@ hibernate-jpamodelgen ${version.hibernate-4.3} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -589,6 +660,31 @@ hibernate-jpamodelgen ${version.hibernate-5} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -682,6 +778,31 @@ hibernate-jpamodelgen ${version.hibernate-5.1} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -778,6 +899,149 @@ hibernate-jpamodelgen ${version.hibernate-5.2} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/test-metamodel + + + + + add-test-source-hibernate + generate-test-sources + + add-test-source + + + + src/test/hibernate + + + + + + + + + + hibernate-5.3 + + com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate52 + hibernate + + + + org.hibernate + hibernate-entitymanager + ${version.hibernate-5.3} + + + ${project.groupId} + blaze-persistence-integration-hibernate-5.3 + test + + + ${project.groupId} + blaze-persistence-testsuite-base-hibernate + compile + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5.3} + provided + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/test-metamodel + + org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor + + + + + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5.3} + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -878,6 +1142,31 @@ hibernate-jpamodelgen ${version.hibernate-6.0} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -982,6 +1271,31 @@ org.eclipse.persistence.jpa.modelgen.processor ${version.eclipselink} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -1080,6 +1394,10 @@ blaze-persistence-testsuite-base-datanucleus test + + ${project.groupId} + blaze-persistence-integration-datanucleus + @@ -1110,6 +1428,10 @@ blaze-persistence-testsuite-base-datanucleus ${project.version} + + ${project.groupId} + blaze-persistence-integration-datanucleus + @@ -1138,6 +1460,31 @@ datanucleus-jpa-query ${version.datanucleus.jpa-5} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -1205,6 +1552,10 @@ blaze-persistence-testsuite-base-datanucleus test + + ${project.groupId} + blaze-persistence-integration-datanucleus + @@ -1235,6 +1586,10 @@ blaze-persistence-testsuite-base-datanucleus ${project.version} + + ${project.groupId} + blaze-persistence-integration-datanucleus + @@ -1256,6 +1611,33 @@ + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + org.codehaus.mojo @@ -1278,6 +1660,160 @@ + + datanucleus-5.1 + + com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus + datanucleus + + + + DataNucleus Nightly + DataNucleus Repository Nightly + http://www.datanucleus.org/downloads/maven2-nightly + + + + + org.datanucleus + javax.persistence + 2.2.0-release + + + org.datanucleus + datanucleus-core + ${version.datanucleus.base-5.1} + + + org.datanucleus + datanucleus-api-jpa + ${version.datanucleus.api-jpa-5.1} + + + org.datanucleus + datanucleus-jpa-query + ${version.datanucleus.jpa-5.1} + + + org.datanucleus + datanucleus-rdbms + ${version.datanucleus.rdbms-5.1} + + + ${project.groupId} + blaze-persistence-testsuite-base-datanucleus + compile + + + ${project.groupId} + blaze-persistence-integration-datanucleus-5.1 + + + + + + org.datanucleus + datanucleus-maven-plugin + 4.0.0-release + + JPA + TestsuiteBase + false + true + ${basedir}/log4j.properties + ${project.build.outputDirectory} + true + + + + process-classes + + enhance + + + + + + ${project.groupId} + blaze-persistence-testsuite-base-datanucleus + ${project.version} + + + ${project.groupId} + blaze-persistence-integration-datanucleus-5.1 + ${project.version} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${additional.source.directory} + ${project.build.directory}/generated-sources/metamodel + + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/generated-sources/metamodel + + org.datanucleus.jpa.query.JPACriteriaProcessor + + + + + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + + openjpa @@ -1326,6 +1862,31 @@ openjpa-all ${version.openjpa} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + diff --git a/jpa-criteria/testsuite/pom.xml b/jpa-criteria/testsuite/pom.xml index b5939bb9e5..f855b0cf56 100644 --- a/jpa-criteria/testsuite/pom.xml +++ b/jpa-criteria/testsuite/pom.xml @@ -100,6 +100,28 @@ h2 test + + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.annotation + javax.annotation-api + ${version.annotation} + @@ -195,6 +217,31 @@ hibernate-jpamodelgen 1.3.0.Final + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -275,6 +322,31 @@ hibernate-jpamodelgen ${version.hibernate-4.3} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -355,6 +427,31 @@ hibernate-jpamodelgen ${version.hibernate-5} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -435,6 +532,31 @@ hibernate-jpamodelgen ${version.hibernate-5.1} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -518,6 +640,136 @@ hibernate-jpamodelgen ${version.hibernate-5.2} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-test-source-metamodel + generate-test-sources + + add-test-source + + + + ${project.build.directory}/test-metamodel + + + + + + + + + + hibernate-5.3 + + com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate,com.blazebit.persistence.testsuite.base.jpa.category.NoHibernate52 + + + + org.hibernate + hibernate-entitymanager + ${version.hibernate-5.3} + + + ${project.groupId} + blaze-persistence-integration-hibernate-5.3 + test + + + ${project.groupId} + blaze-persistence-testsuite-base-hibernate + test + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5.3} + provided + + + + + + org.bsc.maven + maven-processor-plugin + + + process-test + + process-test + + generate-test-sources + + + ${project.build.directory}/test-metamodel + + org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor + + + + + + + + org.hibernate + hibernate-jpamodelgen + ${version.hibernate-5.3} + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -605,6 +857,31 @@ hibernate-jpamodelgen ${version.hibernate-6.0} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -683,6 +960,31 @@ org.eclipse.persistence.jpa.modelgen.processor ${version.eclipselink} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -749,6 +1051,10 @@ blaze-persistence-testsuite-base-datanucleus test + + ${project.groupId} + blaze-persistence-integration-datanucleus + @@ -779,6 +1085,10 @@ blaze-persistence-testsuite-base-datanucleus ${project.version} + + ${project.groupId} + blaze-persistence-integration-datanucleus + @@ -807,6 +1117,31 @@ datanucleus-jpa-query ${version.datanucleus.jpa-5} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + @@ -873,6 +1208,10 @@ blaze-persistence-testsuite-base-datanucleus test + + ${project.groupId} + blaze-persistence-integration-datanucleus + @@ -903,6 +1242,10 @@ blaze-persistence-testsuite-base-datanucleus ${project.version} + + ${project.groupId} + blaze-persistence-integration-datanucleus + @@ -924,6 +1267,33 @@ + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + org.codehaus.mojo @@ -946,6 +1316,160 @@ + + datanucleus-5.1 + + com.blazebit.persistence.testsuite.base.jpa.category.NoDatanucleus + datanucleus + + + + DataNucleus Nightly + DataNucleus Repository Nightly + http://www.datanucleus.org/downloads/maven2-nightly + + + + + org.datanucleus + javax.persistence + 2.2.0-release + + + org.datanucleus + datanucleus-core + ${version.datanucleus.base-5.1} + + + org.datanucleus + datanucleus-api-jpa + ${version.datanucleus.api-jpa-5.1} + + + org.datanucleus + datanucleus-jpa-query + ${version.datanucleus.jpa-5.1} + + + org.datanucleus + datanucleus-rdbms + ${version.datanucleus.rdbms-5.1} + + + ${project.groupId} + blaze-persistence-testsuite-base-datanucleus + compile + + + ${project.groupId} + blaze-persistence-integration-datanucleus-5.1 + + + + + + org.datanucleus + datanucleus-maven-plugin + 4.0.0-release + + JPA + TestsuiteBase + false + true + ${basedir}/log4j.properties + ${project.build.outputDirectory} + true + + + + process-classes + + enhance + + + + + + ${project.groupId} + blaze-persistence-testsuite-base-datanucleus + ${project.version} + + + ${project.groupId} + blaze-persistence-integration-datanucleus-5.1 + ${project.version} + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${additional.source.directory} + ${project.build.directory}/generated-sources/metamodel + + + + + + + org.bsc.maven + maven-processor-plugin + + + process + + process + + generate-sources + + + ${project.build.directory}/generated-sources/metamodel + + org.datanucleus.jpa.query.JPACriteriaProcessor + + + + + + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + + + + + + openjpa @@ -999,6 +1523,31 @@ openjpa-all ${version.openjpa} + + javax.xml.bind + jaxb-api + ${version.jaxb} + + + com.sun.xml.bind + jaxb-core + ${version.jaxb} + + + com.sun.xml.bind + jaxb-impl + ${version.jaxb} + + + javax.transaction + javax.transaction-api + ${version.jta} + + + javax.activation + activation + ${version.activation} + diff --git a/parent/pom.xml b/parent/pom.xml index 32e1ff14f3..fa1ca9a0fb 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -35,11 +35,14 @@ Ink + 2.2.11 + 1.2 + 1.1.1 + 1.3.2 0.2.0 0.1.16 - 1.8.0 4.12 - 3.18.2-GA + 3.22.0-GA @@ -48,6 +51,7 @@ 5.0.12.Final 5.1.4.Final 5.2.8.Final + 5.3.0.CR1 5.2.8.Final @@ -62,20 +66,22 @@ 5.0.13 5.0.2 - - - - - - + 5.1.6 + 5.1.6 + 5.1.4 + 5.0.4 + 2.6.4 2.4.1 + 1.7.2 + 1.8.1 + 1.11.10.RELEASE 2.0.4.RELEASE - 4.6.0 - 6.0-4 + 4.7.5 + 6.0-6 2.4.5.Final @@ -178,6 +184,11 @@ blaze-persistence-integration-hibernate-5.2 ${project.version} + + ${project.groupId} + blaze-persistence-integration-hibernate-5.3 + ${project.version} + ${project.groupId} blaze-persistence-integration-hibernate-6.0 @@ -188,6 +199,11 @@ blaze-persistence-integration-datanucleus ${project.version} + + ${project.groupId} + blaze-persistence-integration-datanucleus-5.1 + ${project.version} + ${project.groupId} blaze-persistence-integration-eclipselink @@ -214,6 +230,11 @@ blaze-persistence-testsuite-base-datanucleus ${project.version} + + ${project.groupId} + blaze-persistence-integration-datanucleus-5.1 + ${project.version} + ${project.groupId} blaze-persistence-testsuite-base-eclipselink @@ -299,14 +320,6 @@ provided - - org.apache.deltaspike.distribution - distributions-bom - ${version.deltaspike} - pom - import - - org.jboss.weld.se weld-se-core diff --git a/pom.xml b/pom.xml index 3da6d8313d..6a7786f738 100644 --- a/pom.xml +++ b/pom.xml @@ -36,8 +36,6 @@ 8.7 yyyy ${maven.build.timestamp} - - 2014 @@ -143,17 +141,11 @@ - - jdk9 + jdk9+ [1.9,) - 3.22.0-CR2 - --add-modules=java.xml.bind - - - --add-modules=java.xml.bind,java.corba 3.0.0-M1 1.9 1.9 diff --git a/testsuite-base/datanucleus/pom.xml b/testsuite-base/datanucleus/pom.xml index 882531d016..0bab9cc4ab 100644 --- a/testsuite-base/datanucleus/pom.xml +++ b/testsuite-base/datanucleus/pom.xml @@ -50,10 +50,6 @@ ${project.groupId} blaze-persistence-testsuite-base-jpa - - ${project.groupId} - blaze-persistence-integration-datanucleus - org.datanucleus datanucleus-core diff --git a/testsuite-base/datanucleus/src/main/java/com/blazebit/persistence/testsuite/base/AbstractPersistenceTest.java b/testsuite-base/datanucleus/src/main/java/com/blazebit/persistence/testsuite/base/AbstractPersistenceTest.java index a35b2b3a65..c0e424a010 100644 --- a/testsuite-base/datanucleus/src/main/java/com/blazebit/persistence/testsuite/base/AbstractPersistenceTest.java +++ b/testsuite-base/datanucleus/src/main/java/com/blazebit/persistence/testsuite/base/AbstractPersistenceTest.java @@ -20,8 +20,11 @@ import com.blazebit.persistence.testsuite.base.jpa.cleaner.DatabaseCleaner; import org.datanucleus.ExecutionContext; import org.datanucleus.store.StoreManager; +import org.datanucleus.store.connection.ConnectionManager; +import org.datanucleus.store.connection.ManagedConnection; import javax.persistence.EntityManager; +import java.lang.reflect.Method; import java.sql.Connection; import java.util.Properties; @@ -58,15 +61,15 @@ protected void addIgnores(DatabaseCleaner applicableCleaner) { protected Connection getConnection(EntityManager em) { StoreManager storeManager = em.unwrap(StoreManager.class); ExecutionContext ec = em.unwrap(ExecutionContext.class); -// try { -// // Datanucleus 5.1 changed the API -// Method getConnection = ConnectionManager.class.getMethod("getConnection", ExecutionContext.class); -// ConnectionManager connectionManager = storeManager.getConnectionManager(); -// return (Connection) ((ManagedConnection) getConnection.invoke(connectionManager, ec)).getConnection(); -// } catch (NoSuchMethodException ex) { - return (Connection) storeManager.getConnection(ec).getConnection(); -// } catch (Exception ex) { -// throw new RuntimeException(ex); -// } + try { + // Datanucleus 5.1 changed the API + Method getConnection = ConnectionManager.class.getMethod("getConnection", ExecutionContext.class); + ConnectionManager connectionManager = storeManager.getConnectionManager(); + return (Connection) ((ManagedConnection) getConnection.invoke(connectionManager, ec)).getConnection(); + } catch (NoSuchMethodException ex) { + return (Connection) storeManager.getConnection(ec).getConnection(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } } } diff --git a/travis/install_jdk_10.sh b/travis/install_jdk_10.sh new file mode 100644 index 0000000000..023ca88079 --- /dev/null +++ b/travis/install_jdk_10.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -e + +# Adapted from https://sormuras.github.io/blog/2017-12-08-install-jdk-on-travis.html + +TMP=$(curl -L jdk.java.net/${JDK}) +TMP="${TMP#*Most recent build: jdk-${JDK}+}" # remove everything before the number +TMP="${TMP%%<*}" # remove everything after the number +JDK_BUILD="$(echo "${TMP}" | tr -d '[:space:]')" # remove all whitespace + +JDK_ARCHIVE=jdk-${JDK}+${JDK_BUILD}_linux-x64_bin.tar.gz + +cd ~ +wget http://download.java.net/java/jdk${JDK}/archive/${JDK_BUILD}/BCL/${JDK_ARCHIVE} +tar -xzf ${JDK_ARCHIVE} +export JAVA_HOME=~/jdk-${JDK} +export PATH=${JAVA_HOME}/bin:$PATH +cd - + +java --version \ No newline at end of file diff --git a/website/pom.xml b/website/pom.xml index 5dec4f3ca3..a35ba71726 100644 --- a/website/pom.xml +++ b/website/pom.xml @@ -185,6 +185,31 @@ + + jdk9+ + + [1.9,) + + + + + + com.blazebit + jbake-maven-plugin + 1.0.0 + + + + org.jbake + jbake-core + 2.6.0 + + + + + + + diff --git a/website/src/main/jbake/content/downloads.adoc b/website/src/main/jbake/content/downloads.adoc index a0a47de8c7..70bc9fbca6 100644 --- a/website/src/main/jbake/content/downloads.adoc +++ b/website/src/main/jbake/content/downloads.adoc @@ -100,6 +100,21 @@ Older releases can be found on https://github.com/Blazebit/blaze-persistence/rel ${blaze-persistence.version} + + + com.blazebit + blaze-persistence-integration-spring-data-rest + ${blaze-persistence.version} + + + + + + com.blazebit + blaze-persistence-integration-hibernate-5.3 + ${blaze-persistence.version} + runtime + @@ -141,6 +156,14 @@ Older releases can be found on https://github.com/Blazebit/blaze-persistence/rel runtime + + + com.blazebit + blaze-persistence-integration-datanucleus-5.1 + ${blaze-persistence.version} + runtime + + com.blazebit