I am getting incorrect results from the server-side AdvancedCriteria:
EntryPoint:
table.ds.xml:
TestDMIHandler:
The result query, which is incorrect:
The correct SQL would be:
What is happening here ?
Using SmartGWT 4.1p power v9.1p_2014-10-28/PowerEdition Deployment (built 2014-10-28) with MSSQL 2014.
EntryPoint:
Code:
public class TestingModule implements EntryPoint { @Override public void onModuleLoad() { ListGrid lg = new ListGrid(); lg.setDataSource(DataSource.get("table")); ListGridField idField = new ListGridField("f_id"); idField.setTitle("ID"); lg.setFields(idField); lg.setWidth100(); lg.setHeight100(); final VStack layout = new VStack(10); layout.setWidth100(); layout.setHeight100(); layout.setMembers(lg); lg.fetchData(); layout.draw(); } }
Code:
<DataSource ID="table" serverType="sql" tableName="t_vertrag"> <fields> <field name="f_id" type="sequence" primaryKey="true" /> <field name="f_vertrag_gekuendigt" type="date" /> <field name="f_vertrag_beginn" type="date" /> <field name="f_vertragsende" type="date" /> </fields> <operationBindings> <operationBinding operationType="fetch"> <serverObject className="de.mks_infofabrik.kids.server.dmi.TestDMIHandler" methodName="doFetch" /> </operationBinding> </operationBindings> </DataSource>
Code:
public class TestDMIHandler { public DSResponse doFetch(DSRequest dsRequest) throws Exception { dsRequest.setAdvancedCriteria(getSchuelerCriteria(new Date())); DSResponse response = dsRequest.execute(); return response; } private AdvancedCriteria getSchuelerCriteria(Date stichtag) { AdvancedCriteria vertragGekuendigtCriteria = new AdvancedCriteria( DefaultOperators.Or.getID(), new Criterion[] { new IsNullCriterion("f_vertrag_gekuendigt"), new SimpleCriterion("f_vertrag_gekuendigt", DefaultOperators.LessThan.getID(), stichtag) }); AdvancedCriteria vertragZeitraumCriteria = new AdvancedCriteria( DefaultOperators.And.getID(), new Criterion[] { new SimpleCriterion("f_vertrag_beginn", DefaultOperators.LessOrEqual.getID(), stichtag), new SimpleCriterion("f_vertragsende", DefaultOperators.GreaterOrEqual.getID(), stichtag) }); AdvancedCriteria schuelerCriteria = new AdvancedCriteria( DefaultOperators.And.getID(), vertragGekuendigtCriteria.asCriterion(), vertragZeitraumCriteria.asCriterion()); return schuelerCriteria; } }
Code:
SELECT t_vertrag.f_id, t_vertrag.f_vertrag_gekuendigt, t_vertrag.f_vertrag_beginn, t_vertrag.f_vertragsende FROM t_vertrag WHERE (((t_vertrag.f_vertrag_gekuendigt IS NULL) OR (t_vertrag.f_vertrag_gekuendigt < '20141103' OR t_vertrag.f_vertrag_gekuendigt IS NULL)) AND ((t_vertrag.f_vertrag_beginn <= '20141103' OR t_vertrag.f_vertrag_beginn IS NULL) AND (t_vertrag.f_vertragsende >= '20141103' AND t_vertrag.f_vertragsende IS NOT NULL)))
Code:
SELECT t_vertrag.f_id, t_vertrag.f_vertrag_gekuendigt, t_vertrag.f_vertrag_beginn, t_vertrag.f_vertragsende FROM t_vertrag WHERE (((t_vertrag.f_vertrag_gekuendigt IS NULL) OR (t_vertrag.f_vertrag_gekuendigt < '20141103' AND t_vertrag.f_vertrag_gekuendigt IS NOT NULL)) AND ((t_vertrag.f_vertrag_beginn <= '20141103' AND t_vertrag.f_vertrag_beginn IS NOT NULL) AND (t_vertrag.f_vertragsende >= '20141103' AND t_vertrag.f_vertragsende IS NOT NULL)))
Using SmartGWT 4.1p power v9.1p_2014-10-28/PowerEdition Deployment (built 2014-10-28) with MSSQL 2014.
Comment