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.  [ 1 post ] 
Author Message
 Post subject: Problem with reflexive association and second-level cache
PostPosted: Wed Apr 21, 2004 12:29 pm 
Newbie

Joined: Tue Apr 20, 2004 5:19 am
Posts: 5
Hi,

The reflexive association:

/**
* Version represents any version of a project
* @hibernate.class table="versions" proxy="com.recercai.ricase.change.Version"
* @hibernate.cache usage="read-write"
*/
public class Version extends PersistentObject {

/**
* String that identifies this version
*/
private String versionNumber = null;

/**
* The parent Version
*/
private Version derivesFrom = null;

/**
* holds the list of subversions made from this
*/
private Map subVersions = null;

...

/**
* @return
* @hibernate.property column="version_number"
*/
public String getVersionNumber() {
return versionNumber;
}

public void setVersionNumber(String versionId) {
this.versionNumber = versionId;
}

/**
* @return
* @hibernate.many-to-one column="derives_from" class="com.recercai.ricase.change.Version" cascade="none"
*/
public Version getDerivesFrom() {
return derivesFrom;
}

/**
* @return
* @hibernate.map name="subVersions" cascade="none" inverse="true" lazy="true"
* @hibernate.collection-key column="derives_from"
* @hibernate.collection-index column="version_number" type="string"
* @hibernate.collection-one-to-many class="com.recercai.ricase.change.Version"
* @hibernate.collection-cache usage="read-write"
*/
public Map getSubVersions() {
return subVersions;
}
...
}

And I create a new version:
...
pSource.setVersionNumber(nextId);
pSource.setDerivesFrom(origVersion);
origVersion.addSubVersion(pSource);
...
//create the new version and update the source
session.saveOrUpdate(pSource);
...

When I try the create a new version with the same version source I see in the Hibernate logs:

...
DEBUG net.sf.cache.ReadWriteCache Cached item was locked: 98306
DEBUG net.sf.hibernate.impl.SessionImpl initializing collection [com.recercai.ricase.change.Version.subVersions#98306]
...
And Hibernate load the collection from the database instead from the cache. I think that the cache not release the lock of the collection after create the new version, and the next time I try to create a new version, the collection is still locked. Is something wrong in my code?


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

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.