Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

One-to-Many collection

 
Faraz Ali
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have implemented a ejb 3.0 one-to-many relationship. I want to remove one element from the collection, how i can do it.

For example,
City has one to many relationship with branches. And it maitains a branches collection. Now i want to remove one branch element from that collection. Whats the best way to do it?
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does city own branches? (i.e. is the branch being deleted by being removed from city?)

how do you have the attribute annotated? (show source, include all annotations)

you basically need to only remove the branch from the collection of branches and update the city,
 
Faraz Ali
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Yes, City owns Branches collection. And yes, i also think same, i only need to remove branch object from collection, and update the city, but sadly its not working.

For the code, you can refer to my previous post http://www.coderanch.com/t/321403/EJB-JEE/java/One-Many-bidirectional.

Also tell me the good way to do this.

Thanks,
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic