Amit Kumar (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63f46e5...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZTlkYmI0OWEw...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16208?atlOrigin=eyJpIjoiZTlkYm...
) HHH-16208 (
https://hibernate.atlassian.net/browse/HHH-16208?atlOrigin=eyJpIjoiZTlkYm...
) Table with @Inheritance(strategy = InheritanceType.JOINED) strategy fetching wrong
column of Jsonb type (
https://hibernate.atlassian.net/browse/HHH-16208?atlOrigin=eyJpIjoiZTlkYm...
)
Issue Type: Bug Assignee: Unassigned Created: 20/Feb/2023 23:45 PM Priority: Major
Reporter: Amit Kumar (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63f46e5...
)
Problem
I have created three entities with the strategy InheritanceType.JOINED.
Parent entity looks like this:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class A<E extends AJsonContent> extends AbstractDomainJsonEntity<E,
String> {
@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy =
"org.hibernate.id.UUIDGenerator")
@NotNull(groups = OnUpdate.class)
@Null(groups = OnCreate.class)
@Column(name = "a_id", columnDefinition = "VARCHAR(255)")
@JsonProperty("aId")
@Schema(description = "This attribute indicates unique id of
OriginationJsonApplication")
private String id;
private String aAttribute;
}
The first child is:
@Entity
public class B extends A<BAttribute> {
private String bAttribute;
}
The second child is:
@Entity
public class C extends A<CAttribute> {
private String cAttribute;
}
Here parent has a column of jsonb type whose type is being passed by child entities using
generics argument A<E extends AJsonContent> and argument should of subtype
AJsonContent.
BAttribute and CAttribute are children of AJsonContent and they represent jsonb column.
Now, when bRepository.findById() is called, it returns an instance of B with jsonb column
CAttribute instead of BAttribute.
When I removed C entity completely, then it is working fine. But when it B and C are both
together it fetches the wrong jsonb column for the B entity.
What could be the reason for this behavior?
(
https://hibernate.atlassian.net/browse/HHH-16208#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16208#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100216- sha1:3fa9804 )