Hello,
My program loads all the DB objects on startup. The "root" object is UserInfo (see below mapping document). As you can see, it has four collections (and we are adding more). Currently, for each user, the DB needs to make at least one call per collection (4), and it is quite slow. As we are loading the entire DB anyway, it would make sense to load the tables in 'one shot' instead of loading each entity one at a time. How can we do this?
Hibernate version:
1.2.0.4000
Mapping documents:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
<class name="UserInfo.UserInfo,UserInfo" table="TUSER" lazy="false" mutable="true" batch-size="10">
<id name="Id" column="USER_ID" type="int">
<generator class="assigned"/>
</id>
<property name="Login" column="USER_CODE" type="System.String" unique="true">
</property>
<property name="UserType" column="USER_TYPE" not-null="true" type="UserInfo.UserProfileTypeType, UserInfo" />
<map name="InstrumentGroupRoles" table="TINSTGROUPUSR" sort="unsorted">
<key column="INSTGRPUSR_USER_ID"/>
<index-many-to-many column="INSTGRPUSR_INSTGRP_ID" class="UserInfo.InstrumentGroup,UserInfo"/>
<many-to-many column="INSTGRPUSR_ROLE_CODE" class="UserInfo.InstrumentGroupRole,UserInfo"/>
</map>
<!-- table="TMKTLOGIN"-->
<set name="MarketLogins">
<key column="MKTLOG_USER_ID"/>
<one-to-many class="UserInfo.MarketLogin,UserInfo" />
</set>
<set name="MarketRights">
<key column="UMKTRIGHT_USER_ID"/>
<one-to-many class="UserInfo.MarketRight,UserInfo" />
</set>
<set name="SystemRights">
<key column="USYSRIGHT_USER_ID"/>
<one-to-many class="UserInfo.SystemRight,UserInfo" />
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
ICriteria criteria = session.CreateCriteria(typeof(UserInfo));
IList<UserInfo> results = criteria.List<UserInfo>();
log.Info("Count: " + results.Count);
foreach (T result in results)
{
log.Info(result.ToString());
log.Info(Configuration.Parser.Serialize(result));
}
Name and version of the database you are using:
Oracle9i Enterprise Edition Release 9.2.0.5.0
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html