I am trying to create a data table with pagination. However my problem is that I would rather use the entity query defined in components.xml.
My query is somewhat like this
select itemDetail from Item item, ItemDetail itemDetail where item.itemId = itemDetail.id.itemId and item.expiryDate > :adate and item.userId = :currUser and itemDetail.id.itemDetailDate = (select max(i.id.itemDetailDate) from ItemDetail i where i.id.itemId = itemDetail.id.itemId)
The aDate and currUser is coming from an object.
If I have this query in a session bean and use the @Factory annotation to get the List, it works fine in a data Table.
Can I formulate the ejbql and restrcitions (including the subquery) ?