-->
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: Batch Insert
PostPosted: Mon Mar 20, 2006 3:13 pm 
Newbie

Joined: Mon Mar 20, 2006 2:54 pm
Posts: 3
In reference to post
http://forums.hibernate.org/viewtopic.p ... 8c47510f94

Could any one please point me exactly to the documentation section
where it says
"
....except for inserts with an identity column. In which case batching is dsiabled.
"

I need to show it to my boss.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 2:55 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
don't know the exact location in the docs, but this makes sense..right? since identity (and as such the key) is only gained by actually inserting a record, thus it needs to "flush" at the time it does the saveOrUpdate(). Other id generators don't have this issue, since the keys can be fetched independently of the actual record being inserted.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 22, 2006 9:41 am 
Newbie

Joined: Mon Mar 20, 2006 2:54 pm
Posts: 3
I'm new to hibernate and I wanted to get more background
(read the docs) before I start to implement things.

Now I think it's recommeded design that every class should have and
identity column .

The question is what id generator do you use.
With oracle for example if you use native generator hibernate
first selects sequence.next_value from dual then assigns it to the
to the object and then saves it.

So I don't think it need to flush at the saveOrUpdate time .

For example in this post
http://forums.hibernate.org/viewtopic.p ... 8c47510f94

Somebody recomends :
"3) generate ID yourself (under Oracle Hibernate do it very very poor)"

Does it mean to use assigned generator ? i.e assign id by myself.

My manager is against that 'cause we need several threads to inserts object simultaneously.

Maybe I don't understand something .
Could you please comment ?
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 1:09 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
identity means that once the record is inserted into the table, the database takes care of assigning the PK automatically.

Thus with generator="identity" you are telling hibernate that the DATABASE will assign the id, when the record is inserted - thus hibernate can't batch the insert.

Also, don't listen to the other recommendation about hibernate doing a poor job on generating IDs... For the most part, the are doing a great job of managing this - the only way I might improve it (and perhaps someone can chime in on this, if they know it already exists), is by POOLING ID's so that it doesn't have to fetch one all the time prior to insert.
For instance (with Oracle sequences) It would be great, if hibernate could pull out X# of sequence from the oracle sequence, and then dole them out as needed on inserts...then grab another X# as it is finished with the pool.

Also don't forget to rate with a "Y" all my posts, if you find them helpful.
I appreciate it.

Thanks,
JT


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 7:29 pm 
Newbie

Joined: Mon Mar 20, 2006 2:54 pm
Posts: 3
Thanks

I now understand things better .

I'm thinking about creating my own generator using the
techique you've suggested as a feature for hibernate.

I want to use alter sequence increment to get a bulk of ids
and then assign them to my objects .

I think if I create a singleton with synchronized method which will provide a range of ids for each thread it should be more efficient .
then doing select sequence.next_val from dual for each insert.

I created a simple test to simulate my use case and using sequence
generator I can achieve a rate of 100 rec per second.
(actually I have one logical record which is inserted into 2 physical tables
so I guess its 200 inserts per second ).

This is far behind the rate one person in this thread
http://forums.hibernate.org/viewtopic.p ... 8c47510f94

claimed to achieve - (2000 rec per sec.)


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.