Re: [Hibernate] Nested Transaction

2003-08-30 Thread Patrick Burleson
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();



Child child = new 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


Re: [Hibernate] Nested Transaction

2003-08-29 Thread Prasad Iyer
What can I say?
Thanks Sir for your valuable time.
regards
prasad chandrasekaran

- Original Message -
From: "Christian Bauer" <[EMAIL PROTECTED]>
To: "Prasad Iyer" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, August 29, 2003 7:44 PM
Subject: Re: [Hibernate] Nested Transaction


> On 29 Aug (19:42), Prasad Iyer wrote:
>
> > First of all I really sorry to ask this question on developer list, but
can't help it.
>
> Why? You don't have a web browser?
>
> > I got this parent child relationship between two tables.
> > And I want to perform a insert on both the tables in a transaction.
> > So if the child transaction fails the parent Transaction should
rollback.
> >
> > Even if somebody points me out in a right direction, it would help me a
lot.
>
> There is a thing we call "Transactions" for exactly this purpose. Please
> read the documentation.
>
> --
> Christian Bauer
> [EMAIL PROTECTED]



---
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


Re: [Hibernate] Nested Transaction

2003-08-29 Thread Christian Bauer
On 29 Aug (19:42), Prasad Iyer wrote:

> First of all I really sorry to ask this question on developer list, but can't help 
> it.

Why? You don't have a web browser?

> I got this parent child relationship between two tables.
> And I want to perform a insert on both the tables in a transaction.
> So if the child transaction fails the parent Transaction should rollback.
> 
> Even if somebody points me out in a right direction, it would help me a lot.

There is a thing we call "Transactions" for exactly this purpose. Please
read the documentation. 

-- 
Christian Bauer
[EMAIL PROTECTED]


---
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


[Hibernate] Nested Transaction

2003-08-29 Thread Prasad Iyer



Hi,
Can anyone help me out with nested 
transaction.
First of all I really sorry to ask this 
question on developer list, but can't help it.
I got this parent child relationship 
between two tables.
And I want to perform a insert on both 
the tables in a transaction.
So if the child transaction fails the 
parent Transaction should rollback.
 
Even if somebody points me out in a right 
direction, it would help me a lot.
Thanks for going through the mail. really 
appreciate
regards
prasad 
chandrasekaran