PL-8124 Exception occurs while trying to get related entities for several entity instances with the cardinality one-to-one

This commit is contained in:
Daniil Tsarev 2016-11-10 14:56:20 +04:00
parent b817a87428
commit 09522948b1

View File

@ -197,26 +197,24 @@ public class RelatedAction extends BaseAction implements Action.HasBeforeActionP
if (cardinality == Cardinality.MANY_TO_ONE) {
return getManyToOneCondition(parentIds, datasource, filterComponentName, primaryKey);
} else if (cardinality == Cardinality.ONE_TO_MANY) {
} else if (cardinality == Cardinality.ONE_TO_MANY || cardinality == Cardinality.ONE_TO_ONE) {
return getOneToManyCondition(parentIds, datasource, filterComponentName, primaryKey);
} else if (cardinality == Cardinality.MANY_TO_MANY) {
return getManyToManyCondition(parentIds, datasource, filterComponentName, primaryKey);
} else if (cardinality == Cardinality.ONE_TO_ONE) {
return getOneToOneCondition(parentIds, datasource, filterComponentName, primaryKey);
}
return null;
}
@Nullable
protected AbstractCondition getOneToOneCondition(List<Object> parentIds, CollectionDatasource datasource, String filterComponentName, String primaryKey) {
protected AbstractCondition getOneToManyCondition(List<Object> parentIds, CollectionDatasource datasource, String filterComponentName, String primaryKey) {
MetaProperty inverseField = metaProperty.getInverse();
if (inverseField == null) {
return null;
}
CustomCondition customCondition = getCustomCondition(parentIds, datasource, filterComponentName, primaryKey, false);
CustomCondition customCondition = getCustomCondition(parentIds, datasource, filterComponentName, primaryKey, true);
String whereString = String.format("{E}.%s.id = :%s", inverseField.getName(), paramName);
String whereString = String.format("{E}.%s.id in :%s", inverseField.getName(), paramName);
customCondition.setWhere(whereString);
return customCondition;
@ -242,21 +240,6 @@ public class RelatedAction extends BaseAction implements Action.HasBeforeActionP
return customCondition;
}
@Nullable
protected AbstractCondition getOneToManyCondition(List<Object> parentIds, CollectionDatasource datasource, String filterComponentName, String primaryKey) {
MetaProperty inverseField = metaProperty.getInverse();
if (inverseField == null) {
return null;
}
CustomCondition condition = getCustomCondition(parentIds, datasource, filterComponentName, primaryKey, true);
String whereString = String.format("{E}.%s.id in :%s", inverseField.getName(), paramName);
condition.setWhere(whereString);
return condition;
}
@Nullable
protected AbstractCondition getManyToOneCondition(List<Object> parentIds, CollectionDatasource datasource, String filterComponentName, String primaryKey) {
MetaProperty inverseField = metaProperty.getInverse();