• Post Reply Bookmark Topic Watch Topic
  • New Topic

Checking referencial constraint  RSS feed

 
jayanandan thiagarajan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai to everbody
Here i need some help in deleting record in the table.Actually i use session facade.Using entity manager in the session bean class i delete the entity bean i.e record.While i delete the record i just want to check it whether any child table refers that record or not.In DAO pattern i done it by checking errorCode that is thrown by SQLExcepion.One more thing i use EJB 3.0.
Please Help me.
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your mapping of the Parent to Child, you need to set the attribute that basically does a cascade delete when the parent is deleted. In Hibernate for example in the mapping you set the cascade level to "all-orphan-delete" or some other ordering of those strings. Of the top of my head I don't remember the exact string.

Mark
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes,
i agree with Mark Spritzler. try cascade-delete in your <ejb-relation >section in your ejb-jar.xml.
pras
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!