[ 
https://issues.apache.org/jira/browse/CAY-2838?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Nikita Timofeev closed CAY-2838.
--------------------------------
    Resolution: Fixed

New fix is ready

*5.0*: 
https://github.com/apache/cayenne/commit/e60ac710be75799a735bbe1a458b4ba09704a5c7

*4.2*: 
https://github.com/apache/cayenne/commit/cc51de1baecc1e67e08206a9603d8618cb91aecd
 + following commits

> Vertical Inheritance: Problem setting db attribute to null via flattened path
> -----------------------------------------------------------------------------
>
>                 Key: CAY-2838
>                 URL: https://issues.apache.org/jira/browse/CAY-2838
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 4.2
>         Environment: Cayenne 4.2, Java 17, MacOS 14
>            Reporter: Jadon Hansell
>            Assignee: Nikita Timofeev
>            Priority: Major
>             Fix For: 4.2.1, 5.0-M1
>
>         Attachments: NullifyFlattenedTests.patch, 
> concrete-to-abstract-error.patch
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> While using vertical inheritance, I ran into a bug with a non-required 
> attribute on a child {{{}DbEntity{}}}. The issue occurs when an attribute, 
> accessed via a flattened path like '{{{}child.attr{}}}' on the child's 
> {{{}ObjEntity{}}}, is initially set to a value and then later changed to 
> null. This causes Cayenne to attempt to set the primary key of the {{child}} 
> db entity to null as well.
> I've attached a patch that contains failing tests demonstrating this issue on 
> both an ObjEntity's attribute and a belongs-to relationship.
> A temporary workaround I've used is to relocate these columns to the parent 
> DbEntity so the path isn't flattened.
>  
> The root of the problem appears to start in the 
> {{{}ValuesCreationHandler{}}}. During the operation, it runs 
> {{processFlattenedPath}} to identify the target row's ID, with 
> {{{}add=false{}}}. This then iterates through the db path components and 
> invokes {{processRelationship}} for each db relationship, again with 
> {{{}add=false{}}}.
> While processing the first path component, {{processRelationship}} creates an 
> {{UPDATE}} row operation, attempting to update the child's uuid to its 
> current value (case 2 in the comments). Normally, this would not cause an 
> error. But, because the '{{{}add'{}}} parameter is set to false, the 
> {{ValuePropagationVisitor}} replaces the current ID with null.



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

Reply via email to