Hi Isomorphic,
I have a use case where I gather Criterion-Objects in a ArrayList<Criterion>.
Until now, I fed only SetCriterion to it and converted with:
No I realized that I don't need a SetCriterion if the Set consists only of 1 item. So I switched to SimpleCriterion for this.
This does not work, and I assume this is because of the internal representation of the SimpleCriterion.
While the SetCriterion is a JavaObject, the SimpleCriterion is a String, see screenshot of Eclipse debug mode.
This leads to this exception for the return statement:
The whole method is:
As this takes basically takes a some HashSet<Long> as only inputs, it is easy to reproduce, even without the the called methods.
I'm using v9.1p_2014-06-29.
Best regards,
Blama
I have a use case where I gather Criterion-Objects in a ArrayList<Criterion>.
Until now, I fed only SetCriterion to it and converted with:
Code:
return new AdvancedCriteria(DefaultOperators.Or, additionalOrCrit.toArray(new SetCriterion[additionalOrCrit.size()])).asCriterion();
This does not work, and I assume this is because of the internal representation of the SimpleCriterion.
While the SetCriterion is a JavaObject, the SimpleCriterion is a String, see screenshot of Eclipse debug mode.
This leads to this exception for the return statement:
Code:
=== 2014-07-04 15:38:47,876 [ec-5] WARN RequestContext - dsRequest.execute() failed:
java.lang.ArrayStoreException
at java.lang.System.arraycopy(Native Method)
at java.util.ArrayList.toArray(Unknown Source)
at com.lmscompany.lms.server.util.Criteria.getCreatedByLegalEntityCriterion(Criteria.java:128)
at com.lmscompany.lms.server.worker.T_CAMPAIGN.fetchOwnAndOtherLECampaigns(T_CAMPAIGN.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:975)
at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:416)
at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:64)
at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2549)
at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:215)
at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:172)
Code:
public static Criterion getCreatedByLegalEntityCriterion(DSRequest dsRequest, TreeDirection treeDirection) throws Exception {
HashMap<String, HashSet<Long>> legalEntityStructure = User.getLegalEntityStructure(dsRequest, treeDirection);
if (legalEntityStructure == null)
return null;
ArrayList<Criterion> additionalOrCrit = new ArrayList<Criterion>();
for (LegalEntityType legalEntityType : LegalEntityType.values()) {
if (getEqualsOrSetCriterion(legalEntityStructure, legalEntityType) != null)
additionalOrCrit.add(getEqualsOrSetCriterion(legalEntityStructure, legalEntityType));
}
if (additionalOrCrit.size() >= 2)
return new AdvancedCriteria(DefaultOperators.Or, additionalOrCrit.toArray(new SetCriterion[additionalOrCrit.size()])).asCriterion();
if (additionalOrCrit.size() == 1)
return additionalOrCrit.get(0);
else
return null;
}
I'm using v9.1p_2014-06-29.
Best regards,
Blama