Reputation: 422
I'm trying to build a query on the fly from a custom query object.
At one point in the code, the orderBy may be added to a DetachedCriteria. Later down the line, I'd like to add an orderBy should none already exist in the DetachedCriteria. Looking through the docs, I can't seem to find any way to access this information.
Is there some way to do this?
(Of course if it's impossible, I'll just refactor my code around this)
Upvotes: 0
Views: 178
Reputation: 1068
Can you try this :
DetachedCriteria detached; //intialized DetachedCriteria
Session s; //intialized hibernate session
//get the criteriaImpl executing the query
CriteriaImpl executableCriteria = (CriteriaImpl) detached.getExecutableCriteria(s);
//return new iterator of the OrderEntries
Iterator<CriteriaImpl.OrderEntry> orderEntryIterator = executableCriteria.iterateOrderings();
//check if it has an order entry
if (orderEntryIterator.hasNext()) {
}
Hope it will help.
Upvotes: 1