- Screen xml for keyValueCollection
<keyValueCollection id="sys_KeyValueEntitiesKeyValueCollectionDc">
<loader id="sys_KeyValueEntitiesKeyValueCollectionDl">
<query>
<![CDATA[
SELECT e.workAwayType AS workAwayType, SUM(e.totalDays) AS totalDays
FROM hr_WorkAwayOffice e
WHERE e.leaveYear.currentLeaveYear = true
AND e.employeeProfile.id = :employeeProfileId
GROUP BY e.workAwayType
]]>
</query>
</loader>
<properties>
<property class="com.inteacc.hr.entity.ls.WorkAwayType"
name="workAwayType"/>
<property datatype="decimal"
name="totalDays"/>
</properties>
</keyValueCollection>
Here workAwayType is enum.
- To load the data, called from controller
sys_KeyValueEntitiesKeyValueCollectionDl.setParameter("employeeProfileId", emplId);
sys_KeyValueEntitiesKeyValueCollectionDl.load(); // Ensure the loader executes properly
Here is the num structure:
public enum WorkAwayType implements EnumClass<Integer> {
WORK_FROM_ANYWHERE(10),
VISIT(20);
private final Integer id;
WorkAwayType(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
@Nullable
public static WorkAwayType fromId(Integer id) {
for (WorkAwayType at : WorkAwayType.values()) {
if (at.getId().equals(id)) {
return at;
}
}
return null;
}
}
Here is the error i get:
ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Enum (java.lang.Integer and java.lang.Enum are in module java.base of loader 'bootstrap')