Hello,
I have an entity called “Parent” with two fields:
- firstField
- secondField
I also have two entities, “Child1” and “Child2”, both extending the “Parent” entity. “Child1” has an additional field called “thirdField,” and “Child2” has an additional field called “fourthField.”
These entities are stored in the same database table, where all four fields are present.
I would like to create a database query using a repository (or DataManager, if applicable). Initially, I want to query the “Parent” entity using a request like “SELECT p FROM Parent p WHERE firstField = :value.” In the future, I would like to cast the retrieved “Parent” object to either “Child1” or “Child2” and access the specific fields of each child entity.
However, when I attempt to do this, I encounter an exception stating:
Caused by: java.lang.IllegalStateException: Cannot get unfetched attribute [thirdField] from detached object com.example.entity.Child1-ad5ba90f-1a28-6faf-4bb0-2b0aa22819fc [detached].
Can you please help me understand how to achieve this functionality?