Anyone have Hibernate collections working?

Discussion in 'Java' started by Timasmith, Nov 16, 2006.

  1. Timasmith

    Timasmith Guest

    It seems that if I have an object, say Person which a collection say
    Cars that I can define a relationship between them and save a new
    Person with Cars or extract a Person with Cars.

    But when I pull a Person with Cats and then add a Car to the collection
    I get an exception saving. Not in front of my workstation but it would
    along the lines of an Object State Excepion and indicated that it
    couldnt save due to the object being updated.

    I only have one working thread so it from the sql output seems that
    Hibernate executed two update statements and then failed on the second.
    I wouldnt have thought it would have done any, one insert only

    Maybe I am better pulling the sequence and saving the Car on its own
    without touching the Person. I suppose that will work but defeats the
    purpose of using Hibernate a bit. Not to mention if I have Car contain
    Wheels I have to deal with them as well.

    My cascade was save-update, might be related but setting it to All
    didnt help.
    Timasmith, Nov 16, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.