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?
|