aspose file tools
The moose likes Object Relational Mapping and the fly likes Bidirectional relationships on Objects in Jpa Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Bidirectional relationships on Objects in Jpa" Watch "Bidirectional relationships on Objects in Jpa" New topic
Author

Bidirectional relationships on Objects in Jpa

sridhanya ganapathy
Greenhorn

Joined: Jun 03, 2006
Posts: 14
Hi All,
In my application for a scenario inheritance is much suited design.
ie N child Objects tied to a parent object{Grouping common attributes}
As JPA doesn't support such inheritance my application expected, we where forced to use "One to Many" Bidirectional Mapping.In the same i have few questions.

eg
class Parent{
attributes
@OneToMany
list <Child> childObjects
}
class Child {
attributes
@ManyToOne
Parent parentObj;
}

1)Is that a bad object design ie having bidirectional relationship?

2)JPA forces the developer to take care of bidirectional relationship in the objects ..To be more clear when child is added to the persistence store forces the developer to update the parentlist also.
Is this behaviour forced by jpa?

3)Is there any other workaround for the same.
 
IntelliJ Java IDE
 
subject: Bidirectional relationships on Objects in Jpa
 
Threads others viewed
ORM as compared to JDBC
Very simple
Interfaces Implementation.
multiple classification
What makes Java difficult
IntelliJ Java IDE