We have found a work around for this.
Problem further drilled down to following calls of ObjectNode domain object(void
addChild(String name, PortalObjectImpl childObject) of
org.jboss.portal.core.impl.model.portal.ObjectNode).
| children.containsKey(name)
|
Here children is a MAP(One-to-Many association) that is being loaded lazily. Because of
this lazy loading, initially it is loaded as a proxy and whenever any operation performed
on it, entire map gets loaded that in-turn fires those multiple select queries.
Proposed Solution
Solution lies in making this collection lazy="extra" instead of
lazy="true" in
core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
From:
<class
| name="org.jboss.portal.core.impl.model.portal.ObjectNode"
| table="JBP_OBJECT_NODE">
| .....
| <map
| name="children"
| inverse="true"
| cascade="none"
| fetch="select"
| lazy="true">
| <cache usage="@portal.hibernate.cache.usage(a)"/>
| <key column="PARENT_KEY"/>
| <map-key
| type="org.jboss.portal.jems.hibernate.MagicString"
| column="NAME"/>
| <one-to-many
class="org.jboss.portal.core.impl.model.portal.ObjectNode"/>
| </map>
To:
<map
| name="children"
| inverse="true"
| cascade="none"
| fetch="select"
| lazy="extra">
| <cache usage="@portal.hibernate.cache.usage(a)"/>
| <key column="PARENT_KEY"/>
| <map-key
| type="org.jboss.portal.jems.hibernate.MagicString"
| column="NAME"/>
| <one-to-many
class="org.jboss.portal.core.impl.model.portal.ObjectNode"/>
| </map>
The advantage gained by making lazy="extra" to lazy="true", according
to hibernate docs,HERE
https://hibernate.bluemars.net/315.html.
anonymous wrote : "...The collection wrapper is now smarter than before. The
collection is no longer initialized if you call size(), contains(), or
isEmpty()ÃÂâÃÂÃÂÃÂÃÂthe database is queried to retrieve the necessary
information. If itÃÂâÃÂÃÂÃÂÃÂs a Map or a List, the operations containsKey()
and get() also query the database directly..."
After doing this only one query in being fired instead of plethora of queries.
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4251697#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...