-->
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.  [ 3 posts ] 
Author Message
 Post subject: Indexed collection + 'cannot access loading collection'
PostPosted: Mon Dec 13, 2004 1:21 pm 
Newbie

Joined: Mon Dec 13, 2004 12:52 pm
Posts: 2
Location: London
Hi,

I have a problem which causes a 'cannot access loading collection' error. I believe the problem is more to do with the approach I'm taking than a bug, coding or configuration error.

It is very similiar to the problem mentioned on the following page: http://www.hibernate.org/74.html#A28.

Yet is caused when I try to implement the technique described in this article:
http://www.hibernate.org/193.html.

I have code in one of my 'child' objects which access a collection maintained by the parent object. The code looks a like this:

Code:
public int getIndex() {
    return this.getParent().getChildren().indexOf(this);
}


This method is being called when my collection is being lazily initialised and causes Hibernate to complain that I'm trying to access the loading collection, which is fair enough.

My question is: How else can I maintain the index value in a similar fashion?

Thanks in advance.

(i have excluded information about my environment as I believe this is a technique rather than a technical problem)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 13, 2004 1:40 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you can map the index column as a read only property

this is to used only with persistent element of the collection (not unsaved)

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 13, 2004 2:06 pm 
Newbie

Joined: Mon Dec 13, 2004 12:52 pm
Posts: 2
Location: London
Anthony,

I believe that is what I've done already. See code below:

Quote:
public int getSeq() {
return getParent().getChildren().indexOf(this);
}

private void setSeq(int seq) {
// do nothing
}


However, I don't think this is what's causing the problem.

I encountered the problem when I added <cache usage="read-write"/> into my mapping file. I'm trying to improve overall performance by enabling caching as much as possible.

When I run a debugger against my application I can see that Hibernate reads all the properties for an object in net.sf.hibernate.impl.CacheEntry.disassemble() whilst caching the object. One of my properties calls it's parent and this is where I get the 'cannot access loading collection' message.

I want to cache this object whilst still following the same technique (described in http://www.hibernate.org/193.html).

Do you have any further ideas? Thanks.


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