Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

@OneToMany - Is thi bidirectional always?

 
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is @OneToMany always bidirectional?
What if the second entity doesn't have a @ManyToOne reference?
 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it can be also uni-directional as you specified.
 
author
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Treimin,

It has to be bi-directional from the OneToMany side. JPA 2 is fixing this.

Regards,
Reza
 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Reza Rahman wrote:Treimin,

It has to be bi-directional from the OneToMany side. JPA 2 is fixing this.

Regards,
Reza



Hi Reza,

Nice to see you here ,
The JPA doesn't say about uni-directional from OneToMany side, as you said. But what if the second entity doesn't have a @ManyToOne reference?, as Amandeep wrote, can it be uni-directional ?
 
Reza Rahman
author
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Treimin,

Not sure what you mean -- I think the answer is no. Can you give me a code example?

Regards,
Reza
 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Reza Rahman wrote:
Can you give me a code example?





In the above example, Bid entity doesn't have a reference to the Item entity. So, isn't it uni-directional?
 
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Treimin Clark wrote:
The JPA doesn't say about uni-directional from OneToMany side



Please see page 32, section 2.1.8.5.1 Unidirectional OneToMany Relationships.
Does this answer your question?
Cheers.
 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Raf Szczypiorski wrote:

Treimin Clark wrote:
The JPA doesn't say about uni-directional from OneToMany side



Please see page 32, section 2.1.8.5.1 Unidirectional OneToMany Relationships.
Does this answer your question?
Cheers.



Many thanks Raf, I got it cleared.
I didn't see that page before.
 
Alas, poor Yorick, he knew this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic