-->
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.  [ 5 posts ] 
Author Message
 Post subject: net.sf.hibernate.ObjectNotFoundException: No row with the gh
PostPosted: Mon Jun 28, 2004 3:33 pm 
Newbie

Joined: Thu Sep 04, 2003 12:34 pm
Posts: 9
Hi,

I have a many-to-one relationship.

<many-to-one name="host" class="HostnameMap" column="filesystemID" outer-join="auto"/>

Sometimes the value in 'host' is bad, and has no correponding record in the HostnameMap table, hibernate throws an exception:

net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: 1560728141, of class: HostnameMap
at net.sf.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:24)
at net.sf.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:1925)
at net.sf.hibernate.proxy.LazyInitializer.initialize(LazyInitializer.java:53)
at net.sf.hibernate.proxy.LazyInitializer.initializeWrapExceptions(LazyInitializer.java:60)
at net.sf.hibernate.proxy.LazyInitializer.getImplementation(LazyInitializer.java:164)
at net.sf.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:108)
at HostnameMap$$EnhancerByCGLIB$$5d195980.toString(<generated>)


At that point I would like to log an error trace, but how can I get the string value of the invalid id of the hostnamemap???

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2004 5:27 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
your db is corrupted, is the foreign declared on db? if not just verify that there is a row in the table "HostnameMap" with the column id = 1560728141

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 29, 2004 4:14 am 
Newbie

Joined: Thu Sep 04, 2003 12:34 pm
Posts: 9
Anthony,

thanks for the reply.
yes, I see the data is wrong in my db (that is ok by itself), I just want to log some info about the issue. My mapping looks like this:

<class name="Parent" table="Parent">
...
<many-to-one name="host" class="HostnameMap" column="filesystemID" outer-join="auto"/>
</class>

I have an instance of Parent, and the exception was thrown when I called parent.getHost();
What I want at that point is to be able to:
System.err.println("Bad data in db: " + parent.getId() + " has host: " + <THE ID OF THE HOST>);

I cannot see how to get the id, without getting the HostnameMap instance, which is unexistant thus the exception...

many thanks,
a plus,


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 29, 2004 4:17 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
use JDBC and execute
select a.fk from a where a.fk not in (select b.pk from b)

you'll have all corrupted rows

and don't forget your dba is your friend to guarantee data integrity

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 29, 2004 6:18 am 
Newbie

Joined: Thu Sep 04, 2003 12:34 pm
Posts: 9
I new it was possilbe without jdbc...that code works for me

String res = "";
SessionImplementor sfi = (SessionImplementor) session;
Serializable sres = null;
try {
sres = HibernateProxyHelper.getIdentifier(o, sfi.getFactory().getPersister(classs));
}
catch (Exception e) {
...
}
return sres.toString();


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

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.