Victor Mariano Lessa de Assis (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNDhlNmUxZWNj...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16798?atlOrigin=eyJpIjoiNDhlNm...
) HHH-16798 (
https://hibernate.atlassian.net/browse/HHH-16798?atlOrigin=eyJpIjoiNDhlNm...
) ClassCastException in Hibernate 6 when "join fetch" is used in a query with
entity inheritance (
https://hibernate.atlassian.net/browse/HHH-16798?atlOrigin=eyJpIjoiNDhlNm...
)
Issue Type: Bug Affects Versions: 6.2.4 Assignee: Unassigned Attachments: src.tar.gz
Created: 14/Jun/2023 09:03 AM Priority: Major Reporter: Victor Mariano Lessa de Assis (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%...
)
em.createQuery("select e from " + Entity1.class.getSimpleName() + " e left
join fetch e.subClass1 left join fetch e.subClass2 ",
Entity1.class).getSingleResult()
This query used to work in Hibernate 5, but I'm getting the following error in
Hibernate 6:
Exception in thread "main" java.lang.ClassCastException: class
org.example.entity.SubClass1 cannot be cast to class org.example.entity.SubClass2
(org.example.entity.SubClass1 and org.example.entity.SubClass2 are in unnamed module of
loader 'app')
@Entity
@Getter
@Setter
public class Entity1 {
@Id
String id;
@OneToOne(fetch = FetchType.LAZY, mappedBy = "entity1")
protected SubClass1 subClass1;
@OneToOne(fetch = FetchType.LAZY, mappedBy = "entity1")
protected SubClass2 subClass2;
}
@Entity
@Getter
@Setter
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public abstract class SuperClass implements Serializable {
@Id
public String id;
@ManyToOne
protected Entity1 entity1;
}
@Entity
@DiscriminatorValue("1")
public class SubClass1 extends SuperClass {
}
@Entity
@DiscriminatorValue("2")
public class SubClass2 extends SuperClass {
}
(
https://hibernate.atlassian.net/browse/HHH-16798#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16798#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#100226- sha1:c25eebb )