Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: v3
Mapping documents:
<hibernate-mapping package="com.etil.sudetp.business.manager.gameaccount.impl" >
<class name="Account" table="account" >
<cache usage="nonstrict-read-write"/>
<id name="accountId" unsaved-value="null" column="ACCOUNTID" >
<generator class="assigned"/>
</id>
<property name="timestampDB" type="long" column="TIMESTAMP" />
<property name="date" type="java.util.Date" column="DATE" />
<property name="description" type="string" column="DESCRIPTION" />
<property name="gameId" type="int" column="GAMEID" />
<property name="serverId" type="int" column="SERVERID" />
<map name="accountFieldMap" table="ACCOUNTFIELDMAP" cascade="all">
<key column="ACCOUNTID" not-null="true"/>
<map-key column="FIELDID" type="string"/>
<one-to-many class="AccountField"/>
</map>
</class>
</hibernate-mapping>
<hibernate-mapping package="com.etil.sudetp.business.manager.gameaccount.impl" >
<class name="AccountField" table="accountfieldmap" >
<id name="id" type="int" column="ID" >
<generator class="native"/>
</id>
<property name="accountId" type="string" column="ACCOUNTID" />
<property name="fieldId" type="string" column="FIELDID" />
<property name="status" type="string" column="STATUS" />
<property name="value" type="string" column="VALUE" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Criteria query = s.session.createCriteria(AccountSale.class).add(
Expression.eq("userId", userId));
List sales = query.list();
for (Iterator it = sales.iterator(); it.hasNext(); ) {
AccountSale sale = (AccountSale) it.next();
Account account = (Account) s.session.get(Account.class, sale.getAccountId());
account.getAccountFieldMap();
sale.setAccount(account);
}
Why aren't my account fields loaded with the account? Worst than that, why is my account even not loaded if I am using the load method rather than the get.
Thanks.
DvJ