• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@OneToMany - Is thi bidirectional always?

 
Treimin Clark
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?
 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it can be also uni-directional as you specified.
 
Reza Rahman
author
Ranch Hand
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
Ranch Hand
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?
 
Raf Szczypiorski
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic