Hibernate version: 1.2RC1
Name and version of the database you are using:SQL 2005
Hi All,
I'm getting very strange behaviours with sets. This will be much easier to explain with a 'Unit Test' style code...
Entity e = ....; // Entity in the session
ChildEntity ce = new ChildEntity(e, "_Prob").Save();
// ChildEntity adds itself to Entitie's ChieldEntities ISet.
// Lets verify this is the case.
IEnumerator enu = c.ChildEntities.GetEnumerator();
enu.MoveNext();
ChildEntity verifyInParent = enu.Current; // This just verifies that ChildEntity added itself appropriatelly to Entity's ChildEntities Set
Assert.AreEqual(verifyInParent , ce); // .Equals working file
Assert.IsTrue(verifyInParent == ce); // Even same reference
Assert.AreEqual(verifyInParent .GetHashCode(), ce.GetHashCode());
// Hashcodes seem ok
Assert.IsTrue(c.ProbabilityEntities.Contains(pInList)); // Fail Test
Is there something I'm missing here? The code to add the ChildEntity to the Parents ChildEntities Set is not complex, In fact its a direct call to ChildEntities.Add(ce).
Any help would be greatly appreciated.
Cheers,
Guido Tapia
|