Results 1 to 3 of 3

Thread: Circular object graphs in Hibernate

  1. #1

    Default Circular object graphs in Hibernate

    Hello all. I'm having a little trouble, and I can't seem to find any info on what I need. Hopefully someone here can set me straight.

    I have three classes:

    ClassA
    Set classB;

    ClassB
    ClassA classA
    ClassC classC

    ClassC
    Set classB

    If I am using a basic DAO as shown in the documentation, can I not simply pass an instance of ClassA to the save method to save the entire object graph? I have no problems saving any one of the individual instances. But when I try to save the graph, I get an exception about a non-persistent instance of classB.

    I'd appreciate any help.

    Thanks!

  2. #2
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    You need to save individual instances, or else turn on cascading save (and deletes, etc.) as appropriate.

    This is actually very much a Hibernate question and not really Spring releated. You can get a lot more Hibernate documentation and help by visiting the Hibernate site...
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

  3. #3

    Default

    I appreciate your response.

    I've been over both sites fairly thoroughly, to no avail. I had come to the conclusion that cascading saves was what I needed, and had even found the configuration snippit on Hibernates site to turn this on. Unfortunately this is not directly transferable to my configuration, as a Spring file is responsible for holding the configuration for Hibernate, and it does not use the exact same manor for doing this. I have attempted a couple of different things trying to get cascades to work. All have failed.

    So I am left wondering if Hibernate is the issue, or the integration of Hibernate into Spring. As I believe that Hibernate does not have a bug in its code preventing cascades from working, I'm left with the option of it being the integration of the two products, or more correctly, my misunderstanding of the inadequately documented integration of the two products.

    That being the case, I felt that this forum was a logical starting place - as it was described as being a forum for data access integration and what-not - to try to correct my understanding of the integration. As I've not received any help here yet, I'll now try the Hibernate forums.

    Again, thanks for your response.

Similar Threads

  1. Replies: 2
    Last Post: Oct 10th, 2005, 05:12 PM
  2. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  3. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  4. Replies: 1
    Last Post: Mar 2nd, 2005, 02:12 AM
  5. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •