-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: confusing net.sf.hibernate.UnresolvableObjectException
PostPosted: Thu Mar 10, 2005 12:32 pm 
Newbie

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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.