-->
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.  [ 2 posts ] 
Author Message
 Post subject: Weired hibernate behaviour when using getHibernateTemplate()
PostPosted: Thu Jul 24, 2008 4:50 pm 
Newbie

Joined: Fri Mar 07, 2008 2:31 pm
Posts: 3
Hi Friends,

I have class where I am trying to find the entity from list. I am calling following method

getHibernateTemplate().get(ABC.class,id) and the trying to access that class
as ABC.getName().

This code gives me ObjectNotFoundException. Actually I am also using spring framework for all this hibernate code. Now I my question is I have say one string with comma separated id for eg.(1,2,3,4,5...) Now suppose I have record in my table for id 1,2,3 and Not for id=4 and id=5. The strange thing is when I access id=4 , get() method returns null as expected. But in case of id=5 , it returns me proxy object. ANd when I try to access the getter method on that proxy object , it throws ONFExcetoion.(ObjectNotFoundException).

Where I am doing wrong?


Top
 Profile  
 
 Post subject: Re: Weired hibernate behaviour when using getHibernateTemplate()
PostPosted: Thu Jan 07, 2010 6:31 am 
Beginner
Beginner

Joined: Thu Jul 06, 2006 11:09 pm
Posts: 25
I am also encountering this kind of problem, which I thought so differently.

Here's my stack trace:

Code:
Caused by: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [entity.PkgGen#PkgGenId[trackNum=123,mpsNum=1]]
        at org.hibernate.impl.SessionFactoryImpl$2.handleEntityNotFound(SessionFactoryImpl.java:419)
        at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:171)
        at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:223)
        at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:126)
        at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:906)
        at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:874)
        at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:590)
        at org.hibernate.type.EntityType.resolve(EntityType.java:412)
        at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)
        at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877)
        at org.hibernate.loader.Loader.doQuery(Loader.java:752)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
        at org.hibernate.loader.Loader.loadEntity(Loader.java:1885)
        at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:71)
        at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:65)
        at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3062)
        at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:434)
        at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:415)
        at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:165)
        at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:223)
        at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:126)
        at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:906)
        at org.hibernate.impl.SessionImpl.get(SessionImpl.java:843)
        at org.hibernate.impl.SessionImpl.get(SessionImpl.java:836)
        at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:531)
        at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
        ... 52 more

_________________
Don't forget to rate.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.