-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: re-loading all associations
PostPosted: Wed Aug 03, 2011 7:54 pm 
Newbie

Joined: Wed Aug 03, 2011 7:47 pm
Posts: 3
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):


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.