[ https://issues.apache.org/jira/browse/CAY-2878?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrus Adamchik updated CAY-2878: --------------------------------- Description: DataDomainQueryAction.interceptRelationshipQuery(..) has a check: {noformat} if (relationship.isSourceIndependentFromTargetChange()) { return !DONE; } {noformat} Which is reasonable for to-many relationships. But for PK-to-PK optional 1..1, it misses the opportunity to find the target object in the shared snapshot cache. We need to be smarter. Cache will not help us to determine whether the target object is NULL, but a presence of a target object would save us a DB trip. The logic should be something like this: {noformat} if (relationship.isSourceIndependentFromTargetChange()) { if(/* can guess target ObjectId */) { /* check for snapshot in the cache */ /* if found, return */ /* if not found, return !DONE*/ } return !DONE; } {noformat} was: DataDomainQueryAction.interceptRelationshipQuery(..) has a check: {noformat} if (relationship.isSourceIndependentFromTargetChange()) { return !DONE; } {noformat} Which is reasonable for to-many relationships. But for PK-to-PK optional 1..1, it misses the opportunity to find the target object in the shared snapshot cache. We need to be smarter. Cache will not help us to determine whether the target object is NULL, but a presence of a target object would save us a DB trip. The logic should be something like this: ``` if (relationship.isSourceIndependentFromTargetChange()) { if(/* can guess target ObjectId */) { /* check for snapshot in the cache */ /* if found, return */ /* if not found, return !DONE*/ } return !DONE; } ``` > PK-to-PK optional 1..1 relationships should be resolved from the snapshot > cache > ------------------------------------------------------------------------------- > > Key: CAY-2878 > URL: https://issues.apache.org/jira/browse/CAY-2878 > Project: Cayenne > Issue Type: Improvement > Reporter: Andrus Adamchik > Priority: Major > > DataDomainQueryAction.interceptRelationshipQuery(..) has a check: > {noformat} > if (relationship.isSourceIndependentFromTargetChange()) { > return !DONE; > } > {noformat} > Which is reasonable for to-many relationships. But for PK-to-PK optional > 1..1, it misses the opportunity to find the target object in the shared > snapshot cache. We need to be smarter. Cache will not help us to determine > whether the target object is NULL, but a presence of a target object would > save us a DB trip. The logic should be something like this: > {noformat} > if (relationship.isSourceIndependentFromTargetChange()) { > if(/* can guess target ObjectId */) { > /* check for snapshot in the cache */ > /* if found, return */ > /* if not found, return !DONE*/ > } > return !DONE; > } > {noformat} -- This message was sent by Atlassian Jira (v8.20.10#820010)