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