apache / apache/grails-core

Instanceof behaviors broken when querying a container class in the same session

Open
#14,557 0 comments 0 reactions 0 assignees View on GitHub
relates-to: gorm
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

### Task List

- [x] Steps to reproduce provided
- [x] Stacktrace (if present) provided
- [x] Example that reproduces the problem uploaded to Github
- [x] Full description of the issue provided (see below)

### Steps to Reproduce

In the context of the sample project, we have a "Drawing" entity that contains a "Shape" entity. "Shape" is sub-typed to "Circle" in this case.

1. In a session, query the "Drawing" table using any method (where queries, finders, etc)
2. Attempt to use `instanceof` on a "Shape" instance from the table

### Expected Behaviour

The shape instance should be `instanceof` Circle.

### Actual Behaviour

`instanceof Circle` returns false

### Environment Information

- **Operating System**: Fedora Linux Workstation 28
- **GORM Version:** 6.1.10.RELEASE, 6.0.12.RELEASE
- **Grails Version (if using Grails):** 3.2.13
- **JDK Version:** openjdk version "1.8.0_181"

### Example Application

- https://github.com/joemccall86/gorm-upgrade-instof

Contributor guide

Open the contributing guide

Research direction

Start by running the linked gorm-upgrade-instof example application and inspect how Drawing, Shape, and Circle are mapped and queried in the same session. Reproduce the query, trace the returned Shape instance, and verify that it is recognized as an instance of Circle without breaking other inheritance behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.