Hibernate: Temporary Tables instead Nested Queries

476 views Asked by At

This is my situation: I have a document that can have only one of 13 states. The state of a document changes in time and the the date of that change of state is needed. I have this tables:

Documents: id, name
DocumentState: id, idDocument, idState, date
States: id, name

I need to get all documents wich actual state (state with max date) is 1 or 12.

I tried to make this with a DetachedCriteria but it generates a neasted query that is pretty bad for perfomance, so, im looking for a way force hibernate to use a temporary table instead.

Thanks in advance

0

There are 0 answers