Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
rajnish_tiwari2
Advisor
Advisor
0 Kudos


This is the continuation of previous blog (blog series), In this blog series will be explaining about adding custom annotation and labels into ODATA metadata, but in Olingo 2.0 anytype of Aggregation is not possible.

 

Introduction   

In order to add new annotation into the metadata to any of the Entity class or calculation view then, we have to extend the JPAEdmExtension class and create a Java class by implementing the interface org.apache.olingo.odata2.jpa.processor.api.model to register the annotated Java methods. Below metadata of Employee and Orders Entity class info, before the annotation addition you need to include below set of code in SampleCustomOdataJpaServiceFactory class,

  • oDataJPAContext.setJPAEdmExtension((JPAEdmExtension) new CustomAnnotationProcessor());


 



And in CustomAnnotationProcessor class override the extendJPAEdmSchema method as shown below, In below sample code I have just added the generic annotation on all the columns, if required you  can added different annotation for different columns as well as for class level also.

 



 

 

Now when you check the metadata before annotation addition,

 



 

 

Now below metadata shows after adding annotation at entity level by implementing the JPAEdmExtension class



 

In this blog it has been explained that how custom annotation can be added in columns metadata of ODATA.

In next blog .i.e. Part4, how JPA mapping can be redefined.

 

 

 

 

2 Comments