Joined: Wed Jun 09, 2004 11:43 pm Posts: 1 Location: Phnom Penh, Cambodia
|
Hello everybody!
Actually i m working with a projet called Inforum6 using HIbernate as persistance layer.
Right now i got stuck with LEFT JOIN who always throws new UnresolvableObjectException because the table which i have joined to does not contain an record wchich match the foreing key in the first table.
net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 13, of class: example.Team
at net.sf.hibernate.UnresolvableObjectException.throwIfNull(UnresolvableObjectException.java:38)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1950)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:69)
at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:204)
In fact i don want it to throw the exception eventhough no id match the record in the table joined cuz the information on the table joined is not nessary that y i use LEFT JOIN just wanna get more information.
Could anybody have any suggestion ?
Thanks in advance :)
Below is my query and file config xml:
query : SELECT player FROM Player player LEFT JOIN player.team
============== Player.hbm.xml==========
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="example.Player" table="players">
<id name="id" column="player_id" type="long" unsaved-value="null">
<generator class="hilo"/>
</id>
<property name="firstName" column="first_name" type="string" length="12" not-null="true"/>
<property name="lastName" column="last_name" type="string" length="15" not-null="true"/>
<property name="draftDate" column="draft_date" type="date"/>
<property name="annualSalary" column="salary" type="float"/>
<property name="jerseyNumber" column="jersey_number" type="integer" length="2" not-null="true"/>
<many-to-one
name="team"
class="example.Team"
column="team_id"
outer-join="true"
/>
</class>
</hibernate-mapping>
===================== team.hbm.xml==============
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="example.Team" table="teams">
<id name="id" column="team_id" type="long" unsaved-value="null">
<generator class="hilo"/>
</id>
<property name="name" column="team_name" type="string" length="15" not-null="true"/>
<property name="city" column="city" type="string" length="15" not-null="true"/>
<set name="players" cascade="all" inverse="true" lazy="true">
<key column="team_id"/>
<one-to-many class="example.Player"/>
</set>
</class>
</hibernate-mapping>
|
|