Skip to content

Commit

Permalink
[#1796] Hibernate 6.3 and 6.4 support and start testing snapshots nig…
Browse files Browse the repository at this point in the history
…htly
  • Loading branch information
beikov committed Nov 6, 2023
1 parent 7643961 commit ae73716
Show file tree
Hide file tree
Showing 61 changed files with 3,526 additions and 136 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,20 @@ jobs:
provider: hibernate-6.2
jdk: 11

################################################
# hibernate-6.3
################################################
- rdbms: h2
provider: hibernate-6.3
jdk: 11

################################################
# hibernate-6.4
################################################
- rdbms: h2
provider: hibernate-6.4
jdk: 11

################################################
# LTS JDKs
################################################
Expand Down
102 changes: 102 additions & 0 deletions .github/workflows/latest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: "Blaze-Persistence CI"
on:
schedule:
- cron: '0 5 * * *'
env:
MAVEN_SKIP_RC: true
jobs:
build:
name: Test
runs-on: ubuntu-latest
# We want to know the test results of all matrix entries
continue-on-error: true
strategy:
fail-fast: false
matrix:
include:
################################################
# Latest integration dependencies
################################################
- rdbms: h2
component: other
jdk: 17
################################################
# hibernate-6.2
################################################
- rdbms: h2
component: hibernate-6.2
jdk: 17

################################################
# hibernate-6.3
################################################
- rdbms: h2
component: hibernate-6.3
jdk: 17

################################################
# hibernate-6.4
################################################
- rdbms: h2
component: hibernate-6.4
jdk: 17
steps:
- uses: actions/checkout@v2
- name: Update /etc/hosts file
# /etc/hosts file needs to be updated as a workaround for
# https://github.com/actions/virtual-environments/issues/3185
run: echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
- name: Reclaim Disk Space
run: .github/ci-prerequisites.sh
- name: Set up Java 8
uses: AdoptOpenJDK/install-jdk@v1
with:
version: 8
targets: JDK8_HOME;JAVA_HOME
- name: Set up Requested JDK
uses: actions/setup-java@v3
if: ${{ matrix.jdk != 8 && !endsWith(matrix.jdk, '-ea') }}
with:
java-version: ${{ matrix.jdk }}
distribution: 'temurin'
- name: Set up EA JDK
uses: actions/setup-java@v3
if: ${{ matrix.jdk != 8 && endsWith(matrix.jdk, '-ea') }}
with:
java-version: ${{ matrix.jdk }}
distribution: 'zulu'

- name: Get year/month for cache key
id: get-date
run: |
echo "::set-output name=yearmonth::$(/bin/date -u "+%Y-%m")"
shell: bash
- name: Cache Maven local repository
uses: actions/cache@v2
id: cache-maven
with:
path: |
~/.m2/repository
# refresh cache every month to avoid unlimited growth
key: maven-localrepo-${{ steps.get-date.outputs.yearmonth }}
- name: Set up Maven
run: ./mvnw -v

- name: Run build script
env:
JDK8_HOME: ${{ env.JDK8_HOME }}
RDBMS: ${{ matrix.rdbms }}
COMPONENT: ${{ matrix.component }}
JDK: ${{ matrix.jdk }}
run: ./ci/build-github-latest.sh
shell: bash

- name: Upload test reports (if Maven failed)
uses: actions/upload-artifact@v2
if: failure()
with:
name: test-reports-${{ matrix.component }}
path: './**/*-reports/'

- name: Omit produced artifacts from build cache
run: ./ci/before-cache.sh
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,9 @@ By default, a Maven build `mvn clean install` will test against H2 and Hibernate
To test a specific combination, you need to activate at least 4 profiles

* One of the JPA provider profiles
* `hibernate-6.2`
* `hibernate-6.4` + the `jakarta` profile
* `hibernate-6.3` + the `jakarta` profile
* `hibernate-6.2` + the `jakarta` profile
* `hibernate-5.6`
* `hibernate-5.5`
* `hibernate-5.4`
Expand Down Expand Up @@ -505,8 +507,8 @@ For executing tests against a database on a dedicated host you might want to spe

## Testing with Jakarta Persistence provider

To build everything use `mvn -pl core/testsuite-jakarta-runner clean install -am -P "hibernate-6.2,h2,spring-data-2.6.x,deltaspike-1.9" -DskipTests`
and to run tests use ` mvn -pl core/testsuite-jakarta-runner clean install -P "hibernate-6.2,h2,spring-data-2.6.x,deltaspike-1.9" "-Dtest=com.blazebit.persistence.testsuite.SetOperationTest#testUnionAllOrderBySubqueryLimit"`.
To build everything use `mvn -pl core/testsuite-jakarta-runner clean install -am -P "hibernate-6.2,jakarta,h2,spring-data-2.6.x,deltaspike-1.9" -DskipTests`
and to run tests use ` mvn -pl core/testsuite-jakarta-runner clean install -P "hibernate-6.2,jakarta,h2,spring-data-2.6.x,deltaspike-1.9" "-Dtest=com.blazebit.persistence.testsuite.SetOperationTest#testUnionAllOrderBySubqueryLimit"`.

## Switching JPA provider profiles in IntelliJ

Expand Down
10 changes: 7 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ if [[ "$JDK" != "" ]]; then
fi
if [[ "$JDK" == "21" ]] || [[ "$JDK" == "22" ]]; then
# As of JDK 21 Javac produces parameter attributes with a null name that old BND versions can't read
PROPERTIES="$PROPERTIES -Dversion.bnd=7.0.0-SNAPSHOT"
PROPERTIES="$PROPERTIES -Dversion.bnd=7.0.0"
fi
PROPERTIES="$PROPERTIES -Djdk8.home=$JDK8_HOME"
fi

if [[ "$JPAPROVIDER" == hibernate-6* ]]; then
ADDITIONAL_PROFILES=,jakarta
fi

if [[ "$NATIVE" == "true" ]]; then
exec $DIR/mvnw -B -P ${JPAPROVIDER},${RDBMS},${SPRING_DATA:-spring-data-2.7.x},${DELTASPIKE:-deltaspike-1.9},native clean install -am -V $PROPERTIES
exec $DIR/mvnw -B -P ${JPAPROVIDER},${RDBMS},${SPRING_DATA:-spring-data-2.7.x},${DELTASPIKE:-deltaspike-1.9},native${ADDITIONAL_PROFILES} clean install -am -V $PROPERTIES
else
exec $DIR/mvnw -B -P ${JPAPROVIDER},${RDBMS},${SPRING_DATA:-spring-data-2.7.x},${DELTASPIKE:-deltaspike-1.9} clean install -am -V $PROPERTIES
exec $DIR/mvnw -B -P ${JPAPROVIDER},${RDBMS},${SPRING_DATA:-spring-data-2.7.x},${DELTASPIKE:-deltaspike-1.9}${ADDITIONAL_PROFILES} clean install -am -V $PROPERTIES
fi
21 changes: 21 additions & 0 deletions ci/build-github-latest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#! /bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

java -version

if [ "$COMPONENT" == 'hibernate-6.2' ]; then
export JPAPROVIDER="hibernate-6.2"
export PROPERTIES="-s $DIR/latest-settings.xml -Dversion.hibernate-6.2=[6.2,6.3.Alpha)"
elif [ "$COMPONENT" == 'hibernate-6.3' ]; then
export JPAPROVIDER="hibernate-6.3"
export PROPERTIES="-s $DIR/latest-settings.xml -Dversion.hibernate-6.3=[6.3,6.4.Alpha)"
elif [ "$COMPONENT" == 'hibernate-6.4' ]; then
export JPAPROVIDER="hibernate-6.4"
export PROPERTIES="-s $DIR/latest-settings.xml -Dversion.hibernate-6.4=[6.4,6.5.Alpha)"
else
export JPAPROVIDER="hibernate-6.2"
export PROPERTIES="-Dversion.spring-data-3.1=[3,4.Alpha) -Dversion.spring-data-3.1-spring=[6.0,6.1.Alpha) -Dversion.spring-data-3.1-spring-boot=[3,4.Alpha)"
fi

exec bash $DIR/../build.sh
33 changes: 33 additions & 0 deletions ci/latest-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!--
Copyright 2014 - 2023 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.
-->

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

<profiles>
<profile>
<id>latest</id>
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>
</profile>
</profiles>

</settings>
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,45 @@ public void render(FunctionRenderContext context, String[] fields, String[] sele
context.addChunk(postChunk);
context.addChunk(subquery.substring(fromIndex));
} else {
String limitText = SqlUtils.LIMIT;
String limit = null;
String offset = null;
int limitIndex = SqlUtils.indexOfLimit(subquery, orderByIndex);
int orderByEndIndex;
if (limitIndex == -1) {
limitText = SqlUtils.FETCH_FIRST;
limitIndex = SqlUtils.indexOfFetchFirst(subquery, orderByIndex);
int offsetIndex = subquery.indexOf(" offset ", orderByIndex);
int fetchFirstIndex = SqlUtils.indexOfFetchFirst(subquery, orderByIndex);
int endIndex = subquery.length() - 1;
if (offsetIndex != -1) {
if (fetchFirstIndex == -1) {
offset = subquery.substring(offsetIndex + " offset ".length(), endIndex);
} else {
offset = subquery.substring(offsetIndex + " offset ".length(), fetchFirstIndex);
}
endIndex = Math.min(endIndex, offsetIndex);
}
if (fetchFirstIndex != -1) {
int rowsOnlyIndex = subquery.indexOf(" rows only", fetchFirstIndex + SqlUtils.FETCH_FIRST.length() + 1);
limit = subquery.substring(fetchFirstIndex + SqlUtils.FETCH_FIRST.length(), rowsOnlyIndex);
endIndex = Math.min(endIndex, fetchFirstIndex);
}
orderByEndIndex = endIndex;
} else {
orderByEndIndex = limitIndex;
int offsetIndex = subquery.indexOf(" offset ", limitIndex);
if (offsetIndex == -1) {
int commaIndex = subquery.indexOf(',', limitIndex);
if (commaIndex == -1) {
limit = subquery.substring(limitIndex + SqlUtils.LIMIT.length(), subquery.length() - 1);
} else {
offset = subquery.substring(limitIndex + SqlUtils.LIMIT.length(), commaIndex);
limit = subquery.substring(commaIndex + 1, subquery.length() - 1);
}
} else {
limit = subquery.substring(limitIndex + SqlUtils.LIMIT.length(), offsetIndex);
offset = subquery.substring(offsetIndex, subquery.length() - 1);
}
}
if (limitIndex == -1) {
if (limit == null) {
context.addChunk(preChunk);
groupConcatFunction.render(context, new AbstractGroupConcatFunction.GroupConcat(false, createGroupConcatArgument(fields, selectItemExpressions, fromIndex), Collections.<Order>emptyList(), ","));
context.addChunk(" OVER (");
Expand All @@ -118,24 +150,21 @@ public void render(FunctionRenderContext context, String[] fields, String[] sele
context.addChunk(preChunk);
groupConcatFunction.render(context, new AbstractGroupConcatFunction.GroupConcat(false, createGroupConcatArgument(fields, selectItemExpressions, fromIndex), Collections.<Order>emptyList(), ","));
context.addChunk(" OVER (");
context.addChunk(subquery.substring(orderByIndex, limitIndex));
String limitClause = subquery.substring(limitIndex + limitText.length(), subquery.length() - 1);
String offsetText = " offset ";
int offsetIndex = limitClause.indexOf(offsetText);
if (offsetIndex == -1) {
context.addChunk(subquery.substring(orderByIndex, orderByEndIndex));
if (offset == null) {
context.addChunk(" ROWS BETWEEN CURRENT ROW AND (");
context.addChunk(limitClause);
context.addChunk(limit);
context.addChunk(" - 1) FOLLOWING");
} else {
context.addChunk(" ROWS BETWEEN ");
context.addChunk(limitClause.substring(offsetIndex + offsetText.length()));
context.addChunk(limit);
context.addChunk(" FOLLOWING AND ");
context.addChunk(limitClause.substring(0, offsetIndex));
context.addChunk(offset);
context.addChunk(" FOLLOWING");
}
context.addChunk(")");
context.addChunk(postChunk);
context.addChunk(subquery.substring(fromIndex, limitIndex));
context.addChunk(subquery.substring(fromIndex, orderByEndIndex));
context.addChunk(" limit 1)");
} else {
context.addChunk(preChunk);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,46 @@ public void render(FunctionRenderContext context, String[] fields, String[] sele
groupConcatFunction.render(context, new AbstractGroupConcatFunction.GroupConcat(false, createGroupConcatArgument(fields, selectItemExpressions, fromIndex), Collections.<Order>emptyList(), ","));
context.addChunk(subquery.substring(fromIndex));
} else {
String limit = null;
String offset = null;
int limitIndex = SqlUtils.indexOfLimit(subquery, orderByIndex);
int orderByEndIndex;
if (limitIndex == -1) {
int offsetIndex = subquery.indexOf(" offset ", orderByIndex);
int fetchFirstIndex = SqlUtils.indexOfFetchFirst(subquery, orderByIndex);
int endIndex = subquery.length() - 1;
if (offsetIndex != -1) {
if (fetchFirstIndex == -1) {
offset = subquery.substring(offsetIndex + " offset ".length(), endIndex);
} else {
offset = subquery.substring(offsetIndex + " offset ".length(), fetchFirstIndex);
}
endIndex = Math.min(endIndex, offsetIndex);
}
if (fetchFirstIndex != -1) {
int rowsOnlyIndex = subquery.indexOf(" rows only", fetchFirstIndex + SqlUtils.FETCH_FIRST.length() + 1);
limit = subquery.substring(fetchFirstIndex + SqlUtils.FETCH_FIRST.length(), rowsOnlyIndex);
endIndex = Math.min(endIndex, fetchFirstIndex);
}
orderByEndIndex = endIndex;
} else {
orderByEndIndex = limitIndex;
int offsetIndex = subquery.indexOf(" offset ", limitIndex);
if (offsetIndex == -1) {
int commaIndex = subquery.indexOf(',', limitIndex);
if (commaIndex == -1) {
limit = subquery.substring(limitIndex + SqlUtils.LIMIT.length(), subquery.length() - 1);
} else {
offset = subquery.substring(limitIndex + SqlUtils.LIMIT.length(), commaIndex);
limit = subquery.substring(commaIndex + 1, subquery.length() - 1);
}
} else {
limit = subquery.substring(limitIndex + SqlUtils.LIMIT.length(), offsetIndex);
offset = subquery.substring(offsetIndex, subquery.length() - 1);
}
}

if (limit == null) {
groupConcatFunction.render(context, new AbstractGroupConcatFunction.GroupConcat(false, createGroupConcatArgument(fields, selectItemExpressions, fromIndex), Collections.<Order>emptyList(), ","));
context.addChunk(" OVER (");
context.addChunk(subquery.substring(orderByIndex));
Expand All @@ -63,22 +101,20 @@ public void render(FunctionRenderContext context, String[] fields, String[] sele
if (lateralStyle == LateralStyle.NONE) {
groupConcatFunction.render(context, new AbstractGroupConcatFunction.GroupConcat(false, createGroupConcatArgument(fields, selectItemExpressions, fromIndex), Collections.<Order>emptyList(), ","));
context.addChunk(" OVER (");
context.addChunk(subquery.substring(orderByIndex, limitIndex));
String limitClause = subquery.substring(limitIndex + " limit ".length(), subquery.length() - 1);
int offsetIndex = limitClause.indexOf(" offset ");
if (offsetIndex == -1) {
context.addChunk(subquery.substring(orderByIndex, orderByEndIndex));
if (offset == null) {
context.addChunk(" ROWS BETWEEN CURRENT ROW AND (");
context.addChunk(limitClause);
context.addChunk(limit);
context.addChunk(" - 1) FOLLOWING");
} else {
context.addChunk(" ROWS BETWEEN ");
context.addChunk(limitClause.substring(offsetIndex + " offset ".length()));
context.addChunk(limit);
context.addChunk(" FOLLOWING AND ");
context.addChunk(limitClause.substring(0, offsetIndex));
context.addChunk(offset);
context.addChunk(" FOLLOWING");
}
context.addChunk(")");
context.addChunk(subquery.substring(fromIndex, limitIndex));
context.addChunk(subquery.substring(fromIndex, orderByEndIndex));
context.addChunk(" limit 1)");
} else {
groupConcatFunction.render(context, new AbstractGroupConcatFunction.GroupConcat(false, createGroupConcatArgument(fields, fields, fromIndex), Collections.<Order>emptyList(), ","));
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</modules>
<profiles>
<profile>
<id>hibernate-6.2</id>
<id>jakarta</id>
<modules>
<module>api</module>
<module>parser</module>
Expand Down
Loading

0 comments on commit ae73716

Please sign in to comment.