How to retrieve latest record in entity's Set attribute


I was wondering what would be the best way to tackle this… I need to track a customer’s status and changes over time. My questions are:

  1. If I map the entities as attached, issues I ran into: retrieving the latest status for the customer.

customer ()>-(1) customer_status (1)-<() status

In SQL, I would use the following query:
select, max( customer_status cs
where = xyz
group by

Would you suggest:
a) Defining the above in a datasource using JPQL? If so, what’s the syntax; or
b) Creating my own custom datasource, helpers, etc.?

  1. I haven’t taken a look at the BPM module yet but this sounds like it would be a fit (there is an element of state and workflow in my requirements). However, I’m guessing I would still need to resolve the issue above?

Would appreciate your thoughts on this.


Hi Eddy,

  1. You can express the same in JPQL, see for example

Keep in mind that you need datasources only if you want to display or edit loaded data in visual components. Otherwise you can load data with DataManager or (on middleware) EntityManager. If you go for a datasource, use value datasources because normal datasources cannot return scalar values and aggregates.

  1. Please ask more concrete questions or write us at and we’ll provide a trial subscription for you to test the BPM addon.