Hi,
I have a bug with the under the following circumstances.
I have a class named a CallTreeContact. The mapping file is displayed below:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="ncontinuity2.core.domain.CallTreeContact,ncontinuity2.core" table="CallTreeContacts" lazy="true">
<cache usage="read-write"/>
<id name="Uid" column="uid" type="System.Guid" unsaved-value="00000000-0000-0000-0000-000000000000">
<generator class="guid"/>
</id>
<many-to-one name="CallTree" column="calltreeuid" class="ncontinuity2.core.domain.CallTree,ncontinuity2.core" not-null="true" cascade="none" lazy="proxy"/>
<many-to-one name="Contact" column="contactuid" class="ncontinuity2.core.domain.Contact,ncontinuity2.core" not-null="true" cascade="none" lazy="false"/>
<many-to-one name="Parent" column="parentuid" class="ncontinuity2.core.domain.CallTreeContact,ncontinuity2.core" not-null="false" cascade="none" lazy="false"/>
<many-to-one name="CallTreeContactRole" column="contactcalltreeid" class="ncontinuity2.core.domain.CallTreeContactRole,ncontinuity2.core" lazy="false" cascade="none" not-null="true"/>
<bag name="Children" table="CallTreeContacts" inverse="true" cascade="all-delete-orphan" lazy="true">
<cache usage="read-write"/>
<key column="parentuid"/>
<one-to-many class="ncontinuity2.core.domain.CallTreeContact,ncontinuity2.core"/>
</bag>
</class>
</hibernate-mapping>
This class contains a bag of objects of the same type (Children). The problem I am having is when I want to delete one of these objects from the bag. I have the following code:
Code:
[Transaction(TransactionMode.RequiresNew)]
public virtual CallTreeContact RemoveResponderFromPrincipal(Guid callTreeUid, Guid responderUid)
{
ISession session = _sessionManager.OpenSession();
CallTree callTree = _commonDao.GetObjectById<CallTree, Guid>(callTreeUid);
CallTreeContact responder = (from ct in callTree.Contacts
where ct.Uid == responderUid
select ct).First();
CallTreeContact principal = responder.Parent;
responder.Parent.Remove(responder);
responder.Parent = null;
return principal;
}
I am using Memcached as my caching provider. The problem I have is after this code runs the child object is deleted but it is not removed from the cache. If I stop the memcached service then everything works fine.
I get an unresolvableobjectexception or the familiar error message:
No row with the given identifier exists[ncontinuity2.core.domain.CallTreeContact#---]
Can anyone tell me why this object is not being removed from the cache?
Can I programmatically remove it from the cache?
Can anyone spot what I am doing wrong?
Cheers
Paul