[ 
https://issues.apache.org/jira/browse/OLINGO-433?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14141889#comment-14141889
 ] 

Chandan V.A commented on OLINGO-433:
------------------------------------

Hi Kiran,
Now you can override the foreign key column name in the JPAEdmMappingModel 
configuration. The changes are part of commit = 
http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/fc8c4ff9 

To override the foreign key column name following would be the steps.
Steps
1) In the mapping model under JPAEntityType --> JPAAttributes Element add a 
JPAAttribute Element. 
2) The JPA Attribute Element name takes the Join Column Name

Example

                        <JPAEntityType name="SalesOrderItem">
                                
<EDMEntityType>SalesOrderLineItem</EDMEntityType>
                                <EDMEntitySet>SalesOrderLineItems</EDMEntitySet>
                                <JPAAttributes>
                                        <JPAAttribute 
name="liId">ID</JPAAttribute>
                                        <JPAAttribute 
name="soId">SalesOrderID</JPAAttribute>
                                        <JPAAttribute 
name="Material_Id">mID</JPAAttribute>
                                </JPAAttributes>
                                <JPARelationships>
                                        <JPARelationship 
name="salesOrderHeader">SalesOrderHeaderDetails</JPARelationship>
                                        <JPARelationship 
name="materials">MaterialDetails</JPARelationship>
                                </JPARelationships>
                        </JPAEntityType>

In the above example the Join Column name Material_Id is mapped to mID.

I hope this solves the problem

Thanks
Kind Regards
Chandan

> Join Column name is used for EDM attribute and exposed as is in $metadata
> -------------------------------------------------------------------------
>
>                 Key: OLINGO-433
>                 URL: https://issues.apache.org/jira/browse/OLINGO-433
>             Project: Olingo
>          Issue Type: New Feature
>          Components: odata2-jpa
>    Affects Versions: V2 2.0.0
>            Reporter: Kiran G
>            Priority: Minor
>
> If I set ODataJPAContext.setDefaultNaming(false) then the attributes for join 
> column is of form FK_<JoinColumn Name>, there by exposing the foreign column 
> name in $metadata url. It would be be nice just to have the JPA attribute 
> name itself with a suffix 'fk' instead and not expose the Database column 
> name. 
> If this is not possible atleast provide support to override this name in 
> JPAEdmMappingModel configuration XML.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to