Joined: Fri Jan 07, 2005 11:56 am Posts: 6 Location: Manchester, England
|
I am using hibernate 2.1.4 and mysql 4.1.0
In Film.hbm.xml I have
<one-to-one name="prContract" class="film.hibernate.prcontract.PrContract" property-ref="film" />
In PrContract.hbm.xml I have
<many-to-one name="film" class="film.hibernate.film.Film" column="filmId" cascade="all" unique="true">
</many-to-one>
Then using the following SQL as queryString:
select distinct film from film.hibernate.film.Film film
left join fetch film.prContract
where
(film.prContract is null or film.prContract.id = 0) order by film.name
if I execute:
Session session = getSession();
Query query = session.createQuery(queryString);
return query.list();
I get the following error:
net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 4, of class: film.hibernate.prcontract.PrContract
The confusing thing is that there is definitely an entry in prContract table with id=4.
And if I run the above sql again but with film.prContract.id = 4 instead of 0
it will in fact return the prContract entry with id=4
Any ideas on what is going on here?
|
|