Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
6 replies
Subscribers
7 subscribers
Views
5124 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Integrations
Delete Operation is not cascading When using Secondary Table
Rama Thummala
Certified Lead Developer
over 8 years ago
I am using single CDT mapping to two tables by using @Table and @Secondary Table.Insertion is working fine.
While Deleting the entity by passing primary key,the data is not getting deleted from DB.(org.hibernate.exception.ConstraintViolationException)
<xsd:appinfo source="appian.jpa">
@Table(name="emp")
@SecondaryTable(name="MoreInfo", pkJoinColumns=@PrimaryKeyJoinColumn(name="Id",referencedColumnName="empId"))
</xsd:appinfo>
.....
....
<xsd:element name="empId" nillable="true" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="appian.jpa">@Id</xsd:appinfo>
</xsd:annotation>
</xsd:element>
....
OriginalPostID-237339
Discussion posts and replies are publicly visible
0
Arun Theja Muthyalu
Certified Lead Developer
over 8 years ago
@Ramanjaneyulu Thummala
Documentation says, "Any CDT created through the Data Type Designer or uploaded via an XSD file automatically has the cascade attribute to ALL by default, so unless you have manually changed this setting, deleting a parent record of a CDT with this setting results in the deletion of the parent's child records."
Please share what you are setting for "Data to Delete". Will try to help you based on that.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Arun Theja Muthyalu
Certified Lead Developer
over 8 years ago
@Ramanjaneyulu Thummala
I can tell you a work around.
Try changing the Foreign Key Options. Set "On Delete" to "CASCADE" from MySQL Workbench.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Rama Thummala
Certified Lead Developer
over 8 years ago
@Arun , Thanks for the response.
I could see,For nested CDTs by default cascade attribute value is ALL.But my case is with @SecondaryTable delete is not cascading.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Arun Theja Muthyalu
Certified Lead Developer
over 8 years ago
@Ramanjaneyulu Thummala
Okay. Any luck with the work around I have given?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
phanibabuk
over 8 years ago
I suggest trying the option suggested by arunthejam to set the cascade option.
If we set "On Cascade" to Delete in the child foreign key constraint, then when a parent record is deleted, all the corresponding child records will automatically delete.
Also, tell me if you are trying to delete rows from one reference table or more than one?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Rama Thummala
Certified Lead Developer
over 8 years ago
Thanks @Phani.
As a work around doing the soft delete,instead of actually deleting the record.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel