• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate: How to delete mapping table

 
Ronwaldo Cruz
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If I have an element (Class A) in my class which has a one-to-one relationship with another element (Class B) and is joined by a mapping table (Mapping table for A & B), is there a way that if object A is deleted, hibernate will delete the mapping entry but not object B?
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens by default?
 
Ronwaldo Cruz
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A constraint violation exception is thrown. Since the entry from the mapping table is not deleted
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic