-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: About the count of SQL statement when cascade="all"
PostPosted: Tue Nov 18, 2003 5:54 am 
Beginner
Beginner

Joined: Fri Sep 26, 2003 2:50 am
Posts: 32
I have a parent table named A, this table has two one-to-one relation to table B and table C.

Firstly, I mapped this two one-to-one bidirectional relations with cascade="none", and when i insert 1000 columns into these three tables(call save() methods one bye one), the console displays three SQL statements.

Finally, I change these two relations to cascade="all", but when i do same thing(insert 1000 columns for every table), the console displays 3000 SQL statements.

I check the database, the result is OK. but why? is it OK?

thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2003 7:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Its fine. Hibernate caches a single SQL statement in BatcherImpl ;)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2003 9:24 am 
Beginner
Beginner

Joined: Fri Sep 26, 2003 2:50 am
Posts: 32
gavin, thank you for reply.

Am i right about following?
(1) if i do not use cascade, all object for a table are inserted into database with batch, so the console display a SQL statement.
(2) if i use cascade, when insert a record of the parent table, because of cascade, the hibernate will check all cascade records od the children tables, so the console will display every insert statement.

is it OK?

if so, is it that inserted data with cascade="all" is slower than with cascade="none"?

BTW, when i use cascade="all", when i delete the record of the parent table, there have many select statements before inserted data really.is it fine?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 9:11 pm 
Beginner
Beginner

Joined: Fri Sep 26, 2003 2:50 am
Posts: 32
sorry, but how about my question?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 9:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
ummm

its OK. And no, I don't expect theres any performance diff, as long as you are using a connection pool that implements statement caching.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.