Ádám Simon (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5d9c852...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNzk0NjkwMTA0...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-17070?atlOrigin=eyJpIjoiNzk0Nj...
) HHH-17070 (
https://hibernate.atlassian.net/browse/HHH-17070?atlOrigin=eyJpIjoiNzk0Nj...
) Delete query gives ClassCastException (
https://hibernate.atlassian.net/browse/HHH-17070?atlOrigin=eyJpIjoiNzk0Nj...
)
Issue Type: Bug Affects Versions: 6.1.7 Assignee: Unassigned Components: hibernate-core
Created: 11/Aug/2023 02:25 AM Priority: Major Reporter: Ádám Simon (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5d9c852...
)
Our delete query fails with ClassCastException:
class org.hibernate.metamodel.mapping.internal.BasicAttributeMapping cannot be cast to
class org.hibernate.metamodel.mapping.EntityValuedModelPart
(org.hibernate.metamodel.mapping.internal.BasicAttributeMapping and
org.hibernate.metamodel.mapping.EntityValuedModelPart are in unnamed module of loader
'app')
query is (hiding business namings):
@Repository
public interface ABCEntityRepository extends CrudRepository<ABCEntity, Long> {
@Modifying
@Query("DELETE FROM ABCEntity abc"
+ " WHERE abc.eId IS NOT NULL "
+ "AND abc.cId = :cId "
+ "AND abc.pId = :pId "
+ "AND abc.rId IN ("
+ "SELECT r "
+ "FROM REntity r "
+ "WHERE r.joinedentity.id = :aId"
+ ")"
)
void deleteABCWithRId(@Param("aId") String aId,
@Param("cId") String cId, @Param("pId") String pId);
}
I tried to debug into Hibernate, and I got until
BaseSqmToSqlAstConverter.visitWhereClause() → .visitJunctionPredicate()
where in the first for cycle is reaching the fourth subpredicate (rId).
I guess there is some issue with the nested select, but not sure if it is intentional
(would be a dedicated HibernateException for that) or is a bug (I think so)
(
https://hibernate.atlassian.net/browse/HHH-17070#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-17070#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#100234- sha1:39b0f46 )