<commit_before>using System;
using System.Collections;

using NHibernate.DomainModel;

using NUnit.Framework;

namespace NHibernate.Test 
{

	/// <summary>
	/// FumTest handles testing Composite Ids.
	/// </summary>
	[TestFixture]
	public class FumTest : TestCase
	{
		protected static short fumKeyShort = 1;
	
		[SetUp]
		public void SetUp()
		{

			ExportSchema(new string[] {  
					"FooBar.hbm.xml",
					"Baz.hbm.xml",
					"Qux.hbm.xml",
					"Glarch.hbm.xml",
					"Fum.hbm.xml",
					"Fumm.hbm.xml",
					"Fo.hbm.xml",
					"One.hbm.xml",
					"Many.hbm.xml",
					"Immutable.hbm.xml",
					"Fee.hbm.xml",
					"Vetoer.hbm.xml",
					"Holder.hbm.xml",
					"Location.hbm.xml",
					"Stuff.hbm.xml",
					"Container.hbm.xml",
					"Simple.hbm.xml",
					"Middle.hbm.xml"
				}, true);
		}

		static FumCompositeID FumKey(String str) 
		{
		
			return FumKey(str,false);
		}
	
		static FumCompositeID FumKey(String str, bool aCompositeQueryTest) 
		{
			FumCompositeID id = new FumCompositeID();
//			if( dialect is Dialect.MckoiDialect ) 
//												{
//													  GregorianCalendar now = new GregorianCalendar();
//													  GregorianCalendar cal = new GregorianCalendar( 
//														  now.get(java.util.Calendar.YEAR),
//														  now.get(java.util.Calendar.MONTH),
//														  now.get(java.util.Calendar.DATE) 
//														  );
//													  id.setDate( cal.getTime() );
//												  }
//			else 
//			{
			id.Date = new DateTime(2004, 4, 29, 9, 0, 0, 0);
//				 }
			id.String = str;
		
			if (aCompositeQueryTest) 
			{
				id.Short = fumKeyShort++ ;
			}
			else 
			{
				id.Short = (short)12 ;
			}
		
			return id;
		}

		[Test]
		public void ListIdentifiers() 
		{
			ISession s = sessions.OpenSession();
			Fum fum = new Fum( FumTest.FumKey("fum") );
			fum.FumString = "fo fee fi";
			s.Save(fum);

			fum = new Fum( FumTest.FumKey("fi") );
			fum.FumString = "fee fi fo";
			s.Save(fum);

			// not doing a flush because the Find will do an auto flush unless we tell the session a 
			// different FlushMode
			IList list = s.Find("select fum.Id from fum in class NHibernate.DomainModel.Fum where not fum.FumString = 'FRIEND'");
			
			Assert.AreEqual(2, list.Count, "List Identifiers");

			IEnumerator enumerator = s.Enumerable("select fum.Id from fum in class NHibernate.DomainModel.Fum where not fum.FumString='FRIEND'").GetEnumerator();
			int i = 0;
			while(enumerator.MoveNext()) 
			{
				Assert.IsTrue(enumerator.Current is FumCompositeID, "Iterating Identifiers");
				i++;
			}

			Assert.AreEqual(2, i, "Number of Ids found.");

			// clean up by deleting the 2 Fum objects that were added.
			s.Delete( s.Load( typeof(Fum), list[0] ) );
			s.Delete( s.Load( typeof(Fum), list[1] ) );
			s.Flush();
			s.Close();


		}
		
		[Test]
		public void CompositeID() 
		{
			ISession s = sessions.OpenSession();
			Fum fum = new Fum( FumTest.FumKey("fum") );
			fum.FumString = "fee fi fo";
			s.Save(fum);

			Assert.AreSame( fum, s.Load( typeof(Fum), FumTest.FumKey("fum"), LockMode.Upgrade ) );
			s.Flush();
			s.Close();

			s = sessions.OpenSession();
			fum = (Fum) s.Load( typeof(Fum), FumTest.FumKey("fum"), LockMode.Upgrade );
			Assert.IsNotNull(fum, "Load by composite key");

			Fum fum2 = new Fum( FumTest.FumKey("fi") );
			fum2.FumString = "fee fo fi";
			fum.Fo = fum2;
			s.Save(fum2);

			IList list = s.Find("from fum in class NHibernate.DomainModel.Fum where not fum.FumString='FRIEND'");
			Assert.AreEqual(2, list.Count, "Find a List of Composite Keyed objects");

			IList list2 = s.Find("select fum from fum in class NHibernate.DomainModel.Fum where fum.FumString='fee fi fo'");
			Assert.AreEqual(fum, (Fum)list2[0], "Find one Composite Keyed object");

			fum.Fo = null;
			s.Flush();
			s.Close();

			s = sessions.OpenSession();
			IEnumerator enumerator = s.Enumerable("from fum in class NHibernate.DomainModel.Fum where not fum.FumString='FRIEND'").GetEnumerator();
			int i = 0;
			while(enumerator.MoveNext()) 
			{
				fum = (Fum) enumerator.Current;
				s.Delete(fum);
				i++;
			}

			Assert.AreEqual(2, i, "Iterate on Composite Key");
			s.Flush();
			s.Close();

		}

		[Test]
		public void CompositeIDOneToOne()
		{
			ISession s = sessions.OpenSession();
			Fum fum = new Fum( FumKey("fum") );
			fum.FumString = "fee fi fo";
			//s.Save(fum); commented out in h2.0.3
			Fumm fumm = new Fumm();
			fumm.Fum = fum;
			s.Save(fumm);
			s.Flush();
			s.Close();

			s = sessions.OpenSession();
			fumm = (Fumm) s.Load( typeof(Fumm), FumKey("fum") );
			//s.delete(fumm.Fum); commented out in h2.0.3
			s.Delete(fumm);
			s.Flush();
			s.Close();
					   
		}
<commit_msg>Wrapped a For Update in a Transaction - oracle requirement.<commit_after>using System;
using System.Collections;

using NHibernate.DomainModel;

using NUnit.Framework;

namespace NHibernate.Test 
{

	/// <summary>
	/// FumTest handles testing Composite Ids.
	/// </summary>
	[TestFixture]
	public class FumTest : TestCase
	{
		protected static short fumKeyShort = 1;
	
		[SetUp]
		public void SetUp()
		{

			ExportSchema(new string[] {  
					"FooBar.hbm.xml",
					"Baz.hbm.xml",
					"Qux.hbm.xml",
					"Glarch.hbm.xml",
					"Fum.hbm.xml",
					"Fumm.hbm.xml",
					"Fo.hbm.xml",
					"One.hbm.xml",
					"Many.hbm.xml",
					"Immutable.hbm.xml",
					"Fee.hbm.xml",
					"Vetoer.hbm.xml",
					"Holder.hbm.xml",
					"Location.hbm.xml",
					"Stuff.hbm.xml",
					"Container.hbm.xml",
					"Simple.hbm.xml",
					"Middle.hbm.xml"
				}, true);
		}

		static FumCompositeID FumKey(String str) 
		{
		
			return FumKey(str,false);
		}
	
		static FumCompositeID FumKey(String str, bool aCompositeQueryTest) 
		{
			FumCompositeID id = new FumCompositeID();
//			if( dialect is Dialect.MckoiDialect ) 
//												{
//													  GregorianCalendar now = new GregorianCalendar();
//													  GregorianCalendar cal = new GregorianCalendar( 
//														  now.get(java.util.Calendar.YEAR),
//														  now.get(java.util.Calendar.MONTH),
//														  now.get(java.util.Calendar.DATE) 
//														  );
//													  id.setDate( cal.getTime() );
//												  }
//			else 
//			{
			id.Date = new DateTime(2004, 4, 29, 9, 0, 0, 0);
//				 }
			id.String = str;
		
			if (aCompositeQueryTest) 
			{
				id.Short = fumKeyShort++ ;
			}
			else 
			{
				id.Short = (short)12 ;
			}
		
			return id;
		}

		[Test]
		public void ListIdentifiers() 
		{
			ISession s = sessions.OpenSession();
			Fum fum = new Fum( FumTest.FumKey("fum") );
			fum.FumString = "fo fee fi";
			s.Save(fum);

			fum = new Fum( FumTest.FumKey("fi") );
			fum.FumString = "fee fi fo";
			s.Save(fum);

			// not doing a flush because the Find will do an auto flush unless we tell the session a 
			// different FlushMode
			IList list = s.Find("select fum.Id from fum in class NHibernate.DomainModel.Fum where not fum.FumString = 'FRIEND'");
			
			Assert.AreEqual(2, list.Count, "List Identifiers");

			IEnumerator enumerator = s.Enumerable("select fum.Id from fum in class NHibernate.DomainModel.Fum where not fum.FumString='FRIEND'").GetEnumerator();
			int i = 0;
			while(enumerator.MoveNext()) 
			{
				Assert.IsTrue(enumerator.Current is FumCompositeID, "Iterating Identifiers");
				i++;
			}

			Assert.AreEqual(2, i, "Number of Ids found.");

			// clean up by deleting the 2 Fum objects that were added.
			s.Delete( s.Load( typeof(Fum), list[0] ) );
			s.Delete( s.Load( typeof(Fum), list[1] ) );
			s.Flush();
			s.Close();


		}
		
		[Test]
		public void CompositeID() 
		{
			ISession s = sessions.OpenSession();
			ITransaction t = s.BeginTransaction();
			Fum fum = new Fum( FumTest.FumKey("fum") );
			fum.FumString = "fee fi fo";
			s.Save(fum);

			Assert.AreSame( fum, s.Load( typeof(Fum), FumTest.FumKey("fum"), LockMode.Upgrade ) );
			//s.Flush();
			t.Commit();
			s.Close();

			s = sessions.OpenSession();
			t = s.BeginTransaction();
			fum = (Fum) s.Load( typeof(Fum), FumTest.FumKey("fum"), LockMode.Upgrade );
			Assert.IsNotNull(fum, "Load by composite key");

			Fum fum2 = new Fum( FumTest.FumKey("fi") );
			fum2.FumString = "fee fo fi";
			fum.Fo = fum2;
			s.Save(fum2);

			IList list = s.Find("from fum in class NHibernate.DomainModel.Fum where not fum.FumString='FRIEND'");
			Assert.AreEqual(2, list.Count, "Find a List of Composite Keyed objects");

			IList list2 = s.Find("select fum from fum in class NHibernate.DomainModel.Fum where fum.FumString='fee fi fo'");
			Assert.AreEqual(fum, (Fum)list2[0], "Find one Composite Keyed object");

			fum.Fo = null;
			//s.Flush();
			t.Commit();
			s.Close();

			s = sessions.OpenSession();
			t = s.BeginTransaction();
			IEnumerator enumerator = s.Enumerable("from fum in class NHibernate.DomainModel.Fum where not fum.FumString='FRIEND'").GetEnumerator();
			int i = 0;
			while(enumerator.MoveNext()) 
			{
				fum = (Fum) enumerator.Current;
				s.Delete(fum);
				i++;
			}

			Assert.AreEqual(2, i, "Iterate on Composite Key");
			//s.Flush();
			t.Commit();
			s.Close();

		}

		[Test]
		public void CompositeIDOneToOne()
		{
			ISession s = sessions.OpenSession();
			Fum fum = new Fum( FumKey("fum") );
			fum.FumString = "fee fi fo";
			//s.Save(fum); commented out in h2.0.3
			Fumm fumm = new Fumm();
			fumm.Fum = fum;
			s.Save(fumm);
			s.Flush();
			s.Close();

			s = sessions.OpenSession();
			fumm = (Fumm) s.Load( typeof(Fumm), FumKey("fum") );
			//s.delete(fumm.Fum); commented out in h2.0.3
			s.Delete(fumm);
			s.Flush();
			s.Close();
					   
		}

{'fraction_non_alphanumeric': 0.1543539767368752, 'fraction_numerical': 0.007544797233574348, 'mean_word_length': 2.5731935604642455, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 36}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7366835', 'n_tokens_mistral': 4592, 'n_tokens_neox': 3656, 'n_words': 788}