At 08:19 PM 8/29/2003 +0530, Prasad Iyer wrote:
What can I say?
Thanks Sir for your valuable time.
regards
prasad chandrasekaran


I sense great sarcasm there, but Christian's response is pretty good. If you start a transaction and create a parent, then create children, and one of the children fails, you rollback the transaction and the parent object won't be created either. And that's not a Hibernate thing. That's a RDBMS thing. Hibernate just provides a nice interface into it.

An example would be (Please excuse any syntax or API errors, doing this one from memory):
try
{
Session session = SessionFactory.getSession();
Transaction tx = session.startTransaction();


Parent parent = new Parent();

<set values of Parent>

Child child = new Child();

<set values of Child>

parent.getChildren().add(child);

tx.commit();
}
catch(Exception e)
{
        if( tx != null )
        {
                tx.rollback();
        }
}
finally
{
        session.close();
}


If you haven't already done so, I would look into a SQL book. I found the following one quite helpful:
http://www.amazon.com/exec/obidos/tg/detail/-/0201703092/qid=1062203306/sr=8-3/ref=sr_8_3/103-7047765-0401466?v=glance&s=books&n=507846


Did that help you answer your question?

Thanks,
Patrick





------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to