I have a very large query that returns 1000 objects (called Fielding) .Each Fielding object has a single Master object.
My domain Fielding object has the Master object set as null an I do not reference it ,yet no matter how I configure my Fielding.hbm.xml file ,it runs a separate select query for the Master object . I only need to access a Master object on a case by case basis . I do not need all of them loaded at once and it is causing a performance nightmare.
Can anyone tell me what is wrong with my configuration files ?
Nothing I do is working as the Hibernate documentation says it will. I have also tried to add lazy="no-proxy" because apparently (from other posts) lazy="true" does not work for anybody.
Thanks for taking a look.
Fielding.hbm.xml
Code:
<hibernate-mapping>
<class name="baseball.hibernate.Fielding" table="fielding">
<cache usage="read-write" />
<composite-id name="id" class="baseball.hibernate.FieldingId">
<key-property name="playerId" type="string">
<column name="playerID" length="9" />
</key-property>
<key-property name="yearId" type="short">
<column name="yearID" />
</key-property>
<key-property name="stint" type="short">
<column name="stint" />
</key-property>
<key-property name="pos" type="string">
<column name="POS" length="2" />
</key-property>
</composite-id>
<property name="playerId" type="string" insert="false" update="false" >
<column name="playerID" length="9" />
</property>
<property name="yearId" type="short" insert="false" update="false">
<column name="yearID" />
</property>
<property name="stint" type="short" insert="false" update="false">
<column name="stint" />
</property>
<property name="pos" type="string" insert="false" update="false">
<column name="POS" length="2" />
</property>
<property name="teamId" type="string">
<column name="teamID" length="3" not-null="true" />
</property>
<property name="lgId" type="string">
<column name="lgID" length="2" not-null="true" />
</property>
<property name="g" type="java.lang.Short">
<column name="G" />
</property>
<property name="gs" type="java.lang.Short">
<column name="GS" />
</property>
<property name="innOuts" type="java.lang.Short">
<column name="InnOuts" />
</property>
<property name="po" type="java.lang.Short">
<column name="PO" />
</property>
<property name="a" type="java.lang.Short">
<column name="A" />
</property>
<property name="e" type="java.lang.Short">
<column name="E" />
</property>
<property name="dp" type="java.lang.Short">
<column name="DP" />
</property>
<property name="pb" type="java.lang.Short">
<column name="PB" />
</property>
<property name="lahmanId" type="java.lang.Short">
<column name="lahmanID" />
</property>
<property name="wp" type="java.lang.Short">
<column name="WP" />
</property>
<property name="sb" type="java.lang.Short">
<column name="SB" />
</property>
<property name="cs" type="java.lang.Short">
<column name="CS" />
</property>
<property name="nameFirst" type="string" insert="false" update="false" >
<column name="nameFirst" length="50" />
</property>
<property name="nameLast" type="string" insert="false" update="false" >
<column name="namelast" length="80" /></property>
<property name="zr" type="java.lang.Double">
<column name="ZR" precision="5" scale="3" />
</property>
<many-to-one name="master" class="baseball.hibernate.Master" column="playerId" property-ref="playerId" />
Master.hbm.XML
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jul 18, 2009 3:03:12 PM by Hibernate Tools 3.2.2.GA -->
<hibernate-mapping>
<class name="baseball.hibernate.Master" table="master">
<cache usage="read-write" />
<id name="lahmanId" type="java.lang.Short">
<column name="lahmanID" />
<generator class="identity" />
</id>
<property name="playerId" type="string">
<column name="playerID" length="10" unique="true" not-null="true" />
</property>
<property name="managerId" type="string">
<column name="managerID" length="10" not-null="true" />
</property>
<property name="hofId" type="string">
<column name="hofID" length="10" not-null="true" />
</property>
<property name="birthYear" type="java.lang.Short">
<column name="birthYear" />
</property>
<property name="birthMonth" type="java.lang.Short">
<column name="birthMonth" />
</property>
<property name="birthDay" type="java.lang.Short">
<column name="birthDay" />
</property>
<property name="birthCountry" type="string">
<column name="birthCountry" length="50" />
</property>
<property name="birthState" type="string">
<column name="birthState" length="2" />
</property>
<property name="birthCity" type="string">
<column name="birthCity" length="50" />
</property>
<property name="deathYear" type="java.lang.Short">
<column name="deathYear" />
</property>
<property name="deathMonth" type="java.lang.Short">
<column name="deathMonth" />
</property>
<property name="deathDay" type="java.lang.Short">
<column name="deathDay" />
</property>
<property name="deathCountry" type="string">
<column name="deathCountry" length="50" />
</property>
<property name="deathState" type="string">
<column name="deathState" length="2" />
</property>
<property name="deathCity" type="string">
<column name="deathCity" length="50" />
</property>
<property name="nameFirst" type="string">
<column name="nameFirst" length="50" />
</property>
<property name="nameLast" type="string">
<column name="nameLast" length="50" not-null="true" />
</property>
<property name="nameNote" type="string">
<column name="nameNote" />
</property>
<property name="nameGiven" type="string">
<column name="nameGiven" />
</property>
<property name="nameNick" type="string">
<column name="nameNick" />
</property>
<property name="weight" type="java.lang.Short">
<column name="weight" />
</property>
<property name="height" type="java.lang.Double">
<column name="height" precision="4" scale="1" />
</property>
<property name="bats" type="string">
<column name="bats" length="2" />
</property>
<property name="throws_" type="string">
<column name="throws" length="2" />
</property>
<!--
-->
<property name="debut" type="java.sql.Date">
<column name="debut" />
</property>
<property name="finale" type="java.sql.Date">
<column name="finalGame" />
</property>
<property name="college" type="string">
<column name="college" length="50" />
</property>
<property name="lahman40id" type="string">
<column name="lahman40ID" length="9" />
</property>
<property name="lahman45id" type="string">
<column name="lahman45ID" length="9" />
</property>
<property name="retroId" type="string">
<column name="retroID" length="9" />
</property>
<property name="holtzId" type="string">
<column name="holtzID" length="9" />
</property>
<property name="bbrefId" type="string">
<column name="bbrefID" length="9" />
</property>
</class>
</hibernate-mapping>