-->
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: ObjectNotFoundException with a valid row number
PostPosted: Tue May 19, 2009 11:35 am 
Newbie

Joined: Tue May 19, 2009 11:06 am
Posts: 1
Greetings,

I am seeing the following error occasionally when trying reference a stats object associated with a content item object:

Code:
Caused by: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.xxx.model.ContentStatistics#15]
        at org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:377)
        at org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:79)
        at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:68)
        at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
        at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)


I understand the what the exception is trying to tell me but its just plain wrong. ContentStatistics is referenced from a ContentItem using a 1-1 mapping. The row does exist in the database. And I have in fact verified that every content item row has a corresponding content statistics row. Any idea where I should start looking for this problem?

Appreciate any help at this point.

Here are the relevant model snippings:

ContentItem.java
Code:
@Entity
@Table(name="content_item")
public class ContentItem
    extends OidBaseObject<Long>
    implements PKeyObject<Long>
{
    ...

    private ContentStatistics    stats = new ContentStatistics(this);

    ...

    @AccessType("field")   
    @OneToOne(optional=false, cascade=CascadeType.ALL, fetch=FetchType.LAZY)
    @JoinColumn(unique=true, nullable=false, updatable=false)
    public ContentStatistics getStats() {
        return stats;
    }
   
    public void setStats(ContentStatistics stats) {
      this.stats = stats;
    }

    ...
}


ContentStatistics.java:
Code:
@Entity
@Table(name="content_statistics")
public class ContentStatistics
   extends JOBaseObject
{
        ...
        private ContentItem contentItem;
        ...
        @OneToOne(optional=false,mappedBy="contentItemInfo")   
        public ContentItem getContentItem() {
            return contentItem;
        }
   
        public void setContentItem( ContentItem item ){
            contentItem = item;     
        }
        ...
}


Code:
select ci.id, cs.*  from content_item ci, content_statistics cs
where ci.owner_id = 70 and ci.stats_id = cs.id

returns:
Code:
id, id, downloadCt
9, 9, 0
10, 10, 0
11, 11, 0
13, 13, 0
14, 14, 0
15, 15, 0    <---------------------------------
37, 37, 0
38, 38, 0
186, 186, 0
201, 201, 0
204, 204, 0


PS: hibernate-annotations-3.4.0.GA and friends.


Top
 Profile  
 
 Post subject: Re: ObjectNotFoundException with a valid row number
PostPosted: Tue Jun 16, 2009 8:22 am 
Newbie

Joined: Tue Jun 16, 2009 8:18 am
Posts: 1
I am experiencing the same problem. In my case, I have two threads accessing different entities. One thread is in a transaction commit. The other thread is throwing an EntityNotFoundException (I am using JPA). Also, I have verified that the object and all of its associations exist in the database. There appears to be no reason why the object access method should throw an EntityNotFoundException. Have you found a solution to this problem?


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.