Skip to Content
0
Jul 27, 2022 at 09:01 AM

CAP Java - Getting entity from within Java code

538 Views Last edit Jul 27, 2022 at 09:01 AM 2 rev

Hello there!

This might be a stupid question but I really don't seem to get it to work.

I was following this SAP CAP Java tutorial and everything works perfectly fine:

https://developers.sap.com/mission.cap-java-app.html

Now, I want to have some custom stuff happening which needs to get data from the underlying entities after a POST request. So I added an @After Event Handler on the POST event and a call to a custom Java class with the ID of the posted entity. In this Java class I would like to get the entity that was just posted by ID and possibly some other entities from the underlying database as well for further processing.

How can I get an entity by ID from within the Java Code?

It seems to me that this is only possible via a REST call, but maybe I'm really missing something.

Maybe I'm also thinking of this wrong and there actually is a different best practice way of processing the data in Java.

Thanks and kind regards,

Tim