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

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

Commit 94d34574543398a53d5b0e9b58b227f4c4720b6d in openjpa's branch 
refs/heads/OPENJPA-2977 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=94d345745 ]

[OPENJPA-2961] Include subclasses of the treated class in the TREAT 
discriminator filter (#189)

* [OPENJPA-2961] Include subclasses of the treated class in the TREAT 
discriminator filter

Build the TREAT condition through the discriminator strategy's class
conditions, so that subclasses of the treated type are matched with an IN
over their discriminator values.

* [OPENJPA-2961] Use try-with-resources for the EntityManager in the TREAT 
subclass test

* [OPENJPA-2961] Restrict a predicate over a TREAT path to the treated type

A TREAT(x AS Type) path in a WHERE clause only overrode the metadata of the
path, so rows of other types matched a predicate on an attribute they share
with the treated type. As defined by the specification, such a predicate is
now false if x is not an instance of Type or one of its subclasses. The
restriction is added to the predicate containing the TREAT path, so other
branches of an OR are not affected.

* [openjpa-2961] Adds other tests on TREAT impl

* [openjpa-2961] Adds header to test entity

* Tab/Space mixture is fixed

---------

Co-authored-by: Paulo Cristovão de Araújo Silva Filho <[email protected]>
Co-authored-by: Maxim Solodovnik <[email protected]>

> TREAT discriminator filter excludes subclasses of target
> --------------------------------------------------------
>
>                 Key: OPENJPA-2961
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2961
>             Project: OpenJPA
>          Issue Type: Sub-task
>          Components: jpa
>    Affects Versions: 4.2.0
>            Reporter: Maxim Solodovnik
>            Assignee: Richard Zowalla
>            Priority: Major
>             Fix For: 4.2.0
>
>
> Discussion thread: 
> https://github.com/apache/openjpa/pull/144#discussion_r3683001854
> **(medium)** `appendTreatDiscriminator` emits `disc = <treated class value>` 
> only. Per JPA, `TREAT(x AS Middle)` must also match subtypes of Middle, so 
> for a 3-level hierarchy this incorrectly filters out instances of Middle's 
> subclasses - it should be an IN over the discriminator values of the treated 
> class and all mapped subclasses. It also only handles `cols[0]` of the 
> discriminator.



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

Reply via email to