Filter for Newest of Second Table Content

Hi there,

I need help for creating a filter in Cuba Platform. Data Model is basically like this:

Entity : Talep

Entity : Durum


StatusEnum is an enumeration. I want the Talep objects that have the latest status information as given input.

So far, I have come up with the below filter which does not consider the last status.

Any help would be appreciated.


Hi Gürcan,

Your filter query will give you all Talep objects that have Durum objects with the given status.
What do you mean by “latest” status?

Hi Konstantin,

Let me explain all entity names in English. Talep means “Demand”, and Durum means “Situation” in English. One-to-many relation exists between Demand and Situation entities.

In Demand.Browse page, I have created a custom column named “Situation”. In this column, status of last Situation is shown. Last situation is found by date(createTs) property. In the background, “Situation” column is filled with something like


I need a filter that shows the “demands” has the latest “situation” with given “status”.

Example : User selects status Finished.
Output : Demands have the latest situation with “Finished” status are shown to user.

I have a different solution also, add another boolean property to Situation entity. Set to True for the latest situation only. If you have different methods, I’d like to hear them too.


I would suggest using the additional boolean property for the latest Situation. A little denormalization always helps in queries. Your filter conditions will become trivial:
Join: {E}.situation s
Where: s.status = ? and s.latest = true