4

I built a OData Producer based on apache olingo, JPA and mySQL following this tutorial While many-to-many associations are displayed within the OData Feed, many-to-one associations are not displayed at all (neither are their JOIN-columns visible)

Does anyone have an idea, how to get olingo to display those Associations?

Daniel
  • 3,541
  • 3
  • 33
  • 46

2 Answers2

2

We had the same problem. Turns out olingo wasn't getting the default referencedColumnName correctly, so we had to set it manually on all our associations.

e.g.

@ManyToOne(fetch=FetchType.LAZY)    
@JoinColumn(name="AccountId")
public Account account;

Becomes

@ManyToOne(fetch=FetchType.LAZY)    
@JoinColumn(name="AccountId", referencedColumnName = "Id")
public Account account;
WearyMonkey
  • 2,519
  • 1
  • 24
  • 22
  • Thanks for your help, but unfortunately the associations still won't show up. They are not visible in the $metadata either... do you have any more ideas? ;) – Daniel May 09 '14 at 13:10
  • One other problem we had was olingo gave the relationships strange names, so we had to disable the olingo name generation with `ODataJPAContext.setDefaultNaming(false)` in `initializeODataJPAContext`. Other than that it worked well for us so I can't help more sorry :( – WearyMonkey May 13 '14 at 01:41
2

With 2.0.0 [http://olingo.apache.org/download.html] release of Olingo V2 lib, it is not mandatory to annotate the relationship property with both name and referencedColumnName.

Refer to the JIRA issue - https://issues.apache.org/jira/browse/OLINGO-127 for more details.

Regards Chandan

Chandan VA
  • 36
  • 2
  • Great! I haven't seen that new release yet. But now Olingo throws a `NullpointerException` upon an eclipse generated JPA. I need to investigate this in detail. When it works, I'll give you an accepted answer checkmark – Daniel Jul 17 '14 at 09:28