File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Oracle/OAS and the fly likes OneToMany <-> ManyToOne relationship Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "OneToMany <-> ManyToOne relationship" Watch "OneToMany <-> ManyToOne relationship" New topic

OneToMany <-> ManyToOne relationship

Jose Alvarez de Lara
Ranch Hand

Joined: May 10, 2008
Posts: 94

I am developing an EJB 3.0 web app on Oracle WebLogic Server 11gR1 PatchSet 1, and I am having problems
on update/delete with the relationship.

I have an entity Customer with two children DiscountCode an MicroMarket. The relation is many Customer has
one DiscountCode and many Customer has one MicroMarket. On the other direction it leaves as one DiscountCode
has many Customer and one MicroMarket has many Customer.

This is my code snippet,



The problem I am having is when I update the MicroMarket.zip_code in a Customer I get another record of
MicroMarket instead of an updated MicroMarket.

On delete a Customer it does not delete the MicroMarket.

And I have not any idea how is it done.


Best Regards,
Vinod Tiwari
Ranch Hand

Joined: Feb 06, 2008
Posts: 466

I think when parent is deleted all child would be automatically deleted (OneToMany). However in case of MnayToOne on deletion of child Parent deletion is not happening... it this the case here??

Vinod Tiwari | Twitter | Shikshanirman | Guftgu
Jose Alvarez de Lara
Ranch Hand

Joined: May 10, 2008
Posts: 94
Thanks for your quickly reply.

Well, I work only with Customer. So what I would like is when I delete a Customer
just only the MicroMarket child would be deleted.

The problem I have is that MicroMarket child is not deleted. That is wrong.

On the other hand the table corresponding to the DiscountCode entity must
leaves as it is without no update, no insert and no delete.

I agree. Here's the link:
subject: OneToMany <-> ManyToOne relationship
It's not a secret anymore!