In Odata2 there is a possibility to redefine the metamodel. The following page describes the process: https://olingo.apache.org/doc/odata2/tutorials/jparedefinemetadata.html
I haven't found a way to do such conversion with OData v4/Olingo/JPA. I am using the SAP implementation olingo-jpa-processor-v4 which exists at https://github.com/SAP/olingo-jpa-processor-v4
What I am looking for is to change the external name of some classes or attributes.
I have tried to use the JPAEdmNameBuilder class but the methods of that class do not have enough information to make the changes of the attributes according to the entity from which they come. These methods only receive the name of the attribute (and not the name of the entity) so it would not be possible to selectively rename an attribute that appears in two entities.
Any suggestions on how to do that conversion?
Thank you very much
Note: there is a related question at: Olingo (OData 4): how set translation of EntitySet (Entity) names? but it is quite old and very specific. My hope is that a functionality similar to what exists in Odata2 would have been implemented during this time.
This is quite a old thread, but I ran into the same issue, and came across a solution hence posting it here.
So while creating
JPAODataSessionContextAccess
you can callsetEdmNameBuilder
function to set the EdmBuilder.If nothing is passed in line 165 of
JPAODataServiceContext
a new instance ofJPADefaultEdmNameBuilder
is created and set.JPADefaultEdmNameBuilder
in the current code is marked as final, so you can't subclass it, but you can build define a class that implementsJPAEdmNameBuilder
, that has your custom logic and pass set it inJPAODataSessionContextAccess
For reference the code for setting your custom class will be something like
and the implementation of
CustomJPADefaultEdmNameBuilder
can be like the following