[ 
https://issues.apache.org/jira/browse/OPENJPA-2975?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18119529#comment-18119529
 ] 

ASF subversion and git services commented on OPENJPA-2975:
----------------------------------------------------------

Commit 052a973cdd28efdfddb4d8e35211e032e39b89c7 in openjpa's branch 
refs/heads/OPENJPA-2975 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=052a973cd ]

[OPENJPA-2975] Narrow criteria TREAT joins instead of casting silently

The treat(Join/CollectionJoin/SetJoin/ListJoin/MapJoin, Class) overloads
only cast their argument, so no type narrowing was applied at all. A
treated join now resolves its attributes against the narrowed type and
binds its kernel variable to the narrowed metadata, which renders the
same discriminator condition as a JPQL TREAT join, including the
subclasses of the treated class.

A join that is correlated to an outer query, or that is reached from
such a join, carries no kernel variable of its own, so there is no
variable that could carry the narrowed metadata. Such a join is now
rejected with an UnsupportedOperationException rather than being
narrowed without any effect.

treat(Path, Class) delegates to the Root and Join implementations and
rejects any other path expression with an UnsupportedOperationException
instead of returning it unnarrowed.

The type restriction of a treated root is evaluated after the projection
and ordering terms, so that it is applied for a root that is treated in
the select clause only, and it now matches the subclasses of the treated
class as well.


> treat() join overloads silently cast without narrowing
> ------------------------------------------------------
>
>                 Key: OPENJPA-2975
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2975
>             Project: OpenJPA
>          Issue Type: Sub-task
>          Components: jpa
>    Affects Versions: 4.2.0
>            Reporter: Maxim Solodovnik
>            Priority: Major
>             Fix For: 4.2.0
>
>
> Discussion thread: 
> https://github.com/apache/openjpa/pull/144#discussion_r3683004426
> **(medium)** Only `treat(Root)` gets a real implementation 
> (`RootImpl.TreatedRoot`); all the join overloads (lines 429-450) and 
> `treat(Path)` (line 458) just cast and return the same object. That is a 
> silent no-op: no type narrowing is applied, but instead of the previous 
> explicit UnsupportedOperationException users now get wrong behavior with no 
> diagnostic. Could the unsupported overloads keep throwing (or get a 
> TreatedJoin analogous to TreatedRoot)?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to