-->
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.  [ 4 posts ] 
Author Message
 Post subject: Loading Collection results in duplicate SQL selects
PostPosted: Fri May 28, 2004 8:23 am 
Beginner
Beginner

Joined: Wed Mar 17, 2004 7:59 am
Posts: 24
When loading a collection, hibernate issues two identical selects. My mappings are:

The many to one mapping:

<many-to-one name="salesBundleData" class="com.po.model.appobjects.SalesBundleDataImpl" cascade="none" outer-join="auto" >
<column name="SALESBUNDLE_ID" not-null="true" unique-key="TIA_DATAUNSVD_UK1" />
</many-to-one>


The one to many mapping:

<map name="modifiedDataMap" lazy="false" inverse="true" cascade="all-delete-orphan" outer-join="true" >
<cache usage="read-write"/>
<key>
<column name="SALESBUNDLE_ID" />
</key>
<index column="DATA_KEY" type="string"/>
<one-to-many class="com.po.model.appobjects.ModifiableDataItem" />
</map>

Any ideas why two selects identical would be generated? Plus is there any way to avoid the collection being re-created, I'm caching it and this work ok, but the first time after it has been created re-initializes the collection.

Thanks Pete.


Top
 Profile  
 
 Post subject: Bi-directional secondary cache
PostPosted: Sun May 30, 2004 6:21 pm 
Beginner
Beginner

Joined: Wed Mar 17, 2004 7:59 am
Posts: 24
My problem appear to be the way the caching works. When I store the parent object the map inserts are cached under "com.po.model.appobjects.ModifiableDataItem" and when I then load the object again it tries to load the data from the parent "modifiedDataMap" cache which is empty!

Am I doing something wrong? How do I get them to share the same cache?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 31, 2004 5:18 am 
Beginner
Beginner

Joined: Wed Mar 17, 2004 7:59 am
Posts: 24
After further investigation I think this may be down to the fact that when I create my persistent object the map is a normal java.util.Hashmap, whereas after loading the object it is the hibernate persistent map. Could this cause the map not be be cached on insert? Any way round this problem?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 31, 2004 5:52 am 
Beginner
Beginner

Joined: Wed Mar 17, 2004 7:59 am
Posts: 24
Ignore the last comment, looks like hibernate swaps in it's own map on doing the save. However the annoying thing is that the cache does not get updated on the inverse end... i.e. all the items in the map are cached and persisted, but the map itself is not cached, so when you load it has to re-select all the data - surely I'm missing something?


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