I am trying to delete a row from the database, along with all it's associations (one-to-many and one-to-one Hibernate associations)
The code for the row render is:
Code:
public void render(final Row row, final java.lang.Object data)
throws Exception {
final MeetingTask meetingTask = (MeetingTask) data;
The code for the remove row button in the render function is
Code:
removeMeetingTaskButton.addEventListener(Events.ON_CLICK,
new EventListener() {
public void onEvent(Event event) throws Exception {
meetingService.deleteMeetingTask(meetingTask);
However when I try to remove this meetingTask from the database using Hibernate I get the error:
Code:
ERROR [org.hibernate.util.JDBCExceptionReporter] - The DELETE statement conflicted with the REFERENCE constraint "FKBFEFDF0A96FF8568". The conflict occurred in database "db", table "ag", column 'T_ID'.
This is because only the meetingTask object is being sent and not all its Hibernate one-to-many and one-to-one associations.
Is there a simple way to get all the Hibernate one-to-one and one-to-many associations for the meetingTask object?
I tried to reload the meetingTask object before deleting it using:
Code:
MeetingTask meetingTaskAndAssociations = meetingService.getMeetingTaskById(meetingTask.getId());
meetingService.deleteMeetingTask(meetingTaskAndAssociations);
and got the following error:
Code:
deleted object would be re-saved by cascade (remove deleted object from associations):nested exception is org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations):