Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OneToMany <-> ManyToOne relationship

 
Jose Alvarez de Lara
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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,

Customer.-


MicroMarket.-


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.

Help!!!


Best Regards,
Jose
 
Vinod Tiwari
Ranch Hand
Posts: 466
1
IntelliJ IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??
 
Jose Alvarez de Lara
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Regards,
Jose
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic