0
votes

I have two objects whose signature is as follows:

Employee{String name, int id, String address, Long salary}

Department{String name, List{Employee} employeesList}

Usign Spring Expression Language I have to find out the Department_name of a particular employee say 'A'.

My spel context has two lists #employees and #departments which are populated with required objects.

I couldn't find any way to need this. Any help would be much appreciated.

Thanks in advance, Raj.

1

1 Answers

1
votes

You can try something like this:

"#departments.?[!employeesList.?[name=='A'].isEmpty()]"

If you are sure that your employee exists and is in only one department, you can get the department name with this:

"#departments.?[!employeesList.?[name=='A'].isEmpty()][0].name"