-->
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.  [ 3 posts ] 
Author Message
 Post subject: insert into ... select with Criteria API
PostPosted: Mon Apr 19, 2010 11:00 am 
Newbie

Joined: Mon Apr 19, 2010 10:52 am
Posts: 3
Hello,

I have used Criteria API for a fairly complex query that can return up to 1 million entries.
Unfortunately i have to store this data in a table so i would need something like insert into ... select
because iterating through such a large list and inserting one by one is a performance bottleneck.
Can i find something similar in criteria API?
Is there another efficient technique for such an operation?

Thanks,
Marius H.


Top
 Profile  
 
 Post subject: Re: insert into ... select with Criteria API
PostPosted: Tue Apr 20, 2010 6:17 am 
Regular
Regular

Joined: Wed Mar 10, 2010 4:48 am
Posts: 106
See this: http://docs.jboss.org/hibernate/core/3. ... ch-inserts


Top
 Profile  
 
 Post subject: Re: insert into ... select with Criteria API
PostPosted: Tue Apr 20, 2010 6:28 am 
Newbie

Joined: Mon Apr 19, 2010 10:52 am
Posts: 3
Thank you for your hint.
I was looking for something like:
String hqlInsert = "insert into DelinquentAccount (id, name) select c.id, c.name from Customer c where ...";
int createdEntities = s.createQuery( hqlInsert )
.executeUpdate();

It seems that HQL has some way of dealing with insert ..select and i was hoping for something similar in Criteria API for performance reasons.
Is there a match in Criteria for that kind of operation? A patch, a workaround, something?
Also i don't return from my select a mapped entity, but rather projections based items.
How can i deal with them?

Thanks again,


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.