Skip to content

fix(hibernate): fetch join of to-one associations and criteria over basic-value collections #2989

fix(hibernate): fetch join of to-one associations and criteria over basic-value collections

fix(hibernate): fetch join of to-one associations and criteria over basic-value collections #2989

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: "Groovy Snapshot Canary Build"
on:
push:
branches:
- '[0-9]+.[0-9]+.x'
pull_request:
# ready_for_review is not a default type: a draft runs nothing until it is ready or labelled "run ci".
types: [ opened, synchronize, reopened, ready_for_review ]
branches:
- '[0-9]+.[0-9]+.x'
workflow_dispatch:
inputs:
run-tests:
description: "Run the build where the branch rule would skip it (a release branch below the default); a [skip tests] head commit still skips it"
type: boolean
default: false
# One run per branch or pull request: a new commit cancels the run in flight, whose result would be for a
# superseded commit, and overlapping runs of this build are likely to hit GitHub resource limits. This
# workflow publishes nothing, so nothing here needs to survive the cancel.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
policy:
name: "CI policy"
# A pull request labelled "no ci", or a draft without the "run ci" label, skips this job; every other
# job needs it, so nothing runs for such a pull request.
if: >-
github.event_name != 'pull_request'
|| (!contains(github.event.pull_request.labels.*.name, 'no ci')
&& (!github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'run ci')))
uses: ./.github/workflows/ci-policy.yml
build_groovy:
needs: [policy]
if: ${{ needs.policy.outputs.run-tests == 'true' }}
name: "Build Groovy Snapshot"
runs-on: ubuntu-22.04
outputs:
groovyVersion: ${{ steps.groovy-version.outputs.value }}
steps:
- name: "☕️ Setup JDK"
uses: actions/setup-java@v6.1.0
with:
java-version: 21
distribution: liberica
- name: "📥 Checkout Grails Core to fetch Gradle Plugin versions it uses"
# Sparse-checkout fetches only the two paths this job actually needs:
# - dependencies.gradle: parsed below to derive the matching Apache
# Groovy branch (GROOVY_<major>_<minor>_X) for this Grails branch.
# - .github/scripts/groovy-snapshot-canary-build.init.gradle: passed to
# ./gradlew --init-script when publishing Groovy to local Maven so
# the canary build reuses our Develocity / build-cache settings.
# Both paths must be listed here; otherwise the init-script step fails
# with "The specified initialization script ... does not exist."
# - .github/actions: the local gradle-cache-policy action the Setup Gradle
# step runs first; without it the job fails before building anything.
uses: actions/checkout@v7.0.1
with:
sparse-checkout-cone-mode: false
sparse-checkout: |
dependencies.gradle
.github/scripts/groovy-snapshot-canary-build.init.gradle
.github/actions
- name: "📝 Derive matching Apache Groovy branch from dependencies.gradle"
id: groovy-branch
run: |
# Extract the major and minor version of `groovy.version` declared in this
# branch's dependencies.gradle (e.g. '5.0.5' -> '5_0', '4.0.31' -> '4_0')
# and use it to pick the matching Apache Groovy development branch
# (GROOVY_<major>_<minor>_X).
# This keeps `7.0.x` PRs validating against Groovy 4 and `8.0.x` PRs
# validating against Groovy 5 without hard-coding the branch here.
GROOVY_MAJOR_MINOR=$(sed -nE "s/.*'groovy\.version'.*'([0-9]+)\.([0-9]+)\.[0-9]+'.*/\1_\2/p" dependencies.gradle | head -n 1)
if [ -z "$GROOVY_MAJOR_MINOR" ]; then
echo "::error::Could not determine Apache Groovy major/minor version from dependencies.gradle"
exit 1
fi
GROOVY_BRANCH="GROOVY_${GROOVY_MAJOR_MINOR}_X"
echo "Validating against Apache Groovy branch: $GROOVY_BRANCH"
echo "value=$GROOVY_BRANCH" >> $GITHUB_OUTPUT
rm dependencies.gradle
- name: "📥 Checkout Apache Groovy (${{ steps.groovy-branch.outputs.value }})"
run: git clone --depth 1 https://github.com/apache/groovy.git -b ${{ steps.groovy-branch.outputs.value }} --single-branch
- name: "🗄️ Decide the Gradle cache mode"
id: gradle-cache-policy
uses: ./.github/actions/gradle-cache-policy
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
with:
# Decided by the step above; see .github/actions/gradle-cache-policy.
cache-read-only: ${{ steps.gradle-cache-policy.outputs.read-only }}
develocity-access-key: ${{ secrets.GRAILS_DEVELOCITY_ACCESS_KEY }}
- name: "🔍 Setup TestLens"
uses: testlens-app/setup-testlens@89edf53f781ac41833b4bc74d0e19a5315c79c67 # v1.10.0
- name: "📝 Store Groovy version to use when building Grails"
id: groovy-version
run: |
cd groovy
GROOVY_VERSION=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]')
echo "Groovy version $GROOVY_VERSION stored"
echo "value=$GROOVY_VERSION" >> $GITHUB_OUTPUT
- name: "🔨 Publish Groovy to local maven repository (no docs)"
run: |
cd groovy
./gradlew pTML -x groovydoc -x javadoc -x javadocAll -x groovydocAll -x asciidoc -x docGDK \
--init-script $GITHUB_WORKSPACE/.github/scripts/groovy-snapshot-canary-build.init.gradle
- name: "📤 Share locally built Groovy artifacts with the build_grails job"
uses: actions/upload-artifact@v7.0.1
with:
name: local-groovy-maven-repo
path: ~/.m2/repository/org/apache/groovy/
if-no-files-found: 'error'
retention-days: 1
build_grails:
needs: [build_groovy]
name: "Build Grails (shard ${{ matrix.shard_index }})"
strategy:
fail-fast: false
matrix:
include:
- shard_index: 0
gradle_task: build
- shard_index: 1
gradle_task: testShard
- shard_index: 2
gradle_task: testShard
# ubuntu-22.04 for the reason gradle.yml's mongodbFunctional job gives: this job runs the MongoDB specifications
# against mongo:8.0, and ubuntu-latest is now the ubuntu-26.04 image, whose 7.0.0-1017-azure kernel MongoDB 8.0
# refuses to start on (https://github.com/actions/runner-images/issues/15005). Move back with that job.
runs-on: ubuntu-22.04
steps:
- name: "⚙️ Maximize build space"
run: |
echo "-- Dotnet"
sudo rm -rf /usr/share/dotnet
echo "-- Android"
sudo rm -rf /usr/local/lib/android
echo "-- Haskell"
sudo rm -rf /opt/ghc
echo "-- CodeQL"
sudo rm -rf /opt/hostedtoolcache/CodeQL
df -h
- name: "📥 Checkout project"
uses: actions/checkout@v7.0.1
- name: "☕️ Setup JDK"
uses: actions/setup-java@v6.1.0
with:
java-version: 21
distribution: liberica
- name: "🗄️ Restore the mongod the embedded server runs"
id: embedmongo-cache
uses: actions/cache/restore@v6.1.0
with:
# Outside the Gradle User Home that setup-gradle caches, for the reasons given on the same
# step in gradle.yml. The version is the one -PmongodbContainerVersion asks for below.
path: ~/.embedmongo
key: embedmongo-${{ runner.os }}-8.0
- name: "🗄️ Decide the Gradle cache mode"
id: gradle-cache-policy
uses: ./.github/actions/gradle-cache-policy
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
with:
# Decided by the step above; see .github/actions/gradle-cache-policy.
cache-read-only: ${{ steps.gradle-cache-policy.outputs.read-only }}
develocity-access-key: ${{ secrets.GRAILS_DEVELOCITY_ACCESS_KEY }}
- name: "🔍 Setup TestLens"
uses: testlens-app/setup-testlens@89edf53f781ac41833b4bc74d0e19a5315c79c67 # v1.10.0
- name: "📥 Fetch the locally built Groovy artifacts"
uses: actions/download-artifact@v8.0.1
with:
name: local-groovy-maven-repo
path: ~/.m2/repository/org/apache/groovy
- name: 'Swap Groovy Version'
run: |
sed -i "/['\"]groovy\.version['\"][[:space:]]*:/c\'groovy.version':'${{ needs.build_groovy.outputs.groovyVersion }}'," dependencies.gradle
- name: "🔨 Build and test Grails using the locally built Groovy snapshot"
# -PmongodbContainerVersion names the MongoDB the specifications bring themselves: a
# container for most of them, an embedded server for the ones that need a replica set. It
# keeps those two on the same release. This workflow validates Grails against a Groovy
# snapshot rather than against a range of MongoDB releases, which is gradle.yml's matrix.
run: >
./gradlew ${{ matrix.gradle_task }}
--continue
--stacktrace
-PskipCodeStyle
-PmaxTestParallel=3
-PtestShardCount=3
-PtestShardIndex=${{ matrix.shard_index }}
-PmongodbContainerVersion=8.0
env:
GRAILS_INCLUDE_MAVEN_LOCAL: true
- name: "🗄️ Save the mongod the embedded server runs"
# The download is the same on every branch, and every branch can restore the default branch's entries,
# so only a push to the default branch saves it; other branches and pull requests only restore it.
if: ${{ success() && github.event_name != 'pull_request' && github.ref_name == github.event.repository.default_branch && steps.embedmongo-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v6.1.0
with:
path: ~/.embedmongo
key: ${{ steps.embedmongo-cache.outputs.cache-primary-key }}