[JIRA] (HHH-16858) Can't compare test expression of type [BasicSqmPathSource(type : Enum)] with element of type [basicType@5(java.lang.Integer,4)]
by Jonas Gernot Steinke (JIRA)
Jonas Gernot Steinke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiN2MxMzU0MjYy... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16858?atlOrigin=eyJpIjoiN2MxMz... ) HHH-16858 ( https://hibernate.atlassian.net/browse/HHH-16858?atlOrigin=eyJpIjoiN2MxMz... ) Can't compare test expression of type [BasicSqmPathSource(type : Enum)] with element of type [basicType(a)5(java.lang.Integer,4)] ( https://hibernate.atlassian.net/browse/HHH-16858?atlOrigin=eyJpIjoiN2MxMz... )
Issue Type: Bug Affects Versions: 6.2.4, 6.2.5 Assignee: Unassigned Components: query-hql Created: 27/Jun/2023 07:07 AM Environment: Hibernate Version 6.2.5.Final
JDK: azul-19.0.2
OS: Ubuntu 20.04.6 LTS
MySQL 8.0.33-0ubuntu0.20.04.2 Priority: Major Reporter: Jonas Gernot Steinke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%... )
With the update of Vaadin from version 14 to 24, Hibernate was also updated. In the process, I noticed a problem in the current Hibernate versions.
Normally Vaadin 24 uses Hibernate 6.2.2.Final, but this version also has problems with generic types and I'm switching to 6.2.4.Final, that fixes it for another project.
Now I found another issue in Hibernate also related to generic types.
I have created a small Vaadin 24 project to illustrate the issue. This example can be found on GitHub: https://github.com/JGSteinke/hibernate-test
I have created two classes ItemA and ItemB. ItemA uses an enum and ItemB extends AbstractItem. This uses a generic type which must be an enum.
Now I want to use < with the enum field and a constant within an query.
In the case of ItemA this is not a problem at all, but for ItemB I get the following exception: Can't compare test expression of type [BasicSqmPathSource(type : Enum)] with element of type [basicType(a)5(java.lang.Integer,4)]
See following code snippets fore context. Actual sources are linked below.
@MappedSuperclass
public abstract class AbstractItem<T extends Enum<T>> extends AbstractEntity implements Item<T> {
@Enumerated(EnumType.ORDINAL)
@Column(name = "type" , nullable = false )
protected T type;
@Override
public T getType() {
return type;
}
public void setType(T type) {
this.type = type;
}
}
https://github.com/JGSteinke/hibernate-test/blob/main/src/main/java/de/hi...
@Entity
@Table(name = "item_b" )
public class ItemB extends AbstractItem<ItemB.Type> {
enum Type {
B1, B2, B3;
}
}
https://github.com/JGSteinke/hibernate-test/blob/main/src/main/java/de/hi...
public interface ItemBRepository extends JpaRepository<ItemB, Long >, JpaSpecificationExecutor<ItemB> {
@Query( "SELECT b FROM ItemB b WHERE b.type < 1" )
List<ItemB> findAllByTypeB2();
}
https://github.com/JGSteinke/hibernate-test/blob/main/src/main/java/de/hi...
I use types like ItemB in many cases on Hibernate 5.1.0 without problems.
( https://hibernate.atlassian.net/browse/HHH-16858#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16858#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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100227- sha1:3bc807d )
1 year, 8 months