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.