I'm using JPA Criteria API, and in my query multiselect I want to retrieve an enum attribute, and not the enum itself.
This is my query :
final CriteriaQuery<MyClassDTO> query = builder.createQuery(MyClassDTO.class);
in MyClassDTO
I have 4 fields as following:
private String icon;
private String provenance;
private int sizeX;
private int sizeY;
And the path I'm retrieving data from is :
final Root<MyClass> from = query.from(MyClass.class);
MyClass
has 3 fields :
@Column
@Enumerated(EnumType.STRING)
private EnumTileIcon enumTileIcon;
@Column
@Enumerated(EnumType.STRING)
private EnumProvenance enumProvenance;
@Column
@Enumerated(EnumType.STRING)
private EnumSize enumSize;
What I want to do is to populate the MyClassDTO
using the query.multiselect
, something like this :
query.multiselect(
from.get(MyClass_.enumTileIcon.toString()),
from.get(MyClass_.enumProvenance.name()),
from.get(MyClass_.enumSize.getWidth()),
from.get(MyClass_.enumSize.getHeight())
);
How can I solve this ?