JPA Criteria API support

Hi there,

We have a portal client needs to do JPQL query for dynamic fields based on the value of a known variable. For example, assume we have an entity of Weekdays, it has properties of sunday to saturday. Based on today’s day of the week, we need to query this entity to get the value of that particular column. For example, if today is monday, we’d like to

    select e.monday from portalProject$Weekdays e

and if today is friday, we’d like to:

    select e.friday from portalProject$Weekdays e

Please note that Weekdays entity has only a few columns just for an example, we have other entities that have much larger number of columns in similar situation. Thus we can not afford to load unwanted columns for resources consumption.

Ideally we would like to use Criteria API like this to achieve the goal:

I searched the forum about Criteria API, it seems cuba has not supported it yet. Would it be any plan to support it, or what would you suggest as an alternative if no plan to support it?

Thank you,

Hi Mike,

CUBA does not support Criteria API and we don’t have plans about it. We have some thoughts on this topic, see the issue and the linked discussion.

An obvious workaround for you is just constructing an appropriate JPQL string.

1 Like

Thank you for clarifying this, Konstantin.