public void CascadeCompositeElements()
		{
			Container c = new Container();
			IList list = new ArrayList();
			c.Cascades = list;
			Container.ContainerInnerClass cic = new Container.ContainerInnerClass();
			cic.Many = new Many();
			cic.One = new One();
			list.Add(cic);
			ISession s = OpenSession();
			s.Save(c);
			s.Flush();
			s.Close();

			s = OpenSession();
			foreach (Container obj in s.CreateQuery("from c in class ContainerX").Enumerable())
			{
				c = obj;
				break;
			}
			foreach (Container.ContainerInnerClass obj in c.Cascades)
			{
				cic = obj;
				break;
			}
			Assert.IsNotNull(cic.Many);
			Assert.IsNotNull(cic.One);
			Assert.AreEqual(1, c.Cascades.Count);
			s.Delete(c);
			s.Flush();
			s.Close();

			c = new Container();
			s = OpenSession();
			s.Save(c);
			list = new ArrayList();
			c.Cascades = list;
			cic = new Container.ContainerInnerClass();
			cic.Many = new Many();
			cic.One = new One();
			list.Add(cic);
			s.Flush();
			s.Close();

			s = OpenSession();
			foreach (Container obj in s.CreateQuery("from c in class ContainerX").Enumerable())
			{
				c = obj;
			}
			foreach (Container.ContainerInnerClass obj in c.Cascades)
			{
				cic = obj;
			}
			Assert.IsNotNull(cic.Many);
			Assert.IsNotNull(cic.One);
			Assert.AreEqual(1, c.Cascades.Count);
			s.Delete(c);
			s.Flush();
			s.Close();
		}
		public void Container()
		{
			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();
			Container c = new Container();
			Simple x = new Simple();
			x.Count = 123;
			Simple y = new Simple();
			y.Count = 456;
			s.Save(x, (long) 1);
			s.Save(y, (long) 0);
			IList o2m = new ArrayList();
			o2m.Add(x);
			o2m.Add(null);
			o2m.Add(y);
			IList m2m = new ArrayList();
			m2m.Add(x);
			m2m.Add(null);
			m2m.Add(y);
			c.OneToMany = o2m;
			c.ManyToMany = m2m;
			IList comps = new ArrayList();
			Container.ContainerInnerClass ccic = new Container.ContainerInnerClass();
			ccic.Name = "foo";
			ccic.Simple = x;
			comps.Add(ccic);
			comps.Add(null);
			ccic = new Container.ContainerInnerClass();
			ccic.Name = "bar";
			ccic.Simple = y;
			comps.Add(ccic);

			ISet compos = new HashedSet();
			compos.Add(ccic);
			c.Composites = compos;
			c.Components = comps;
			One one = new One();
			Many many = new Many();
			ISet manies = new HashedSet();
			manies.Add(many);
			one.Manies = manies;
			many.One = one;
			ccic.Many = many;
			ccic.One = one;
			s.Save(one);
			s.Save(many);
			s.Save(c);
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			c = (Container) s.Load(typeof(Container), c.Id);

			ccic = (Container.ContainerInnerClass) c.Components[2];
			Assert.AreEqual(ccic.One, ccic.Many.One);
			Assert.AreEqual(3, c.Components.Count);
			Assert.AreEqual(1, c.Composites.Count);
			Assert.AreEqual(3, c.OneToMany.Count);
			Assert.AreEqual(3, c.ManyToMany.Count);

			for (int i = 0; i < 3; i++)
			{
				Assert.AreEqual(c.ManyToMany[i], c.OneToMany[i]);
			}
			object o1 = c.OneToMany[0];
			object o2 = c.OneToMany[2];
			c.OneToMany.RemoveAt(2);
			c.OneToMany[0] = o2;
			c.OneToMany[1] = o1;
			o1 = c.Components[2];
			c.Components.RemoveAt(2);
			c.Components[0] = o1;
			c.ManyToMany[0] = c.ManyToMany[2];
			c.Composites.Add(o1);
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			c = (Container) s.Load(typeof(Container), c.Id);
			Assert.AreEqual(1, c.Components.Count); //WAS: 2 - h2.0.3 comment
			Assert.AreEqual(2, c.Composites.Count);
			Assert.AreEqual(2, c.OneToMany.Count);
			Assert.AreEqual(3, c.ManyToMany.Count);
			Assert.IsNotNull(c.OneToMany[0]);
			Assert.IsNotNull(c.OneToMany[1]);

			((Container.ContainerInnerClass) c.Components[0]).Name = "a different name";
			IEnumerator enumer = c.Composites.GetEnumerator();
			enumer.MoveNext();
			((Container.ContainerInnerClass) enumer.Current).Name = "once again";
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			c = (Container) s.Load(typeof(Container), c.Id);
			Assert.AreEqual(1, c.Components.Count); //WAS: 2 -> h2.0.3 comment
			Assert.AreEqual(2, c.Composites.Count);
			Assert.AreEqual("a different name", ((Container.ContainerInnerClass) c.Components[0]).Name);
			enumer = c.Composites.GetEnumerator();
			bool found = false;
			while (enumer.MoveNext())
			{
				if (((Container.ContainerInnerClass) enumer.Current).Name.Equals("once again"))
				{
					found = true;
				}
			}

			Assert.IsTrue(found);
			c.OneToMany.Clear();
			c.ManyToMany.Clear();
			c.Composites.Clear();
			c.Components.Clear();
			s.Delete("from s in class Simple");
			s.Delete("from m in class Many");
			s.Delete("from o in class One");
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			c = (Container) s.Load(typeof(Container), c.Id);
			Assert.AreEqual(0, c.Components.Count);
			Assert.AreEqual(0, c.Composites.Count);
			Assert.AreEqual(0, c.OneToMany.Count);
			Assert.AreEqual(0, c.ManyToMany.Count);
			s.Delete(c);
			t.Commit();
			s.Close();
		}