-->
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.  [ 1 post ] 
Author Message
 Post subject: Collection batch loading with custom sql-query loader
PostPosted: Wed Mar 16, 2011 10:44 am 
Newbie

Joined: Wed Mar 16, 2011 9:45 am
Posts: 1
Hi All,

I have an entity with a mapped collection like below:
<class name="Game">
...
...
<set name="codes" inverse="true" lazy="true" cascade="all" >
<cache usage="read-write"/>
<key>
<column name="GAME_ID" not-null="true" />
</key>
<one-to-many class="GameCode"/>
<loader query-ref="loaderQuery" />
</set>
</class>

<sql-query name="loaderQuery" cacheable="true">
<load-collection alias="cds" role="Game.codes" />
SELECT {cds.*}
FROM game_code cds
WHERE cds.game_id = ?
AND cds.code_revision = (SELECT MAX (revision)
FROM game_code a
WHERE a.game_id = cds.game_id AND a.code_id = cds.code_id)
ORDER BY cds.code_id ASC
</sql-query>

Everything is working fine, but on multiple Game loads the generated queries are quite inefficient. Adding batch-size attribute in the collection mapping would normally do the trick, but unfortunately when a custom loader is defined the batch-size seems to be ignored.

When I remove the <loader query-ref="loaderQuery"> and add the a batch-size everything works fine, but it doesn't cover my business needs.

Does anybody have an idea if there is a hook somewhere in Hibernate that I can add my custom batch loading code, or if I am doing something terribly wrong and there is a quick workaround/fix?

I'm using Hibernate 3.3.2.GA.

Thanks in advance,


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.