You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "Chandan V.A (JIRA)" <ji...@apache.org> on 2013/11/01 18:37:17 UTC

[jira] [Commented] (OLINGO-42) jpa processor requires a redundant field for many-to-one relationships

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

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

Hi Georgi,
This is a know constraint. The JPA EDM provider while constructing a relationship between two JPA entities needs to know the fields on which the two entities are related. The reason for

1) Optional annotation attribute - referencedColumnName is --> 
  As per JPA specification if the referenced column name is not specified then it is assumed that the foreign key refers to the primary key of the referenced table. But for the JPA EDM provider confusion arises when there is a compound key defined for the JPA Entity.

2) a redundant field for Foreign key is needed --> 
  As per JPA specification the foreign key columns if not explicitly specified in the JPA Entity can be generated by the underlying implementations based on certain naming rules. This means the JPA EDM provider that builds properties for an Entity needs to make an assumption on the existence of such JPA attributes that are not explicitly part of JPA Entity definition. Secondly this attribute also needs to be added as Edm property in the EDM entity type for consistent EDM.

Hence to keep things simple, optimal for transformation between JPA and EDM and to build consistent references JPA EDM Provider mandates that 
1) A redundant field be added explicitly to the JPA entity as foreign key
2) the attribute "referencedColumnName" be added to the JPA annotation @JoinColumn to avoid confusion in case of compounded keys

Regards
Chandan

> jpa processor requires a redundant field for many-to-one relationships
> ----------------------------------------------------------------------
>
>                 Key: OLINGO-42
>                 URL: https://issues.apache.org/jira/browse/OLINGO-42
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-jpa
>    Affects Versions: 1.0.0
>         Environment: windows7, tomcat 7.0.42, hsql, eclipse link 2.5.0
>            Reporter: Georgi
>            Assignee: Chandan V.A
>
> It looks like that the only way to get a consistent EDM associations model and the corresponding navigation properties, when there are many-to-one (bi-directional) managed relationships, is to add an additional and redundant property, annotated with @Column to the owning class. Same as in your reference jpa model.
> However, it's highly unlikely that one models a JPA model like this in reality and quite an impairment particularly for existing models.
> I'm not sure why is that needed, because the information encoded in the required field @Column annotation is redundant with the one @JoinColumn annotation and you already parse the JoinColumn anyways.
> So probably that's a low hanging fruit?
> I also realized that specifying the optional in the JPA @JoinColumn annotaiton property referencedColumnName is yet another mandatory requirement for the JPA edm producer to create a valid navigation properties set.



--
This message was sent by Atlassian JIRA
(v6.1#6144)