Community
Participate
Working Groups
Using the example here: http://wiki.eclipse.org/EclipseLink/Examples/JPA/MappingSelectionCriteria OneToOneMapping mapping = (OneToOneMapping)descriptor.getMappingForAttributeName("manager"); ExpressionBuilder builder = new ExpressionBuilder(); mapping.setSelectionCriteria(builder.getField("EMPLOYEE.DEPT_ID").equal(builder.getParameter("DEPARTMENT.DEPT_ID"). and(builder.getField("EMPLOYEE.POSITION").equal("MANAGER")); A query on this mapping with an IN batch type will return incorrect results. query.setHint("eclipselink.batch.type", "IN"); query.setHint("eclipselink.batch", "manager"); They predicate should be: WHERE POSITION = 'MANAGER' AND DEPT_ID IN (...) They predicate is: WHERE DEPT_ID IN (...)
This bug does seem like a fairly significant issue as it can lead to data corruption in the identityMap and incorrect batch query results. As a workaround I've overridden buildBatchCriteria and added an additionalCriteria variable to my mapping. protected Expression _additionalCriteria; public Expression getAdditionalCriteria() { return _additionalCriteria; } public void setAdditionalCriteria(Expression additionalCriteria) { this._additionalCriteria = additionalCriteria; setSelectionCriteria(buildSelectionCriteria().and(getAdditionalCriteria())); } // to ease development @Override public void setSelectionCriteria(Expression anExpression) { assert false : "setSelectionCriteria should not be called directly, use setAdditionalCriteria instead"; super.setSelectionCriteria(anExpression); } // add in additional criteria to batch query @Override protected Expression buildBatchCriteria(ExpressionBuilder builder, ObjectLevelReadQuery query) { Expression criteria = super.buildBatchCriteria(builder, query); if(getAdditionalCriteria() != null) { criteria = criteria.and(getAdditionalCriteria()); } return criteria; }
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next.
the @JoinFetch(Outer) is also affected by this bug. Should I write a new report with a small self contained test case and link to here or should I open a separate ticket ?
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink