Select query with where clause that reads from an arraylist

Good day,

I am trying to search through a table within a screen using wagonManagementsDs.setQuery("select e from transportationms$WagonManagement e "); but the where clause should read from a list of value.

Not sure if this is possible because it does not executed when i do.

Code:

for(int i = 0; i < listOfStations.size(); i++) {
			
			wagonManagementsDs.setQuery("select e from transportationms$WagonManagement e "
					+ "where e.yard IN :custom$stationList AND "
					+ "e.movementStatus <> :custom$wagonMovement");
			params.put("stationList", listOfStations.get(i));
			params.put("wagonMovement", WagonMovementEnum.En_Route);
			wagonManagementsDs.refresh(params);
		}

If there is a solution to this, pleae share.
Thanks.

Hi,

Looking at your code, I don’t fully understand your intention.
But the following should work:

wagonManagementsDs.setQuery("select e from transportationms$WagonManagement e "
        + "where e.yard IN :custom$stationList AND "
        + "e.movementStatus <> :custom$wagonMovement");
params.put("stationList", listOfStations);
params.put("wagonMovement", WagonMovementEnum.En_Route);
wagonManagementsDs.refresh(params);

I.e. you should be able to use java.util.List as a value of a parameter of the ‘IN’ clause.