Every so often, I get a "org.hibernate.QueryException: duplicate association path: myAssociation". This is because the complex criteria I'm working with can define the same path in many places. I'd love to do something like
Criteria association = myCriteria.getAssociation("wax");
if(association == null) association = myCriteria.createCriteria("wax");
Is there any such way that I can check if an association is already in place?
Cheers
Nik
Actually you could find Subcriteria by alias, but the code is not published (i.e. in CriteriaImpl class). See my example below:
private Subcriteria getCritria(Criteria pCriteria, String pAlias) {
Iterator<Subcriteria> iter = ((CriteriaImpl)pCriteria).iterateSubcriteria();
while (iter.hasNext()){
Subcriteria sub = iter.next();
if (pAlias.equals(sub.getAlias())){
return sub;
}
}
return null;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With