Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Bug: Serverside dsRequest.addToCriteria creating inner NULL-criteria

    Hi Isomorphic,

    I found the following bug in serverside dsRequest.addToCriteria for the current 4.1d nightly (SNAPSHOT_v9.1d_2014-01-22/EVAL Deployment).
    I'm using Oracle 11g XE and Java 1.7.0_45 if this is important.

    Please create following DMI-fetch method or integrate it in a existing DMI class.
    I included four testcases in the java code:
    • dsRequest.addToCriteria(testSetCriterion) is creating an inner null-criterion for two different calls of new SetCriterion(...)
    • 3-param version of dsRequest.addToCriteria() is creating a 0=1 WHERE-clause in one case from above with the same parameters as used above for new SetCriterion(...)
    • 3-param version of dsRequest.addToCriteria() works as expected with the other parameters
      used for new SetCriterion(...)


    Please see below:
    Code:
    	public DSResponse fetchChildResellers(DSRequest dsRequest, HttpServletRequest servletRequest) throws Exception {
    		int i = dsRequest.getAdvancedCriteria().getCriteriaAsMap().size(); // 0
    		ArrayList<Long> myList = new ArrayList<Long>();
    		myList.add(-2L);
    		myList.add(1L);
    		SetCriterion testSetCriterion = null;
    		[B]// Testcase 1):[/B]
    		testSetCriterion = new SetCriterion("ID", DefaultOperators.InSet.getID(), myList);
    		[B]// Testcase 2):[/B]
    		testSetCriterion = new SetCriterion("ID", DefaultOperators.InSet.getID(), myList.toArray());
    		dsRequest.addToCriteria(testSetCriterion);
    		Map m = dsRequest.getAdvancedCriteria().getCriteriaAsMap(); // Exception
    		// Watch dsRequest.getAdvancedCriteria() in Eclipse Debugger Expressions to
    		// see that the 1st element in
    		// dsRequest.getAdvancedCriteria() -> criteria ->mCriteria -> elementData ->
    		// [0] is null.
    		[B]// Testcase 3):[/B]
    		// Remove the dsRequest.addToCriteria(testSetCriterion) above and replace by:
    		dsRequest.addToCriteria("ID", DefaultOperators.InSet.getID(), myList.toArray());
    		/*
    		Generates WHERE clause: WHERE ( ('0' = '1')), criteria from log are:
    		=== 2014-01-22 18:58:45,156 [c-10] INFO  SQLDataSource - [builtinApplication.fetchChildResellers] Performing fetch operation with
    			criteria: {criteria:[{value:[-2,1],fieldName:"ID",operator:"inSet"}],operator:"and",_constructor:"AdvancedCriteria"}	values: {criteria:[{value:[-2,1],fieldName:"ID",operator:"inSet"}],operator:"and",_constructor:"AdvancedCriteria"}
    		 */
    		[B]// Testcase 4):[/B]
    //		dsRequest.addToCriteria("ID", DefaultOperators.InSet.getID(), myList);
    		/*
    		Works as expected:
    		Generates WHERE clause: WHERE ( ( (t_reseller.id IN (-2, 1)) AND t_reseller.id IS NOT NULL))
    		Criteria from log are:
    		=== 2014-01-22 19:02:30,960 [ec-4] INFO  SQLDataSource - [builtinApplication.fetchChildResellers] Performing fetch operation with
    			criteria: {criteria:[{value:[-2,1],fieldName:"ID",operator:"inSet"}],operator:"and",_constructor:"AdvancedCriteria"}	values: {criteria:[{value:[-2,1],fieldName:"ID",operator:"inSet"}],operator:"and",_constructor:"AdvancedCriteria"}
    		--> Exactly the same as above, but this time the WHERE clause is as expected! 
    		 */
    		return dsRequest.execute();
    	}
    In the ds.xml I have the following lines:
    Code:
    <field primaryKey="true" hidden="true" name="ID" type="sequence" />
    .....
    	<serverObject lookupStyle="new" className="com.lmscompany.lms.server.worker.T_RESELLER" />
    	<operationBindings>
    		<operationBinding operationType="fetch" operationId="fetchChildResellers" serverMethod="fetchChildResellers">
    		</operationBinding>
    	</operationBindings>
    Please let me know if you can't reproduce.

    Best regards,
    Blama

    #2
    The fix will be in nightly builds on 4.1d as of tomorrow.

    Regards.
    Isomorphic Software

    Comment

    Working...
    X