java - Can't seem to get rid of NonUniqueObjectException -


I am using the SINGLE_TABLE legacy strategy in Java Hibernate, this is setup:

  Class A @ cascade (cascade type DELETOORHHN, cascade type.AL) list & lt; B & gt; BS;   

A subdivision is spread in B. B There is an additional area in BA which is not in B. The reason for this is that I should just take care of this additional area of ​​the Bay objects (which is very low) and I want to avoid overhead of keeping it on every B object.

During the save, the way we have setup, we need to update the pre-B object field (rather than just changing the context). Therefore, we can not list BS = List B. We need to find each individual B through the primary key and update the field, such as B. Fields = Changed B. Field

At the time when this exception is left then, when a pre-B object should be saved as an additional field with the remaining fields. The reverse direction (save B to a pre-B object) is fine, I can set or drop down that extra field but I can not find a way to convert a B object to the left.

I have tried

  • By adding the b before the removal and saving of the B from the list, when I get this exception
  • I also Tried to swap areas from the B to the tiger, which needs to be changed in B and Vise, but it also did not work and I got an exception because I changed it to PK

    is during:

    • Inserts
    • Collections
    • Delete

      So, even if you remove the element If the new additions will be moved before the insert is removed, hence the obligation to throw the exception violation.

      To make it work, remove it from you and add the new collection back to your children's collection:

        a.removeChild (b); session.flush (); a.addChild (left);   

      Delete / adb utilities are establishing both sides of bi-directional collaboration, if there is a case in your domain model.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -