Skip to content

Keep every alias of an association path in a DetachedCriteria when the datastore opts in (#16851) - #16890

Open
borinquenkid wants to merge 11 commits into
8.1.xfrom
fix/h5-alias-consolidation-7.0.x
Open

borinquenkid wants to merge 11 commits into
8.1.xfrom
fix/h5-alias-consolidation-7.0.x

Conversation

@borinquenkid

@borinquenkid borinquenkid commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Part of #16851 and #14647. This is the 7.0.x half, so Hibernate 5 and the shared core get it first. The Hibernate 7 half is #16891, which contains this commit and runs the full CI.

What changes

AbstractDetachedCriteria.createAlias replaced the alias of an association path when it was given another one, so the first alias never reached a datastore. A MappingContext that implements the new MultipleAliasesMappingContext and says it joins an association once for each alias now gets every alias as an entry of its own.

A datastore that does not implement it keeps the latest alias of a path, as it always has. That is Hibernate 5, MongoDB, Neo4j and the simple datastore, so none of them changes.

Also in this PR

A DetachedCriteria resolves an alias path that starts with an alias it declared earlier: after createAlias('children', 'c') the path 'c.related' is children.related, as the criteria builder resolves it. It used to fail with "Argument [c.related] is not an association" and worked only when the alias had the name of its association (#14647).

Tests

DetachedCriteriaAliasSpec for Hibernate 5 pins what stays the same: declaring the same alias again is still one alias, the second of two aliases replaces the first and a restriction on it works, and a restriction on the replaced alias fails with Hibernate's own error.

The datamapping-core and Hibernate 5 core suites and the style checks pass. The tests of this PR are not run by CI here (no ci), because the same commit is in #16891.

https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL

Tracked in #16896.

…achedCriteria, and reject it clearly on Hibernate 5 (#16851)

AbstractDetachedCriteria.createAlias renamed the existing alias of a path when it was given another
one, so the first alias was gone before any datastore saw the criteria. A second alias of a path is now
kept as its own entry next to the first. Declaring the same alias again, or naming a block that had no
alias, behave as before.

Hibernate 5 joins an association once, as its Criteria API rejects a second join of one path. It used to
reuse the join of the first alias for the second, so a restriction on the second failed with "could not
resolve property". It now throws an InvalidDataAccessApiUsageException that names the association and
both aliases. Aliases the query generates for associations nobody named are not affected.

Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
… path (#16851)

The AliasMatrixSpec of the 8.0.x line showed that the error turned queries that returned rows on Hibernate 5
into exceptions: a second alias of a path that nothing restricts was harmless before, because the second
alias simply reused the join of the first. Only a restriction on the second alias fails, with Hibernate's
"could not resolve property". The translator is back to its old behaviour, and the spec pins what fails.

Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
… association path (#16851)

AbstractDetachedCriteria.createAlias replaces the alias of an association path when it is given another
one. A MappingContext that implements MultipleAliasesMappingContext and says it joins an association once
for each alias now gets every alias as an entry of its own, so the datastore sees both. A datastore that
does not implement it, as Mongo, Neo4j, the simple datastore and Hibernate 5 do not, keeps the latest
alias of a path, as it always has.

The Hibernate 5 spec pins that: the second alias replaces the first, a restriction on it works, and a
restriction on the replaced alias fails with Hibernate's own error.

Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
Copilot AI balanced review requested due to automatic review settings November 7, 2026 23:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…teria declared earlier (#14647)

createAlias on a DetachedCriteria checked every segment of the path against the entities, so after
createAlias('children', 'c') the path 'c.related' failed with "Argument [c.related] is not an association".
It worked only when the alias had the name of its association, as in createAlias('children', 'children'). A
path whose first segment is an alias the criteria declared earlier now continues the path of that alias, so
'c.related' is 'children.related', as the criteria builder resolves it. A first segment that is both an alias
and a property of the entity names the alias.

The Hibernate 5 spec covers both spellings.

Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not approving. A later join that starts from one of two aliases of the same association is stored as the association path, so two different queries become the same and one returns the wrong rows.

String head = associationPath.substring(0, dot)
for (Query.Criterion criterion in criteria) {
if (criterion instanceof DetachedAssociationCriteria && ((DetachedAssociationCriteria) criterion).alias == head) {
return ((DetachedAssociationCriteria) criterion).associationPath + associationPath.substring(dot)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Input: two aliases of children, then a join from the second alias to related. The stored path is children.related, with nothing that says which alias it starts from. A parent that matches only through the second alias is dropped, or one that matches only through the first is returned. Keep the alias the join started from.

…e alias it started from

createAlias('c2.related', 'r') after two aliases of children was stored as children.related, with nothing
to say that it continues from c2 and not from the first alias, so a datastore that joins each alias
could not tell the two joins apart. The association criteria now carry the written path when it starts
with a later alias of its association. A path that starts with the first alias is the path of the
association and carries nothing.

Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
@borinquenkid

Copy link
Copy Markdown
Member Author

@jamesfredley Fixed in b863104. When a path starts with a later alias of its association, the association criteria now carry the path as written (c2.related) next to the association path (children.related), so a datastore that joins each alias can tell which join it continues from. A path that starts with the first alias carries nothing, since it is the path of the association. Three features in DetachedCriteriaAliasSpec fail without the change; the Hibernate 5 core and datamapping-core suites pass.

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not approving. A path that starts from a later alias is still stored as the association path, and declaring that alias twice sends the same alias twice.

// the first alias of an association names the path itself, so a path that starts with it is that path; a
// later alias is a join of its own, and a path that starts with it has to continue from that join
String pathFromAlias = startingAlias != null && !startingAlias.is(associationCriteriaMap[startingAlias.associationPath]) ?
writtenPath : null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create aliases children as c1 and c2, then c2.related as r, then r.owner as o, and compare o.name with Alice. That query is stored as the same criteria as one that starts from c1.related.owner. A parent whose first child relates to Alice and whose second relates to Bob is kept or dropped for both queries. Keep the written alias path when the input starts from a declared alias.

// is kept next to it, so both aliases reach the datastore, which decides whether they share a join.
associationCriteria = new DetachedAssociationCriteria(a.associatedEntity.javaClass, a, associationPath, alias)
associationCriteria.pathFromAlias = pathFromAlias
add(associationCriteria)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declare children as c1, then declare children as c2 twice. The alias list is c1, c2, c2. The second declaration of c2 is appended again, so the datastore receives the same alias twice. Look up the existing path and alias before adding another criterion.

… join in the criteria builder

A second alias for a path that another alias or a block already joins names that join instead of failing with a duplicate association path; a dotted createAlias path joins the associations before its last one; order(Query.Order) accepts a path that starts with an alias; an alias used before its declaration, when a block already joins its path, is rejected with a clear message. The H7 alias path identity matrix now runs on Hibernate 5.
borinquenkid added a commit that referenced this pull request Nov 10, 2026
…iteria builder on Hibernate 5 and 7

One path spelled several ways is one join, a dotted createAlias joins the associations before its last one, and an order by an alias-qualified path sorts by that alias through both overloads. Hibernate 5 marks all three pending until the alias fixes of #16890 reach 8.0.x.

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not approving. A path that starts with the root alias throws, and a path through an embedded component is turned into a join.

*/
protected String joinPrefix(String associationPath, int joinType) {
String[] segments = associationPath.split("\\.");
if (segments.length < 2 || aliasMap.containsValue(segments[0])) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createAlias('this.owner', 'o') then eq('o.name', 'A'). The query throws because this is treated as an association. Keep the root alias when the path starts with it.

for (int i = 0; i < segments.length - 1; i++) {
absolute.append(i == 0 ? "" : ".").append(segments[i]);
String existing = aliasMap.get(absolute.toString());
if (existing == null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createAlias('address.country', 'c'), where address is embedded and country is an association inside it. The query throws because address is joined. Keep the embedded segment and join only the association.

… the embedded segment of a path through a component

A path that starts with this named a property called 'this' and failed, and a path through an embedded component
joined the component, which Hibernate cannot create a criteria on. The path now drops a leading this, and joinPrefix
asks the entity metadata, keeping an embedded segment as part of the path and joining only the associations. The two
createAlias overloads now share one path, so the rules are written once.

AliasPathShapeMatrixSpec runs ten spellings of the path (plain, this, nested, embedded then association, an alias
that starts from an earlier alias, a second alias of one path, and the combinations) used to restrict, project and
order. 18 of its 30 cells failed before the change.

Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL

@matrei matrei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking up #16851 and #14647. I'd like the #14647 fix in 7.0.x, but I don't think this PR can go there as it is. It now contains three separate changes:

  1. The #14647 fix in AbstractDetachedCriteria. A path that starts with an alias declared earlier, like createAlias('c.related', 'r') after createAlias('children', 'c'), now works. That's a bug fix with tests, and it fits 7.0.x.
  2. The MultipleAliasesMappingContext opt-in. No datastore on 7.0.x implements it. On 7.0.x it is new public API that never runs: the interface, keepsEveryAlias() and DetachedAssociationCriteria.pathFromAlias. Its only user is HibernateMappingContext in #16891, so I'd move it there (inline comment below).
  3. The Hibernate 5 criteria builder change in 09ad764. The description says Hibernate 5 doesn't change, but this commit changes how createCriteria and withCriteria resolve aliases. It is the Hibernate 5 side of the #16889 model, not part of #16851 or #14647, so I'd give it a PR of its own.

To see what this means for 7.0.x, I ran the same queries with the Hibernate 5 TCK on the merge base (95f6389) and on 09ad764. Pets Ann (owner A), Bob (owner B) and Cat (no owner). Owners A and B each have one score in round first and one in round second. Owner.address is embedded and has a country association:

Query 7.0.x This PR
Pet.withCriteria { createAlias('this.owner', 'o'); eq('o.name', 'A') } [Ann] QueryException: could not resolve property: this
Owner.withCriteria { createAlias('address.country', 'c'); eq('c.name', 'SE') } [A] QueryException: Criteria objects cannot be created directly on components
Pet.withCriteria { owner { eq('name', 'A') }; createAlias('owner', 'o'); eq('o.name', 'A') } QueryException: duplicate association path: owner [Ann]
Pet.withCriteria { createAlias('owner.scores', 'os'); eq('os.round', 'first'); eq('os.score', 1) } SQLGrammarException: column OS1_.ROUND not found [Ann]
Pet.withCriteria { createAlias('owner', 'o'); order(new Query.Order('o.name', DESC)) } QueryException: could not resolve property: o [Bob, Ann]
new DetachedCriteria(Owner).build { createAlias('scores', 's'); createAlias('s.judge', 'j'); eq('j.name', 'J1') }.list() IllegalArgumentException: Argument [s.judge] is not an association [A, B]
Owner.withCriteria { createAlias('scores', 'a'); createAlias('scores', 'b'); eq('a.round', 'first'); eq('b.round', 'second') } QueryException: duplicate association path: scores []
Domain classes
@Entity
class Judge {
    String name
}

@Entity
class Score {
    String round
    Integer score
    Judge judge
}

@Entity
class Country {
    String name
}

class Address {
    String city
    Country country
}

@Entity
class Owner {
    String name
    Address address

    static embedded = ['address']
    static hasMany = [scores: Score]
}

@Entity
class Pet {
    String name
    Owner owner

    static constraints = {
        owner nullable: true
    }
}

The first two rows are the cases jamesfredley reported. They work on 7.0.x today and fail with this PR, and we can't ship that in a patch release. The next four rows are real fixes. The #14647 one is in this PR's core change, and I'd be glad to have the other three in 7.0.x once the regressions are fixed and covered by tests.

The last row worries me more, because it doesn't fail. On 7.0.x, two aliases of one path fail with "duplicate association path". With this PR, the second alias names the join of the first, so both restrictions apply to the same score row, and the query returns no owners. In the model in #16896, every later alias has a join of its own, so the same query returns [A, B] on Hibernate 7. Hibernate 5 can't join a path twice, so I'd rather it keeps failing there, as #16851 suggests, and only shares the join of a block that declares no alias (inline comment below).

The PR is also labelled no ci, so its tests haven't run in CI against 7.0.x. #16891 runs on 8.0.x, which is different code, so please replace the label with run ci before this merges.

My proposal:

  • Keep the #14647 fix in this PR, against 7.0.x.
  • Move the Hibernate 5 builder change to its own PR against 7.0.x, with the two regressions fixed and tested, and the error kept for two explicit aliases of one path.
  • Move the opt-in to #16891.
  • Update the title and description to match what is left.

Comment on lines +701 to +707
if (existing != null && !existing.equals(alias)) {
if (usedPropertyHeads.contains(alias)) {
throw new IllegalArgumentException("The alias [" + alias + "] for the association [" + associationPath +
"] is used before it is declared, and a block of the query already joins that association: " +
"declare the alias before the criteria that use it");
}
aliasRedirects.put(alias, existing);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When existing is an alias that createAlias declared, not one that a block generated, this turns the second alias into another name for the first alias's join. On 7.0.x, createAlias('scores', 'a'), createAlias('scores', 'b'), eq('a.round', 'first'), eq('b.round', 'second') fails with "duplicate association path". With this change it returns no rows, because both restrictions apply to the same join. In the #16896 model, the second alias has a join of its own. Hibernate 5 can't do that, so I'd keep the error when both aliases were declared, and redirect only to the join of a block, for example by recording the aliases the builder generates.

* it a second alias of a path takes the place of the first, which is what a datastore that ignores aliases, or
* joins an association once, has always seen.
*
* @since 8.0.1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing on 7.0.x implements this. There, this interface, keepsEveryAlias() and pathFromAlias are public API that never runs, and @since 8.0.1 already points at 8.0.x. I'd move them to #16891, together with HibernateMappingContext, their only implementation. That also keeps 7.0.x clear of the open point about a later alias declared twice being added twice, which only matters for a datastore that opts in.

@borinquenkid

Copy link
Copy Markdown
Member Author

@jamesfredley both inputs reproduced and fixed in 74b3759.

  • createAlias('this.owner', 'o'). A path starting with this was treated as a property called this. The path now drops a leading this. first (unless an alias is literally named this).
  • createAlias('address.country', 'c'), address embedded. joinPrefix tried to join address, and Hibernate cannot create a criteria on a component. It now asks the entity metadata: an embedded segment stays part of the path, and only the associations are joined.

Both live in the one path that the two createAlias overloads now share (the 2-argument form delegates to the 3-argument one), so the rules are written once.

Rather than add two cases, AliasPathShapeMatrixSpec runs ten spellings of the path: plain, this., nested, this. and nested, embedded then association, this. and embedded, a dotted path from an earlier alias, a second alias of one path, this. then a second alias, and embedded with a second alias. Each is used to restrict, project and order, so 30 cells. 18 failed before the change, all of them your two inputs and their combinations. All 30 pass now.

Hibernate 5 core: 737 tests, 0 failures, 29 skipped as before.

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A path that starts with the root alias no longer throws. Not approving. A path through an embedded component is still turned into a join when the builder has no datastore, or when the path is declared inside an association block. A second alias of an association also fails when it is used to join further.

if (segments.length < 2 || aliasMap.containsValue(segments[0])) {
return associationPath;
}
PersistentEntity entity = datastore == null ? null : datastore.getMappingContext().getPersistentEntity(targetClass.getName());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createAlias('address.country', 'c') on a builder created with new HibernateCriteriaBuilder(clazz, sessionFactory), or the same path inside owner { }, throws because address is joined. address is embedded. Keep that segment and join only country.

"] is used before it is declared, and a block of the query already joins that association: " +
"declare the alias before the criteria that use it");
}
aliasRedirects.put(alias, existing);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createAlias('owner', 'o'); createAlias('owner', 'o2'); createAlias('o2.club', 'c') throws. o2 names the same join as o. Use that join when the path starts at o2.

@borinquenkid
borinquenkid requested a review from matrei November 12, 2026 14:12
@borinquenkid
borinquenkid changed the base branch from 7.0.x to 7.1.x November 15, 2026 18:16
@borinquenkid

Copy link
Copy Markdown
Member Author

Retargeted from 7.0.x to 7.1.x. This adds a public SPI (MultipleAliasesMappingContext), and the PR template keeps 7.0.x (the patch branch) to bug fixes with no new API; 7.1.x is the lowest minor branch and merges up through 7.2.x to 8.0.x. No code changed (head 74b3759). #16891 is the 8.0.x half and still contains this commit.

…gh a component on a builder without a datastore, and from a second alias

A path through an embedded component was joined when the builder was made without a datastore, because
the component was found only through the mapping context; it is found through the Hibernate metadata then.

createAlias inside an association block did not qualify its path with the alias of the block, so
Hibernate resolved it against the root, and a property that starts at an alias declared in a block was
prefixed with the alias of the block. Both are qualified by the block's alias only when they do not start
at an alias of the query.

A path that starts at a second alias of a join (createAlias('owner', 'o2') after 'o') is the path of the
join the first alias names, so o2.club joins further from it.

Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
@borinquenkid

Copy link
Copy Markdown
Member Author

@jamesfredley All three cases reproduced, and are fixed in the new commit. AliasEmbeddedAndChainSpec has them; all three rows fail without the change.

  • createAlias('address.country', 'c') on new HibernateCriteriaBuilder(clazz, sessionFactory). The component was found only through the mapping context, which a builder without a datastore does not have, so address was joined. It is found through the Hibernate metadata then, and only country is joined.
  • The same path inside a block. createAlias did not qualify its path with the alias of the block, so Hibernate looked for address on the root, and a property that starts at an alias declared in the block (eq('c.name', ...)) was prefixed with the alias of the block. A path is qualified by the block's alias now, unless it starts at an alias of the query. The paths the builder joins itself are still written from the root.
  • createAlias('owner', 'o'); createAlias('owner', 'o2'); createAlias('o2.club', 'c'). o2 only names the join of o, so a path that starts at o2 is the path of o now. A rejection still names the path as it was written.

The Hibernate 5 module (740 tests) and codeStyle pass.

Branch policy: the new public type (MultipleAliasesMappingContext) and the new throw in AbstractHibernateCriteriaBuilder were already in this PR; this commit adds neither. Where the PR belongs is the open question, 7.1.x as it is now or 8.1.x, and I have not moved it.

If you find another shape that does not reproduce first time, a failing spec on a throwaway branch, or the few lines you ran, would help me a lot.

@jamesfredley jamesfredley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes. A second alias inside an association block throws. A path that starts at the root is now looked up on the association.

String lastAlias = getLastAlias();
if (lastAlias != null) {
// a property that starts at an alias of the query is not a property of the block
String head = dot > 0 ? propertyName.substring(0, dot) : null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pet { createAlias('owner', 'o'); createAlias('owner', 'ownerAgain'); eq('ownerAgain.name', 'A') } should return the shelf named one. It throws. The dot was counted before the alias was rewritten to a shorter name. Count it again after the rewrite.

@matrei

matrei commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Thanks for the fixes. I ran the queries from my review again at a21785a. createAlias('this.owner', 'o') and createAlias('address.country', 'c') work again, and the other fixes still hold.

Target branch. I'm afraid 7.1.x doesn't solve the branch question. The examples in the PR template date from before 7.1.0 and 8.0.0 shipped. 7.1.x has had eight patch releases since 7.1.0, so anything merged there ships in a 7.1.x patch release, and in 7.2.x and 8.0.x patch releases after the merge-up. Today 8.1.x (8.1.0-SNAPSHOT) is the only branch whose next release is a minor. So I'd suggest:

Two aliases of one path. This point from my review is still open. Owners A and B each have one score in round first and one in round second. On Hibernate 5:

Query Result
Owner.withCriteria { createAlias('scores', 'a'); createAlias('scores', 'b'); eq('a.round', 'first'); eq('b.round', 'second') } at a21785a []
The same restrictions in new DetachedCriteria(Owner).build { ... }.list() at a21785a QueryException: could not resolve property: a
The withCriteria query on 7.0.x QueryException: duplicate association path: scores

So the same query now fails in one API and silently returns nothing in the other. In the #16896 model, b has a join of its own, so Hibernate 7 should return [A, B]. Hibernate 5 can't join a path twice, so I'd keep the error when two aliases of one path are both declared. a21785a goes the other way: after createAlias('owner', 'o') and createAlias('owner', 'o2'), a path that starts at o2 now continues from the join of o. I think we should settle this before more cases are built on it. @jamesfredley, what do you think?

CI. The PR still has no ci, so its tests haven't run in CI on any branch yet. Please remove the label before this merges. A PR against 7.0.x also needs run ci.

@borinquenkid

Copy link
Copy Markdown
Member Author

@matrei: the #14647 fix is split out as #17105, on 7.0.x, with no new API: only the path-from-an-earlier-alias change in AbstractDetachedCriteria, its spec, and one note in the 7.0.18 section. The rest of this pull request, the opt-in and the Hibernate 5 builder change, moves to 8.1.x with #16891, as you suggest; I will retarget it and answer James's three cases and the two-aliases point there.

https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL

…dation-7.0.x

# Conflicts:
#	grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/query/criteria/AbstractDetachedCriteria.groovy
…one keeps the Hibernate error, and the specs register their entities the 8.1.x way

Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
@borinquenkid
borinquenkid changed the base branch from 7.1.x to 8.1.x November 20, 2026 22:56
@borinquenkid

Copy link
Copy Markdown
Member Author

@matrei: the base is 8.1.x now, as you suggest, and 8.1.x is merged into the branch; against it the pull request changes only its own nine files. The #14647 fix is in #17105 on 7.0.x. This pull request still carries the same lines for it, which go when #17105 is merged up.

Two aliases of one path. Hibernate 5 keeps the error, as you said. A second alias that a caller declares for a path that another declared alias already joins is no longer made another name of the first join: Hibernate refuses it with duplicate association path, as on 7.0.x. createAlias('owner', 'o'); createAlias('owner', 'o2'); createAlias('o2.club', 'c') throws on the second call. An alias for a join that the builder made itself for a block, owner { } and then createAlias('owner', 'o'), still names that join. The specs that pinned the old behavior now pin the refusal, and the three second-alias rows of AliasPathShapeMatrixSpec are refusal rows. Both modules pass.

@jamesfredley: pet { createAlias('owner', 'o'); createAlias('owner', 'ownerAgain'); eq('ownerAgain.name', 'A') } throws now, by that decision, and a feature pins it. Could you give me an example of the root-start path that is looked up on the association? I could not reproduce it from the review, and createAlias('this.owner', 'o') works.

https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants