By design, DetachedCriteria are intended to be serializable and this is something we have been leveraging in our result paging system for years. We are now hitting an issue when adding subqueries to the detached criteria where our session replication breaks on the serialization attempt.
In contrast to the rest of the DetachedCriteria object graph, the following classes are not serializable:
{code} org.hibernate.loader.criteria.CriteriaQueryTranslator org.hibernate.engine.spi.QueryParameters {code}
Instances of these can be present inside of any SubqueryExpression instance, which makes its way into is connected to a DetachedCriteria instance by way of as follows :
{code} instance<DetachedCriteria>.criteria<CriteriaImpl>.criterionEntries<List<CriterionEntry>> {code}
An example criteria that ends up with a PropertySubqueryExpression in that List:
{code} DetachedCriteria mainCriteria = DetachedCriteria.forClass(ParticipantAsset.class); DetachedCriteria subQ = DetachedCriteria.forClass(Ownership.class); subQ.add(Restrictions.eq("pid", pid)); subQ.setProjection(Property.forName("guid")); mainCriteria.add(Property.forName("participant.guid").in(subQ)); {code} |
|