Re: [smartweb-user] [Smartweb-user] Entity -IntegrityReferenceException
Brought to you by:
rlogiacco
From: rlogiacco <rlo...@us...> - 2007-06-05 13:26:18
|
Pino Contartese wrote: >=20 > Need a control of IntegrityReference when we try to remove an Object from > data-base. > Maybe the Object is referenced from another table in the database and we > must implement a logical remove method. >=20 Well, we actually have such a method into the Hibernate API, the only sad thing is it's quite reverted. When you create the Hibernate Mapping (.hbm file) you can specify the cascading style (more on this on the official Hibernate documentation, specifically on=20 http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#example-pare= ntchild-cascades parent-child cascade and=20 http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#objectstate-= transitive transitive state ) which can allow you to manage consistency about your objects. Pino Contartese wrote: >=20 > A possible solution for this problem is: > 1) Insert IntegrityReferenceException in > net.smartlab.web.BusinessObjectFactory in the method remove > so the last user is forced to manage this Exception and to implement a > logic while removing an Object from DB. > 2) Create a method isRemovible(Object o) in the class referenced that ca= n > throws an IntegrityReferenceException > Es.: I have to remove a CommessaObject from my Db and it's just reference= d > from a ProgettoObject and AttivitaObject. >=20 What I figure out from your statement is that you wish to handle this cascading manually instead of automatically and beyond your back: am I right? Can I ask you why do you need to handle those things programmatically? For the sake of speeking: do you want to delete all your Progetto and Attivita when you delete Commessa or do you want to avoid deletion of Commessa if there is a Progetto or Attivit=C3=A0 linked to it? In the first case you just need to set the cascade style of your Commessa t= o all-delete-orphan, in the second to something more restictive like all or something lesser. Obviously I coul have not understood your point at all, in which case I jus= k ask you to explain it further... --=20 View this message in context: http://www.nabble.com/Entity--IntegrityRefere= nceException-tf3871534s17546.html#a10969404 Sent from the SmartWeb Users mailing list archive at Nabble.com. |