Skip to Content
May 06, 2020 at 03:42 PM

CDS OData Java service

333 Views Last edit May 07, 2020 at 09:00 AM 3 rev


I am new in this forum, and new to SAP Cloud Foundry/CAP. I can not find a solution to the below problem anywhere.

I have created a Odata Java service using the CAP Java Maven Archetype as mentioned here:

Other than splitting entities and services in two files, eventually I have combined them into one cds file:

service service {
	entity Case {
		key ID : Integer;
		caseNumber : Integer;
		description : String;
		phase  : String;

Next, I have created a CaseImpl, which extends HashMap<String, Object> and it implements the generated 'Case' interface. All four properties are provided in the CaseImpl, like this:

	public Integer getId() {
		return (Integer) get(ID);

	public void setId(final Integer id) {
		put(ID, id);

So, basically, CaseImpl is a HashMap containing all necessary String key / Object value combinations.

Then I have added a custom event handler, as mentioned here:

It contains this method:

	@On(event = CdsService.EVENT_READ, entity = "service.Case")
	public void onReadCases(final CdsReadEventContext context) {


... the getCases() method returns a collection of four CaseImpl instances that are identified by ID= 1, 2, 3 and 4.

And the entire collection is shown perfectly when calling /odata/v4/service/Case

However, when calling /odata/v4/service/Case(1) I expect to see only Case with ID=1, but I get: Result contains more than one row
	at ~[cds4j-core-1.8.0.jar:na]
	at ~[cds-adapter-odata-v4-1.4.0.jar:na]
	at$processReadRequest$6( ~[cds-adapter-odata-v4-1.4.0.jar:na]
	at ~[cds-services-impl-1.4.0.jar:na]
	at ~[cds-adapter-odata-v4-1.4.0.jar:na]
	at ~[cds-adapter-odata-v4-1.4.0.jar:na]
	at$processChangesetRequest$0( ~[cds-adapter-odata-v4-1.4.0.jar:na]
	at$runInReqContextIfNecessary$2( ~[cds-adapter-odata-v4-1.4.0.jar:na]
	at ~[cds-services-impl-1.4.0.jar:na]
	at ~[cds-adapter-odata-v4-1.4.0.jar:na]
	at ~[cds-adapter-odata-v4-1.4.0.jar:na]
	at ~[cds-adapter-odata-v4-1.4.0.jar:na]
	at ~[cds-adapter-odata-v4-1.4.0.jar:na]
	at ~[cds-adapter-odata-v4-1.4.0.jar:na]

(etc., no cause)

Also, when calling /odata/v4/service/Case?$top=2, all four cases are shown. As if the filter is ignored.

What am I doing wrong? The CDS version is 1.4.0.

Thanks in advance,

Kind regards,