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
name-----------------|---------type---------|---------cardinality---------
durum_bilgileri-------------Durum-----------------One-to-Many------

Entity : Durum
name-----------------|---------type---------|---------cardinality---------

talep---------------------------------------Talep--------------------------Many-to-One
status---------------------------------StatusEnum--------------------------------------------

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.
image

Any help would be appreciated.

Respect
Gürcan

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

talep.getLatestSituation().getStatus()

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.

Thanks

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