Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 

This is the continuation of previous blog (blog series), In this blog will be explaining about JPA mapping and how columns name which can be renamed and column's join can be renamed as well as how class name can be manipulated in xml.




OData services created from JPA models using OData JPA processor Library derives the names for its elements from Java Persistence Entity elements. These derived (default) names can be redefined using JPA EDM mapping models. JPA EDM Mapping model can be used to redefine: Schema Namespace Name Entity Type Names Entity Set Names Property Names Navigation Property Names Complex Type Names

The OData JPA Processor Library applies certain naming rules to derive the names for the above OData elements by default. Here are the rules:

  1. Schema Namespace Name is derived from Java Persistence Unit Name.

  2. Entity Type Names are derived from Java Persistence Entity Type Names.

  3. Entity Set Names are derived from EDM Entity Type Names suffixed with character "s".

  4. Property Names are derived from Java Persistence Entity Attribute Names. The initial character in the property name is converted to an upper-case character.

Steps to modify the Metadata

  1. Create a JPA EDM Mapping model XML according to the schema given below. In the XML, maintain the mapping only for those elements that needs to be redefined. For example, if JPA Entity Type A's name has to be redefined, then maintain an EDM name for the same.

  2. Deploy the JPA EDM Mapping model XML file in the root directory of your web application archive (store it in the same directory as 'WEB-INF').

  3. 3. Pass the XML name into ODataJPAContext. In the method initializeODataJPAContext, pass the name of the XML document as shown below:



As you can observe below that persistence unit name definition is must and it should be maintained across the application,

Compile, deploy and run the web application in a web server. A sample JPA EDM Mapping Model is provided as an example below:



So in the above blog, it has been explained that how JPA mapping can be creates as well as attributes name can be manipulated based on the requirement, In the next blog i.e. Part 5 I will be explaining about the Debugging implementation in olingo 2.0 OData services.