| Summary: | BatchFetchType.IN does not consider a mappings selection criteria | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Michael Nielson <michaelnielson> |
| Component: | Eclipselink | Assignee: | Project Inbox <eclipselink.foundation-inbox> |
| Status: | NEW --- | QA Contact: | |
| Severity: | normal | ||
| Priority: | P2 | CC: | antonio.petrelli, jamesssss, nicolas.marcotte, ruebe356, tom.ware |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Michael Nielson
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 |