You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Michael D. <mik...@us...> - 2004-12-11 20:08:29
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13895/NHibernate.Test/TypesTest Added Files: SByteTypeFixture.cs Log Message: NH-151: added SByteType and Fixture for it Moved nh specific CompositeId tests to their own namespace. --- NEW FILE: SByteTypeFixture.cs --- using System; using NHibernate.Type; using NUnit.Framework; namespace NHibernate.Test.TypesTest { /// <summary> /// Summary description for SByteTypeFixture. /// </summary> [TestFixture] public class SByteTypeFixture { [Test] public void Equals() { SByteType type = (SByteType)NHibernate.SByte; Assert.IsTrue( type.Equals( (sbyte)-1, (sbyte)-1 ) ); Assert.IsFalse( type.Equals( (sbyte)-2, (sbyte)-1 ) ); } [Test] public void ObjectToSQLString() { SByteType type = (SByteType)NHibernate.SByte; Assert.AreEqual( "-1", type.ObjectToSQLString( (sbyte)-1 ) ); } [Test] public void StringToObject() { SByteType type = (SByteType)NHibernate.SByte; Assert.AreEqual( (sbyte)-1, type.StringToObject( "-1" ) ); } } } |
From: Michael D. <mik...@us...> - 2004-12-11 20:08:28
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/CompositeId In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13895/NHibernate.Test/CompositeId Added Files: ClassWithCompositeId.cs ClassWithCompositeId.hbm.xml ClassWithCompositeIdFixture.cs Id.cs Log Message: NH-151: added SByteType and Fixture for it Moved nh specific CompositeId tests to their own namespace. --- NEW FILE: Id.cs --- using System; namespace NHibernate.Test.CompositeId { /// <summary> /// Summary description for Id. /// </summary> public class Id { private string _keyString; private short _keyShort; private System.DateTime _keyDateTime; public Id() { } public Id(string keyString, short keyShort, System.DateTime keyDateTime) { _keyString = keyString; _keyShort = keyShort; _keyDateTime = keyDateTime; } public string KeyString { get { return _keyString;} set { _keyString = value;} } // public short KeyShort { // get { return _keyShort;} // set {_keyShort = value;} // } public System.DateTime KeyDateTime { get { return _keyDateTime;} // set {_keyDateTime = value;} } public override int GetHashCode() { return _keyString.GetHashCode(); } public override bool Equals(object obj) { Id otherObj = obj as Id; if(otherObj==null) return false; if(otherObj.KeyString.Equals(this.KeyString)) return true; return false; } } } --- NEW FILE: ClassWithCompositeIdFixture.cs --- using System; using System.Collections; using System.Data; using NHibernate.DomainModel.NHSpecific; using NUnit.Framework; namespace NHibernate.Test.CompositeId { /// <summary> /// Summary description for ClassWithCompositeIdFixture. /// </summary> [TestFixture] public class ClassWithCompositeIdFixture : TestCase { private DateTime firstDateTime = new DateTime(2003, 8, 16); private DateTime secondDateTime = new DateTime(2003, 8, 17); private Id id; private Id secondId; [SetUp] public void SetUp() { ExportSchema( new string[] { "CompositeId.ClassWithCompositeId.hbm.xml" }, true, "NHibernate.Test" ); id = new Id("stringKey", 3, firstDateTime); secondId = new Id("stringKey2", 5, secondDateTime); } /// <summary> /// Test the basic CRUD operations for a class with a Composite Identifier /// </summary> /// <remarks> /// The following items are tested in this Test Script /// <list type=""> /// <item> /// <term>Save</term> /// </item> /// <item> /// <term>Load</term> /// </item> /// <item> /// <term>Criteria</term> /// </item> /// <item> /// <term>Update</term> /// </item> /// <item> /// <term>Delete</term> /// </item> /// <item> /// <term>Criteria - No Results</term> /// </item> /// </list> /// </remarks> [Test] public void TestSimpleCRUD() { // insert the new objects ISession s = sessions.OpenSession(); ITransaction t = s.BeginTransaction(); ClassWithCompositeId theClass = new ClassWithCompositeId(id); theClass.OneProperty = 5; ClassWithCompositeId theSecondClass = new ClassWithCompositeId(secondId); theSecondClass.OneProperty = 10; s.Save(theClass); s.Save(theSecondClass); t.Commit(); s.Close(); // verify they were inserted and test the SELECT ISession s2 = sessions.OpenSession(); ITransaction t2 = s2.BeginTransaction(); ClassWithCompositeId theClass2 = (ClassWithCompositeId)s2.Load(typeof(ClassWithCompositeId), id); IList results2 = s2.CreateCriteria(typeof(ClassWithCompositeId)) .Add(Expression.Expression.Eq("Id", secondId)) .List(); Assert.AreEqual(1, results2.Count); ClassWithCompositeId theSecondClass2 = (ClassWithCompositeId)results2[0]; ClassWithCompositeId theClass2Copy = (ClassWithCompositeId)s2.Load(typeof(ClassWithCompositeId), id); // verify the same results through Criteria & Load were achieved Assert.AreSame(theClass2, theClass2Copy); // compare them to the objects created in the first session Assert.AreEqual(theClass.Id, theClass2.Id); Assert.AreEqual(theClass.OneProperty, theClass2.OneProperty); Assert.AreEqual(theSecondClass.Id, theSecondClass2.Id); Assert.AreEqual(theSecondClass.OneProperty, theSecondClass2.OneProperty); // test the update functionallity theClass2.OneProperty = 6; theSecondClass2.OneProperty = 11; s2.Update(theClass2); s2.Update(theSecondClass2); t2.Commit(); s2.Close(); // lets verify the update went through ISession s3 = sessions.OpenSession(); ITransaction t3 = s3.BeginTransaction(); ClassWithCompositeId theClass3 = (ClassWithCompositeId)s3.Load(typeof(ClassWithCompositeId), id); ClassWithCompositeId theSecondClass3 = (ClassWithCompositeId)s3.Load(typeof(ClassWithCompositeId), secondId); // check the update properties Assert.AreEqual(theClass3.OneProperty, theClass2.OneProperty); Assert.AreEqual(theSecondClass3.OneProperty, theSecondClass2.OneProperty); // test the delete method s3.Delete(theClass3); s3.Delete(theSecondClass3); t3.Commit(); s3.Close(); // lets verify the delete went through ISession s4 = sessions.OpenSession(); try { ClassWithCompositeId theClass4 = (ClassWithCompositeId)s4.Load(typeof(ClassWithCompositeId), id); } catch(ObjectNotFoundException onfe) { // I expect this to be thrown because the object no longer exists... Assert.IsNotNull(onfe); //getting ride of 'onfe' is never used compile warning } IList results = s4.CreateCriteria(typeof(ClassWithCompositeId)) .Add(Expression.Expression.Eq("Id", secondId)) .List(); Assert.AreEqual(0, results.Count); } [Test] public void Criteria() { Id id = new Id("stringKey", 3, firstDateTime); ClassWithCompositeId cId = new ClassWithCompositeId(id); cId.OneProperty = 5; // add the new instance to the session so I have something to get results // back for ISession s = sessions.OpenSession(); s.Save(cId); s.Flush(); s.Close(); s = sessions.OpenSession(); ICriteria c = s.CreateCriteria(typeof(ClassWithCompositeId)); c.Add( Expression.Expression.Eq("Id", id) ); // right now just want to see if the Criteria is valid IList results = c.List(); Assert.AreEqual(1, results.Count); s.Close(); } [Test] public void Hql() { // insert the new objects ISession s = sessions.OpenSession(); ITransaction t = s.BeginTransaction(); ClassWithCompositeId theClass = new ClassWithCompositeId(id); theClass.OneProperty = 5; ClassWithCompositeId theSecondClass = new ClassWithCompositeId(secondId); theSecondClass.OneProperty = 10; s.Save(theClass); s.Save(theSecondClass); t.Commit(); s.Close(); ISession s2 = sessions.OpenSession(); IQuery hql = s2.CreateQuery("from ClassWithCompositeId as cwid where cwid.Id.KeyString = :keyString"); hql.SetString("keyString", id.KeyString); IList results = hql.List(); Assert.AreEqual(1, results.Count); } } } --- NEW FILE: ClassWithCompositeId.cs --- using System; namespace NHibernate.Test.CompositeId { /// <summary> /// Summary description for ClassWithCompositeId. /// </summary> public class ClassWithCompositeId { private Id _id; private int _oneProperty; public ClassWithCompositeId(){} public ClassWithCompositeId(Id id ) { _id = id; } public Id Id { get {return _id;} } public int OneProperty { get {return _oneProperty;} set {_oneProperty = value;} } } } --- NEW FILE: ClassWithCompositeId.hbm.xml --- <?xml version="1.0"?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"> <class name="NHibernate.Test.CompositeId.ClassWithCompositeId, NHibernate.Test" table="class_w_com_id" > <composite-id name="Id" class="NHibernate.Test.CompositeId.Id, NHibernate.Test" access="nosetter.camelcase-underscore"> <key-property name="KeyString" column="string_" type="String(20)" length="20" /> <key-property name="KeyShort" column="short_" access="field.camelcase-underscore"/> <key-property name="KeyDateTime" column="date_" type="DateTime" access="nosetter.camelcase-underscore"/> </composite-id> <property name="OneProperty" column="one_property"/> </class> </hibernate-mapping> |
From: Michael D. <mik...@us...> - 2004-12-11 20:08:27
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13895/NHibernate.Test Modified Files: NHibernate.Test-1.1.csproj Log Message: NH-151: added SByteType and Fixture for it Moved nh specific CompositeId tests to their own namespace. Index: NHibernate.Test-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHibernate.Test-1.1.csproj,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** NHibernate.Test-1.1.csproj 10 Dec 2004 16:40:02 -0000 1.52 --- NHibernate.Test-1.1.csproj 11 Dec 2004 20:08:18 -0000 1.53 *************** *** 236,239 **** --- 236,258 ---- /> <File + RelPath = "CompositeId\ClassWithCompositeId.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "CompositeId\ClassWithCompositeId.hbm.xml" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "CompositeId\ClassWithCompositeIdFixture.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "CompositeId\Id.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "DialectTest\DialectFixture.cs" SubType = "Code" *************** *** 397,405 **** /> <File - RelPath = "NHSpecificTest\ClassWithCompositeIdFixture.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File RelPath = "NHSpecificTest\MapFixture.cs" SubType = "Code" --- 416,419 ---- *************** *** 624,627 **** --- 638,646 ---- /> <File + RelPath = "TypesTest\SByteTypeFixture.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TypesTest\TicksTypeFixture.cs" SubType = "Code" |
From: Michael D. <mik...@us...> - 2004-12-11 20:08:27
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/NHSpecific In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13895/NHibernate.DomainModel/NHSpecific Removed Files: ClassWithCompositeId.cs ClassWithCompositeId.hbm.xml CompositeId.cs Log Message: NH-151: added SByteType and Fixture for it Moved nh specific CompositeId tests to their own namespace. --- CompositeId.cs DELETED --- --- ClassWithCompositeId.cs DELETED --- --- ClassWithCompositeId.hbm.xml DELETED --- |
From: Michael D. <mik...@us...> - 2004-12-11 20:05:38
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/CompositeId In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13224/CompositeId Log Message: Directory /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/CompositeId added to the repository |
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32076/SqlTypes Modified Files: AnsiStringFixedLengthSqlType.cs AnsiStringSqlType.cs BinaryBlobSqlType.cs BinarySqlType.cs BooleanSqlType.cs ByteSqlType.cs CurrencySqlType.cs DateSqlType.cs DateTimeSqlType.cs DecimalSqlType.cs DoubleSqlType.cs GuidSqlType.cs Int16SqlType.cs Int32SqlType.cs Int64SqlType.cs SingleSqlType.cs SqlType.cs StringClobSqlType.cs StringFixedLengthSqlType.cs StringSqlType.cs TimeSqlType.cs Added Files: SByteSqlType.cs Log Message: NH-151: added SByteSqlType Still need to add something to the Dialects for schema export. Added comments to the other SqlTypes. Index: AnsiStringFixedLengthSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/AnsiStringFixedLengthSqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AnsiStringFixedLengthSqlType.cs 9 Aug 2004 03:33:54 -0000 1.3 --- AnsiStringFixedLengthSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 *************** *** 5,17 **** { /// <summary> ! /// Summary description for AnsiStringFixedLengthSqlType. /// </summary> [Serializable] public class AnsiStringFixedLengthSqlType : SqlType { public AnsiStringFixedLengthSqlType() : base(DbType.AnsiStringFixedLength) { } public AnsiStringFixedLengthSqlType(int length) : base(DbType.AnsiStringFixedLength, length) { --- 5,30 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.AnsiStringFixedLength"/> with the ! /// information required to to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// This can store the length of the string that the <see cref="IDbDataParameter"/> can hold. + /// If no value is provided for the length then the <c>Driver</c> is responsible for + /// setting the properties on the <see cref="IDbDataParameter"/> correctly. + /// </remarks> [Serializable] public class AnsiStringFixedLengthSqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="AnsiStringFixedLengthSqlType"/> class. + /// </summary> public AnsiStringFixedLengthSqlType() : base(DbType.AnsiStringFixedLength) { } + /// <summary> + /// Initializes a new instance of the <see cref="AnsiStringFixedLengthSqlType"/> class. + /// </summary> + /// <param name="length">The length of the string the <see cref="IDbDataParameter"/> should hold.</param> public AnsiStringFixedLengthSqlType(int length) : base(DbType.AnsiStringFixedLength, length) { Index: CurrencySqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/CurrencySqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CurrencySqlType.cs 9 Aug 2004 03:33:54 -0000 1.3 --- CurrencySqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 *************** *** 2,17 **** using System.Data; ! namespace NHibernate.SqlTypes { ! /// <summary> ! /// Summary description for CurrencySqlType. ! /// ! /// TODO: determine if I want to remove this. There is no native .NET Currency class ! /// and the sql server money = decimal(19,4) and smallmoney = decimal(10,4). So there ! /// is no advantage to using it. /// </summary> [Serializable] public class CurrencySqlType : SqlType { public CurrencySqlType() : base(DbType.Currency) { --- 2,20 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> ! /// Describes the details of a <see cref="DbType.Currency"/> with the ! /// information required to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// There is not any extra information needed for a <see cref="DbType.Currency"/>. + /// </remarks> [Serializable] public class CurrencySqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="CurrencySqlType"/> class. + /// </summary> public CurrencySqlType() : base(DbType.Currency) { Index: SingleSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/SingleSqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SingleSqlType.cs 9 Aug 2004 03:33:54 -0000 1.3 --- SingleSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 *************** *** 5,13 **** { /// <summary> ! /// Summary description for SingleSqlType. /// </summary> [Serializable] public class SingleSqlType : SqlType { public SingleSqlType() : base(DbType.Single) { --- 5,20 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.Single"/> with the ! /// extra information required to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// There is not any extra information needed for a <see cref="DbType.Single"/>. + /// </remarks> [Serializable] public class SingleSqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="SingleSqlType"/> class. + /// </summary> public SingleSqlType() : base(DbType.Single) { Index: DoubleSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/DoubleSqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DoubleSqlType.cs 9 Aug 2004 03:33:54 -0000 1.3 --- DoubleSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 *************** *** 5,13 **** { /// <summary> ! /// Summary description for DoubleSqlType. /// </summary> [Serializable] public class DoubleSqlType : SqlType { public DoubleSqlType() : base(DbType.Double) { --- 5,20 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.Double"/> with the ! /// extra information required to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// There is not any extra information needed for a <see cref="DbType.Double"/>. + /// </remarks> [Serializable] public class DoubleSqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="DoubleSqlType"/> class. + /// </summary> public DoubleSqlType() : base(DbType.Double) { Index: BinaryBlobSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/BinaryBlobSqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BinaryBlobSqlType.cs 25 Aug 2004 03:51:48 -0000 1.1 --- BinaryBlobSqlType.cs 11 Dec 2004 16:28:28 -0000 1.2 *************** *** 5,15 **** { /// <summary> ! /// A SqlType that uses a <see cref="DbType.Binary"/> to generate a Parameter ! /// for the IDriver to write a BLOB value to the database. /// </summary> /// <remarks> /// This is only needed by DataProviders (SqlClient) that need to specify a Size for the /// IDbDataParameter. Most DataProvider(Oralce) don't need to set the Size so a /// BinarySqlType would work just fine. /// </remarks> [Serializable] --- 5,23 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.Binary"/> that is stored in ! /// a BLOB column with the information required to generate ! /// an <see cref="IDbDataParameter"/>. /// </summary> /// <remarks> + /// <p> + /// This can store the length of the binary data that the <see cref="IDbDataParameter"/> can hold. + /// If no value is provided for the length then the <c>Driver</c> is responsible for + /// setting the properties on the <see cref="IDbDataParameter"/> correctly. + /// </p> + /// <p> /// This is only needed by DataProviders (SqlClient) that need to specify a Size for the /// IDbDataParameter. Most DataProvider(Oralce) don't need to set the Size so a /// BinarySqlType would work just fine. + /// </p> /// </remarks> [Serializable] *************** *** 17,23 **** --- 25,39 ---- { + /// <summary> + /// Initializes a new instance of the <see cref="BinaryBlobSqlType"/> class. + /// </summary> public BinaryBlobSqlType() : base() { } + + /// <summary> + /// Initializes a new instance of the <see cref="BinaryBlobSqlType"/> class. + /// </summary> + /// <param name="length">The length of the binary data the <see cref="IDbDataParameter"/> should hold</param> public BinaryBlobSqlType(int length) : base(length) { Index: Int32SqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/Int32SqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Int32SqlType.cs 9 Aug 2004 03:33:54 -0000 1.3 --- Int32SqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 *************** *** 5,13 **** { /// <summary> ! /// Summary description for Int32SqlType. /// </summary> [Serializable] public class Int32SqlType : SqlType { public Int32SqlType(): base(DbType.Int32) { --- 5,20 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.Int32"/> with the ! /// extra information required to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// There is not any extra information needed for a <see cref="DbType.Int32"/>. + /// </remarks> [Serializable] public class Int32SqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="Int32SqlType"/> class. + /// </summary> public Int32SqlType(): base(DbType.Int32) { Index: StringClobSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/StringClobSqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StringClobSqlType.cs 25 Aug 2004 03:51:48 -0000 1.1 --- StringClobSqlType.cs 11 Dec 2004 16:28:28 -0000 1.2 *************** *** 5,15 **** { /// <summary> ! /// A SqlType that uses a <see cref="DbType.String "/> to generate a Parameter ! /// for the IDriver to write a CLOB value to the database. /// </summary> /// <remarks> /// This is only needed by DataProviders (SqlClient) that need to specify a Size for the /// IDbDataParameter. Most DataProvider(Oralce) don't need to set the Size so a /// StringSqlType would work just fine. /// </remarks> [Serializable] --- 5,23 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.String"/> that is stored in ! /// a CLOB column with the information required to generate ! /// an <see cref="IDbDataParameter"/>. /// </summary> /// <remarks> + /// <p> + /// This can store the length of the binary data that the <see cref="IDbDataParameter"/> can hold. + /// If no value is provided for the length then the <c>Driver</c> is responsible for + /// setting the properties on the <see cref="IDbDataParameter"/> correctly. + /// </p> + /// <p> /// This is only needed by DataProviders (SqlClient) that need to specify a Size for the /// IDbDataParameter. Most DataProvider(Oralce) don't need to set the Size so a /// StringSqlType would work just fine. + /// </p> /// </remarks> [Serializable] *************** *** 17,23 **** --- 25,39 ---- { + /// <summary> + /// Initializes a new instance of the <see cref="StringClobSqlType"/> class. + /// </summary> public StringClobSqlType() : base() { } + + /// <summary> + /// Initializes a new instance of the <see cref="StringClobSqlType"/> class. + /// </summary> + /// <param name="length">The length of the string the <see cref="IDbDataParameter"/> should hold.</param> public StringClobSqlType(int length) : base(length) { Index: DateTimeSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/DateTimeSqlType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DateTimeSqlType.cs 9 Aug 2004 03:33:54 -0000 1.4 --- DateTimeSqlType.cs 11 Dec 2004 16:28:28 -0000 1.5 *************** *** 5,13 **** { /// <summary> ! /// Summary description for DateTimeSqlType. /// </summary> [Serializable] public class DateTimeSqlType : SqlType { public DateTimeSqlType() : base(DbType.DateTime) { --- 5,20 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.DateTime"/> with the ! /// extra information required to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// There is not any extra information needed for a <see cref="DbType.DateTime"/>. + /// </remarks> [Serializable] public class DateTimeSqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="DateTimeSqlType"/> class. + /// </summary> public DateTimeSqlType() : base(DbType.DateTime) { Index: BinarySqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/BinarySqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BinarySqlType.cs 9 Aug 2004 03:33:54 -0000 1.3 --- BinarySqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 *************** *** 5,17 **** { /// <summary> ! /// Summary description for BinarySqlType. /// </summary> [Serializable] public class BinarySqlType : SqlType { public BinarySqlType() : base (DbType.Binary) { } public BinarySqlType(int length) : base (DbType.Binary, length) { --- 5,31 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.Binary"/> with the ! /// information required to to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// This can store the binary data that the <see cref="IDbDataParameter"/> can hold. + /// If no value is provided for the length then the <c>Driver</c> is responsible for + /// setting the properties on the <see cref="IDbDataParameter"/> correctly. + /// </remarks> [Serializable] public class BinarySqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="BinarySqlType"/> class. + /// </summary> public BinarySqlType() : base (DbType.Binary) { } + + /// <summary> + /// Initializes a new instance of the <see cref="BinarySqlType"/> class. + /// </summary> + /// <param name="length">The length of the binary data the <see cref="IDbDataParameter"/> should hold</param> public BinarySqlType(int length) : base (DbType.Binary, length) { Index: SqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/SqlType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SqlType.cs 21 Nov 2004 22:56:30 -0000 1.4 --- SqlType.cs 11 Dec 2004 16:28:28 -0000 1.5 *************** *** 5,15 **** { /// <summary> ! /// This is the base class that describes the DbType in further detail so we ! /// can prepare the IDbCommands. Certain SqlTypes have a default length or ! /// precision/scale that can get overriden in the hbm files. ! /// ! /// It is expected that each Dialect will be the one responsible for converting these ! /// objects to the sql string when using SchemaExport. /// </summary> [Serializable] public abstract class SqlType --- 5,22 ---- { /// <summary> ! /// This is the base class that adds information to the <see cref="DbType" /> ! /// for the <see cref="Driver.IDriver"/> and <see cref="Dialect.Dialect"/> ! /// to use. /// </summary> + /// <remarks> + /// <p> + /// The <see cref="Driver.IDriver"/> uses the SqlType to get enough + /// information to create an <see cref="IDbDataParameter"/>. + /// </p> + /// <p> + /// The <see cref="Dialect.Dialect"/> use the SqlType to convert the <see cref="DbType"/> + /// to the appropriate sql type for SchemaExport. + /// </p> + /// </remarks> [Serializable] public abstract class SqlType *************** *** 73,77 **** } ! #region overrides of Object methods public override int GetHashCode() --- 80,84 ---- } ! #region System.Object Members public override int GetHashCode() Index: DecimalSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/DecimalSqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DecimalSqlType.cs 9 Aug 2004 03:33:54 -0000 1.3 --- DecimalSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 *************** *** 5,18 **** { /// <summary> ! /// Summary description for DecimalSqlType. /// </summary> [Serializable] public class DecimalSqlType : SqlType { public DecimalSqlType() : base(DbType.Decimal) { } public DecimalSqlType(byte precision, byte scale) : base(DbType.Decimal, precision, scale) { --- 5,33 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.Decimal"/> with the ! /// information required to to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// This can store the precision & scale of the decimal value that the + /// <see cref="IDbDataParameter"/> can hold. If no value is provided for the + /// precision & scale then the <c>Driver</c> is responsible for + /// setting the properties on the <see cref="IDbDataParameter"/> correctly. + /// </remarks> [Serializable] public class DecimalSqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="DecimalSqlType"/> class. + /// </summary> public DecimalSqlType() : base(DbType.Decimal) { } + /// <summary> + /// Initializes a new instance of the <see cref="DecimalSqlType"/> class. + /// </summary> + /// <param name="precision">The precision of the Decimal the <see cref="IDbDataParameter"/> should hold.</param> + /// <param name="scale">The scale of the Decimal the <see cref="IDbDataParameter"/> should hold.</param> public DecimalSqlType(byte precision, byte scale) : base(DbType.Decimal, precision, scale) { Index: AnsiStringSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/AnsiStringSqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AnsiStringSqlType.cs 9 Aug 2004 03:33:54 -0000 1.3 --- AnsiStringSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 *************** *** 4,17 **** namespace NHibernate.SqlTypes { - /// <summary> ! /// Summary description for AnsiStringSqlType. /// </summary> [Serializable] public class AnsiStringSqlType : SqlType { public AnsiStringSqlType() : base(DbType.AnsiString) { } public AnsiStringSqlType(int length) : base(DbType.AnsiString, length) { --- 4,30 ---- namespace NHibernate.SqlTypes { /// <summary> ! /// Describes the details of a <see cref="DbType.AnsiString"/> with the ! /// information required to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// This can store the length of the string that the <see cref="IDbDataParameter"/> can hold. + /// If no value is provided for the length then the <c>Driver</c> is responsible for + /// setting the properties on the <see cref="IDbDataParameter"/> correctly. + /// </remarks> [Serializable] public class AnsiStringSqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="AnsiStringSqlType"/> class. + /// </summary> public AnsiStringSqlType() : base(DbType.AnsiString) { } + + /// <summary> + /// Initializes a new instance of the <see cref="AnsiStringSqlType"/> class. + /// </summary> + /// <param name="length">The length of the string the <see cref="IDbDataParameter"/> should hold.</param> public AnsiStringSqlType(int length) : base(DbType.AnsiString, length) { Index: StringSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/StringSqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** StringSqlType.cs 9 Aug 2004 03:33:54 -0000 1.3 --- StringSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 *************** *** 5,16 **** { /// <summary> ! /// Summary description for StringSqlType. /// </summary> [Serializable] public class StringSqlType : SqlType { public StringSqlType() : base(DbType.String) { } public StringSqlType(int length) : base(DbType.String, length) { --- 5,30 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.String"/> with the ! /// information required to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// This can store the length of the string that the <see cref="IDbDataParameter"/> can hold. + /// If no value is provided for the length then the <c>Driver</c> is responsible for + /// setting the properties on the <see cref="IDbDataParameter"/> correctly. + /// </remarks> [Serializable] public class StringSqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="StringSqlType"/> class. + /// </summary> public StringSqlType() : base(DbType.String) { } + + /// <summary> + /// Initializes a new instance of the <see cref="StringSqlType"/> class. + /// </summary> + /// <param name="length">The length of the string the <see cref="IDbDataParameter"/> should hold.</param> public StringSqlType(int length) : base(DbType.String, length) { Index: TimeSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/TimeSqlType.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TimeSqlType.cs 9 Aug 2004 03:33:54 -0000 1.2 --- TimeSqlType.cs 11 Dec 2004 16:28:28 -0000 1.3 *************** *** 5,13 **** { /// <summary> ! /// Summary description for TimeSqlType. /// </summary> [Serializable] public class TimeSqlType : SqlType { public TimeSqlType() : base(DbType.Time) { --- 5,20 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.Time"/> with the ! /// extra information required to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// There is not any extra information needed for a <see cref="DbType.Time"/>. + /// </remarks> [Serializable] public class TimeSqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="TimeSqlType"/> class. + /// </summary> public TimeSqlType() : base(DbType.Time) { Index: Int64SqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/Int64SqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Int64SqlType.cs 9 Aug 2004 03:33:54 -0000 1.3 --- Int64SqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 *************** *** 5,13 **** { /// <summary> ! /// Summary description for Int64SqlType. /// </summary> [Serializable] public class Int64SqlType : SqlType { public Int64SqlType(): base(DbType.Int64) { --- 5,20 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.Int64"/> with the ! /// extra information required to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// There is not any extra information needed for a <see cref="DbType.Int64"/>. + /// </remarks> [Serializable] public class Int64SqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="Int64SqlType"/> class. + /// </summary> public Int64SqlType(): base(DbType.Int64) { Index: ByteSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/ByteSqlType.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ByteSqlType.cs 9 Aug 2004 03:33:54 -0000 1.2 --- ByteSqlType.cs 11 Dec 2004 16:28:28 -0000 1.3 *************** *** 2,14 **** using System.Data; ! namespace NHibernate.SqlTypes { ! /// <summary> ! /// Summary description for ByteSqlType. /// </summary> [Serializable] public class ByteSqlType : SqlType { ! public ByteSqlType() : base(DbType.Byte){ } } --- 2,22 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> ! /// Describes the details of a <see cref="DbType.Byte"/> with the ! /// information required to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// There is not any extra information needed for a <see cref="DbType.Byte"/>. + /// </remarks> [Serializable] public class ByteSqlType : SqlType { ! /// <summary> ! /// Initializes a new instance of the <see cref="ByteSqlType"/> class. ! /// </summary> ! public ByteSqlType() : base(DbType.Byte) ! { } } Index: DateSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/DateSqlType.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DateSqlType.cs 9 Aug 2004 03:33:54 -0000 1.2 --- DateSqlType.cs 11 Dec 2004 16:28:28 -0000 1.3 *************** *** 5,13 **** { /// <summary> ! /// Summary description for DateSqlType. /// </summary> [Serializable] public class DateSqlType : SqlType { public DateSqlType() : base(DbType.Date) { --- 5,20 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.Date"/> with the ! /// extra information required to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// There is not any extra information needed for a <see cref="DbType.Date"/>. + /// </remarks> [Serializable] public class DateSqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="DateSqlType"/> class. + /// </summary> public DateSqlType() : base(DbType.Date) { Index: Int16SqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/Int16SqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Int16SqlType.cs 9 Aug 2004 03:33:54 -0000 1.3 --- Int16SqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 *************** *** 5,13 **** { /// <summary> ! /// Summary description for Int16SqlType. /// </summary> [Serializable] public class Int16SqlType : SqlType { public Int16SqlType(): base(DbType.Int16) { --- 5,20 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.Int16"/> with the ! /// extra information required to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// There is not any extra information needed for a <see cref="DbType.Int16"/>. + /// </remarks> [Serializable] public class Int16SqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="Int16SqlType"/> class. + /// </summary> public Int16SqlType(): base(DbType.Int16) { Index: StringFixedLengthSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/StringFixedLengthSqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** StringFixedLengthSqlType.cs 9 Aug 2004 03:33:54 -0000 1.3 --- StringFixedLengthSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 *************** *** 5,17 **** { /// <summary> ! /// Summary description for StringFixedLengthSqlType. /// </summary> [Serializable] public class StringFixedLengthSqlType : SqlType { public StringFixedLengthSqlType() : base(DbType.StringFixedLength) { } public StringFixedLengthSqlType(int length) : base(DbType.StringFixedLength, length) { --- 5,30 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.StringFixedLength"/> with the ! /// information required to to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// This can store the length of the string that the <see cref="IDbDataParameter"/> can hold. + /// If no value is provided for the length then the <c>Driver</c> is responsible for + /// setting the properties on the <see cref="IDbDataParameter"/> correctly. + /// </remarks> [Serializable] public class StringFixedLengthSqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="StringFixedLengthSqlType"/> class. + /// </summary> public StringFixedLengthSqlType() : base(DbType.StringFixedLength) { } + /// <summary> + /// Initializes a new instance of the <see cref="StringFixedLengthSqlType"/> class. + /// </summary> + /// <param name="length">The length of the string the <see cref="IDbDataParameter"/> should hold.</param> public StringFixedLengthSqlType(int length) : base(DbType.StringFixedLength, length) { Index: BooleanSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/BooleanSqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BooleanSqlType.cs 9 Aug 2004 03:33:54 -0000 1.3 --- BooleanSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 *************** *** 5,13 **** { /// <summary> ! /// Summary description for BooleanSqlType. /// </summary> [Serializable] public class BooleanSqlType : SqlType { public BooleanSqlType() : base(DbType.Boolean) { --- 5,20 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.Boolean"/> with the ! /// information required to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// There is not any extra information needed for a <see cref="DbType.Boolean"/>. + /// </remarks> [Serializable] public class BooleanSqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="BooleanSqlType"/> class. + /// </summary> public BooleanSqlType() : base(DbType.Boolean) { --- NEW FILE: SByteSqlType.cs --- using System; using System.Data; namespace NHibernate.SqlTypes { /// <summary> /// Describes the details of a <see cref="DbType.SByte"/> with the /// extra information required to generate an <see cref="IDbDataParameter"/>. /// </summary> /// <remarks> /// There is not any extra information needed for a <see cref="DbType.SByte"/>. /// </remarks> [Serializable] public class SByteSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="SByteSqlType"/> class. /// </summary> public SByteSqlType() : base(DbType.SByte) { } } } Index: GuidSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/GuidSqlType.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GuidSqlType.cs 9 Aug 2004 03:33:54 -0000 1.2 --- GuidSqlType.cs 11 Dec 2004 16:28:28 -0000 1.3 *************** *** 1,3 **** - using System; using System.Data; --- 1,2 ---- *************** *** 6,14 **** { /// <summary> ! /// Summary description for GuidSqlType. /// </summary> [Serializable] public class GuidSqlType : SqlType { public GuidSqlType() : base(DbType.Guid) { --- 5,20 ---- { /// <summary> ! /// Describes the details of a <see cref="DbType.Guid"/> with the ! /// extra information required to generate an <see cref="IDbDataParameter"/>. /// </summary> + /// <remarks> + /// There is not any extra information needed for a <see cref="DbType.Guid"/>. + /// </remarks> [Serializable] public class GuidSqlType : SqlType { + /// <summary> + /// Initializes a new instance of the <see cref="GuidSqlType"/> class. + /// </summary> public GuidSqlType() : base(DbType.Guid) { |
From: Michael D. <mik...@us...> - 2004-12-11 16:28:37
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32076 Modified Files: NHibernate-1.1.csproj Log Message: NH-151: added SByteSqlType Still need to add something to the Dialects for schema export. Added comments to the other SqlTypes. Index: NHibernate-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate-1.1.csproj,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** NHibernate-1.1.csproj 9 Dec 2004 22:08:55 -0000 1.63 --- NHibernate-1.1.csproj 11 Dec 2004 16:28:27 -0000 1.64 *************** *** 1615,1618 **** --- 1615,1623 ---- /> <File + RelPath = "SqlTypes\SByteSqlType.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "SqlTypes\SingleSqlType.cs" SubType = "Code" |
From: Donald L M. Jr. <lu...@us...> - 2004-12-10 18:25:09
|
Update of /cvsroot/nhibernate/NHibernateContrib/src/Nullables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5667/src/Nullables Modified Files: NullableBoolean.cs NullableByte.cs NullableDateTime.cs NullableDecimal.cs NullableDouble.cs NullableGuid.cs NullableInt16.cs NullableInt32.cs NullableInt64.cs NullableSingle.cs Added Files: NullableSByte.cs Log Message: Implemented IComparable. Added NullableSByte, but it is inactive until further investigation. Index: NullableInt16.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables/NullableInt16.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NullableInt16.cs 7 Dec 2004 21:32:49 -0000 1.2 --- NullableInt16.cs 10 Dec 2004 18:24:22 -0000 1.3 *************** *** 4,8 **** { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableInt16Converter)), Serializable()] ! public struct NullableInt16 : INullableType, IFormattable { public static readonly NullableInt16 Default = new NullableInt16(); --- 4,8 ---- { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableInt16Converter)), Serializable()] ! public struct NullableInt16 : INullableType, IFormattable, IComparable { public static readonly NullableInt16 Default = new NullableInt16(); *************** *** 166,169 **** --- 166,207 ---- #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + if (obj is NullableInt16) //chack and unbox + { + NullableInt16 value = (NullableInt16)obj; + + if (value.HasValue == this.HasValue) //both null or not null + { + if (this.HasValue) //this has a value, so they both do + return Value.CompareTo(value.Value); + else + return 0; //both null, so they are equal; + } + else //one is null + { + if (HasValue) //he have a value, so we are greater. + return 1; + else + return -1; + } + } + else if (obj is Int16) + { + Int16 value = (Int16)obj; + + if (HasValue) //not null, so compare the real values. + return Value.CompareTo(value); + else + return -1; //this is null, so less that the real value; + } + + throw new ArgumentException("NullableInt16 can only compare to another NullableInt16 or a System.Int16"); + } + + #endregion } } Index: NullableInt32.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables/NullableInt32.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NullableInt32.cs 7 Dec 2004 21:32:49 -0000 1.2 --- NullableInt32.cs 10 Dec 2004 18:24:22 -0000 1.3 *************** *** 5,9 **** { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableInt32Converter)), Serializable()] ! public struct NullableInt32 : INullableType, IFormattable { public static readonly NullableInt32 Default = new NullableInt32(); --- 5,9 ---- { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableInt32Converter)), Serializable()] ! public struct NullableInt32 : INullableType, IFormattable, IComparable { public static readonly NullableInt32 Default = new NullableInt32(); *************** *** 167,170 **** --- 167,208 ---- #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + if (obj is NullableInt32) //chack and unbox + { + NullableInt32 value = (NullableInt32)obj; + + if (value.HasValue == this.HasValue) //both null or not null + { + if (this.HasValue) //this has a value, so they both do + return Value.CompareTo(value.Value); + else + return 0; //both null, so they are equal; + } + else //one is null + { + if (HasValue) //he have a value, so we are greater. + return 1; + else + return -1; + } + } + else if (obj is DateTime) + { + Int32 value = (Int32)obj; + + if (HasValue) //not null, so compare the real values. + return Value.CompareTo(value); + else + return -1; //this is null, so less that the real value; + } + + throw new ArgumentException("NullableInt32 can only compare to another NullableInt32 or a System.Int32"); + } + + #endregion } } Index: NullableByte.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables/NullableByte.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NullableByte.cs 7 Dec 2004 21:32:49 -0000 1.2 --- NullableByte.cs 10 Dec 2004 18:24:22 -0000 1.3 *************** *** 4,8 **** { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableByteConverter)), Serializable()] ! public struct NullableByte : INullableType, IFormattable { public static readonly NullableByte Default = new NullableByte(); --- 4,8 ---- { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableByteConverter)), Serializable()] ! public struct NullableByte : INullableType, IFormattable, IComparable { public static readonly NullableByte Default = new NullableByte(); *************** *** 166,169 **** --- 166,207 ---- #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + if (obj is NullableByte) //chack and unbox + { + NullableByte value = (NullableByte)obj; + + if (value.HasValue == this.HasValue) //both null or not null + { + if (this.HasValue) //this has a value, so they both do + return Value.CompareTo(value.Value); + else + return 0; //both null, so they are equal; + } + else //one is null + { + if (HasValue) //he have a value, so we are greater. + return 1; + else + return -1; + } + } + else if (obj is Byte) + { + Byte value = (Byte)obj; + + if (HasValue) //not null, so compare the real values. + return Value.CompareTo(value); + else + return -1; //this is null, so less that the real value; + } + + throw new ArgumentException("NullableByte can only compare to another NullableByte or a System.Byte"); + } + + #endregion } } --- NEW FILE: NullableSByte.cs --- using System; //Contributed by Sergey Koshcheyev namespace Nullables { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableSByteConverter)), Serializable()] public struct NullableSByte : INullableType, IFormattable, IComparable { public static readonly NullableSByte Default = new NullableSByte(); SByte _value; bool hasValue; #region Constructors public NullableSByte(SByte value) { _value = value; hasValue = true; } #endregion #region INullable Members object INullableType.Value { get { return Value; } } public bool HasValue { get { return hasValue; } } #endregion public SByte Value { get { return _value; } } #region Casts public static explicit operator SByte(NullableSByte nullable) { if (!nullable.HasValue) throw new NullReferenceException(); return nullable.Value; } public static implicit operator NullableSByte(SByte value) { return new NullableSByte(value); } public static implicit operator NullableSByte(DBNull value) { return NullableSByte.Default; } #endregion public override string ToString() { if (HasValue) return Value.ToString(); else return string.Empty; } public override bool Equals(object obj) { if (obj is DBNull && !HasValue) return true; else if (obj is NullableSByte) return Equals((NullableSByte)obj); else return false; //if this is reached, it is either some other type, or DBnull is compared with this and we have a Value. } public bool Equals(NullableSByte x) { return Equals(this, x); } public static bool Equals(NullableSByte x, NullableSByte y) { if (x.HasValue != y.HasValue) //one is null return false; else if (x.HasValue) //therefor y also HasValue return x.Value == y.Value; else //both are null return true; } public static bool operator ==(NullableSByte x, NullableSByte y) { return x.Equals(y); } public static bool operator ==(NullableSByte x, object y) { return x.Equals(y); } public static bool operator !=(NullableSByte x, NullableSByte y) { return !x.Equals(y); } public static bool operator !=(NullableSByte x, object y) { return !x.Equals(y); } public static NullableInt32 operator +(NullableSByte x, NullableSByte y) { if (!x.HasValue || !y.HasValue) //one or both are null return NullableInt32.Default; return new NullableInt32(x.Value + y.Value); } public static NullableInt32 operator -(NullableSByte x, NullableSByte y) { if (!x.HasValue || !y.HasValue) //one or both are null return NullableInt32.Default; return new NullableInt32(x.Value - y.Value); } public static NullableInt32 operator *(NullableSByte x, NullableSByte y) { if (!x.HasValue || !y.HasValue) //one or both are null return NullableInt32.Default; return new NullableInt32(x.Value * y.Value); } public static NullableInt32 operator /(NullableSByte x, NullableSByte y) { if (!x.HasValue || !y.HasValue) //one or both are null return NullableInt32.Default; return new NullableInt32(x.Value / y.Value); } public override int GetHashCode() { if (HasValue) return Value.GetHashCode(); else return 0; //GetHashCode() doesn't garantee uniqueness, and neither do we. } #region IFormattable Members string System.IFormattable.ToString(string format, IFormatProvider formatProvider) { if (HasValue) return Value.ToString(format, formatProvider); else return string.Empty; } #endregion #region IComparable Members public int CompareTo(object obj) { if (obj is NullableSByte) //chack and unbox { NullableSByte value = (NullableSByte)obj; if (value.HasValue == this.HasValue) //both null or not null { if (this.HasValue) //this has a value, so they both do return Value.CompareTo(value.Value); else return 0; //both null, so they are equal; } else //one is null { if (HasValue) //he have a value, so we are greater. return 1; else return -1; } } else if (obj is DateTime) { SByte value = (SByte)obj; if (HasValue) //not null, so compare the real values. return Value.CompareTo(value); else return -1; //this is null, so less that the real value; } throw new ArgumentException("NullableSByte can only compare to another NullableSByte or a System.SByte"); } #endregion } } Index: NullableDouble.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables/NullableDouble.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NullableDouble.cs 7 Dec 2004 21:32:49 -0000 1.2 --- NullableDouble.cs 10 Dec 2004 18:24:22 -0000 1.3 *************** *** 4,8 **** { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableDoubleConverter)), Serializable()] ! public struct NullableDouble : INullableType, IFormattable { public static readonly NullableDouble Default = new NullableDouble(); --- 4,8 ---- { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableDoubleConverter)), Serializable()] ! public struct NullableDouble : INullableType, IFormattable, IComparable { public static readonly NullableDouble Default = new NullableDouble(); *************** *** 166,169 **** --- 166,207 ---- #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + if (obj is NullableDouble) //chack and unbox + { + NullableDouble value = (NullableDouble)obj; + + if (value.HasValue == this.HasValue) //both null or not null + { + if (this.HasValue) //this has a value, so they both do + return Value.CompareTo(value.Value); + else + return 0; //both null, so they are equal; + } + else //one is null + { + if (HasValue) //he have a value, so we are greater. + return 1; + else + return -1; + } + } + else if (obj is Double) + { + Double value = (Double)obj; + + if (HasValue) //not null, so compare the real values. + return Value.CompareTo(value); + else + return -1; //this is null, so less that the real value; + } + + throw new ArgumentException("NullableDouble can only compare to another NullableDouble or a System.Double"); + } + + #endregion } } Index: NullableDateTime.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables/NullableDateTime.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NullableDateTime.cs 7 Dec 2004 21:32:49 -0000 1.2 --- NullableDateTime.cs 10 Dec 2004 18:24:22 -0000 1.3 *************** *** 4,8 **** { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableDateTimeConverter)), Serializable()] ! public struct NullableDateTime : INullableType, IFormattable { public static readonly NullableDateTime Default = new NullableDateTime(); --- 4,8 ---- { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableDateTimeConverter)), Serializable()] ! public struct NullableDateTime : INullableType, IFormattable, IComparable { public static readonly NullableDateTime Default = new NullableDateTime(); *************** *** 136,139 **** --- 136,177 ---- #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + if (obj is NullableDateTime) //chack and unbox + { + NullableDateTime value = (NullableDateTime)obj; + + if (value.HasValue == this.HasValue) //both null or not null + { + if (this.HasValue) //this has a value, so they both do + return Value.CompareTo(value.Value); + else + return 0; //both null, so they are equal; + } + else //one is null + { + if (HasValue) //he have a value, so we are greater. + return 1; + else + return -1; + } + } + else if (obj is DateTime) + { + DateTime value = (DateTime)obj; + + if (HasValue) //not null, so compare the real values. + return Value.CompareTo(value); + else + return -1; //this is null, so less that the real value; + } + + throw new ArgumentException("NullableDateTime can only compare to another NullableDateTime or a System.DateTime"); + } + + #endregion } } Index: NullableDecimal.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables/NullableDecimal.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NullableDecimal.cs 7 Dec 2004 21:32:49 -0000 1.2 --- NullableDecimal.cs 10 Dec 2004 18:24:22 -0000 1.3 *************** *** 4,8 **** { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableDecimalConverter)), Serializable()] ! public struct NullableDecimal : INullableType, IFormattable { public static readonly NullableDecimal Default = new NullableDecimal(); --- 4,8 ---- { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableDecimalConverter)), Serializable()] ! public struct NullableDecimal : INullableType, IFormattable, IComparable { public static readonly NullableDecimal Default = new NullableDecimal(); *************** *** 166,169 **** --- 166,207 ---- #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + if (obj is NullableDecimal) //chack and unbox + { + NullableDecimal value = (NullableDecimal)obj; + + if (value.HasValue == this.HasValue) //both null or not null + { + if (this.HasValue) //this has a value, so they both do + return Value.CompareTo(value.Value); + else + return 0; //both null, so they are equal; + } + else //one is null + { + if (HasValue) //he have a value, so we are greater. + return 1; + else + return -1; + } + } + else if (obj is Decimal) + { + Decimal value = (Decimal)obj; + + if (HasValue) //not null, so compare the real values. + return Value.CompareTo(value); + else + return -1; //this is null, so less that the real value; + } + + throw new ArgumentException("NullableDecimal can only compare to another NullableDecimal or a System.Decimal"); + } + + #endregion } } Index: NullableBoolean.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables/NullableBoolean.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NullableBoolean.cs 12 Nov 2004 22:08:25 -0000 1.1 --- NullableBoolean.cs 10 Dec 2004 18:24:21 -0000 1.2 *************** *** 4,8 **** { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableBooleanConverter)), Serializable()] ! public struct NullableBoolean : INullableType { public static readonly NullableBoolean Default = new NullableBoolean(); --- 4,8 ---- { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableBooleanConverter)), Serializable()] ! public struct NullableBoolean : INullableType, IComparable { public static readonly NullableBoolean Default = new NullableBoolean(); *************** *** 124,127 **** --- 124,165 ---- //TODO: Operators for bool (or, and, xor, etc) + + #region IComparable Members + + public int CompareTo(object obj) + { + if (obj is NullableBoolean) //chack and unbox + { + NullableBoolean value = (NullableBoolean)obj; + + if (value.HasValue == this.HasValue) //both null or not null + { + if (this.HasValue) //this has a value, so they both do + return Value.CompareTo(value.Value); + else + return 0; //both null, so they are equal; + } + else //one is null + { + if (HasValue) //he have a value, so we are greater. + return 1; + else + return -1; + } + } + else if (obj is Boolean) + { + Boolean value = (Boolean)obj; + + if (HasValue) //not null, so compare the real values. + return Value.CompareTo(value); + else + return -1; //this is null, so less that the real value; + } + + throw new ArgumentException("NullableBoolean can only compare to another NullableBoolean or a System.Boolean"); + } + + #endregion } } Index: NullableSingle.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables/NullableSingle.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NullableSingle.cs 7 Dec 2004 21:32:49 -0000 1.2 --- NullableSingle.cs 10 Dec 2004 18:24:22 -0000 1.3 *************** *** 4,8 **** { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableSingleConverter)), Serializable()] ! public struct NullableSingle : INullableType, IFormattable { public static readonly NullableSingle Default = new NullableSingle(); --- 4,8 ---- { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableSingleConverter)), Serializable()] ! public struct NullableSingle : INullableType, IFormattable, IComparable { public static readonly NullableSingle Default = new NullableSingle(); *************** *** 166,169 **** --- 166,207 ---- #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + if (obj is NullableSingle) //chack and unbox + { + NullableSingle value = (NullableSingle)obj; + + if (value.HasValue == this.HasValue) //both null or not null + { + if (this.HasValue) //this has a value, so they both do + return Value.CompareTo(value.Value); + else + return 0; //both null, so they are equal; + } + else //one is null + { + if (HasValue) //he have a value, so we are greater. + return 1; + else + return -1; + } + } + else if (obj is Single) + { + Single value = (Single)obj; + + if (HasValue) //not null, so compare the real values. + return Value.CompareTo(value); + else + return -1; //this is null, so less that the real value; + } + + throw new ArgumentException("NullableSingle can only compare to another NullableSingle or a System.Single"); + } + + #endregion } } Index: NullableGuid.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables/NullableGuid.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NullableGuid.cs 7 Dec 2004 21:32:49 -0000 1.2 --- NullableGuid.cs 10 Dec 2004 18:24:22 -0000 1.3 *************** *** 5,9 **** { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableGuidConverter)), Serializable()] ! public struct NullableGuid : INullableType, IFormattable { public static readonly NullableGuid Default = new NullableGuid(); --- 5,9 ---- { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableGuidConverter)), Serializable()] ! public struct NullableGuid : INullableType, IFormattable, IComparable { public static readonly NullableGuid Default = new NullableGuid(); *************** *** 135,138 **** --- 135,176 ---- #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + if (obj is NullableGuid) //chack and unbox + { + NullableGuid value = (NullableGuid)obj; + + if (value.HasValue == this.HasValue) //both null or not null + { + if (this.HasValue) //this has a value, so they both do + return Value.CompareTo(value.Value); + else + return 0; //both null, so they are equal; + } + else //one is null + { + if (HasValue) //he have a value, so we are greater. + return 1; + else + return -1; + } + } + else if (obj is Guid) + { + Guid value = (Guid)obj; + + if (HasValue) //not null, so compare the real values. + return Value.CompareTo(value); + else + return -1; //this is null, so less that the real value; + } + + throw new ArgumentException("NullableGuid can only compare to another NullableGuid or a System.Guid"); + } + + #endregion } } Index: NullableInt64.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables/NullableInt64.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NullableInt64.cs 7 Dec 2004 21:32:49 -0000 1.2 --- NullableInt64.cs 10 Dec 2004 18:24:22 -0000 1.3 *************** *** 4,8 **** { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableInt64Converter)), Serializable()] ! public struct NullableInt64 : INullableType, IFormattable { public static readonly NullableInt64 Default = new NullableInt64(); --- 4,8 ---- { [System.ComponentModel.TypeConverter(typeof(Nullables.TypeConverters.NullableInt64Converter)), Serializable()] ! public struct NullableInt64 : INullableType, IFormattable, IComparable { public static readonly NullableInt64 Default = new NullableInt64(); *************** *** 166,169 **** --- 166,207 ---- #endregion + + #region IComparable Members + + public int CompareTo(object obj) + { + if (obj is NullableInt64) //chack and unbox + { + NullableInt64 value = (NullableInt64)obj; + + if (value.HasValue == this.HasValue) //both null or not null + { + if (this.HasValue) //this has a value, so they both do + return Value.CompareTo(value.Value); + else + return 0; //both null, so they are equal; + } + else //one is null + { + if (HasValue) //he have a value, so we are greater. + return 1; + else + return -1; + } + } + else if (obj is DateTime) + { + Int64 value = (Int64)obj; + + if (HasValue) //not null, so compare the real values. + return Value.CompareTo(value); + else + return -1; //this is null, so less that the real value; + } + + throw new ArgumentException("NullableInt64 can only compare to another NullableInt64 or a System.Int64"); + } + + #endregion } } |
From: Donald L M. Jr. <lu...@us...> - 2004-12-10 18:25:09
|
Update of /cvsroot/nhibernate/NHibernateContrib/src/Nullables.Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5667/src/Nullables.Tests Modified Files: NullableBooleanFixture.cs NullableByteFixture.cs NullableDateTimeFixture.cs NullableDecimalFixture.cs NullableDoubleFixture.cs NullableGuidFixture.cs NullableInt16Fixture.cs NullableInt32Fixture.cs NullableInt64Fixture.cs NullableSingleFixture.cs Added Files: NullableSByteFixture.cs Log Message: Implemented IComparable. Added NullableSByte, but it is inactive until further investigation. Index: NullableBooleanFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables.Tests/NullableBooleanFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NullableBooleanFixture.cs 6 Dec 2004 03:17:00 -0000 1.1 --- NullableBooleanFixture.cs 10 Dec 2004 18:24:20 -0000 1.2 *************** *** 19,22 **** --- 19,47 ---- // } + + [Test] + public void BooleanIComparableTest() + { + NullableBoolean x; + NullableBoolean y; + + //one null, one not + x = NullableBoolean.Default; + y = new NullableBoolean(true); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + + //now both null + x = NullableBoolean.Default; + y = NullableBoolean.Default; + Assert.IsTrue(x.CompareTo(y) == 0); + Assert.IsTrue(y.CompareTo(x) == 0); + + //now both with a value + x = new NullableBoolean(false); + y = new NullableBoolean(true); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + } } } Index: NullableGuidFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables.Tests/NullableGuidFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NullableGuidFixture.cs 6 Dec 2004 03:17:00 -0000 1.1 --- NullableGuidFixture.cs 10 Dec 2004 18:24:20 -0000 1.2 *************** *** 43,46 **** --- 43,71 ---- Assert.IsTrue(v2.Equals(DBNull.Value)); } + + [Test] + public void GuidIComparableTest() + { + NullableGuid x; + NullableGuid y; + + //one null, one not + x = NullableGuid.Default; + y = new NullableGuid(new Guid("12345678-1234-1234-1234-123456789012")); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + + //now both null + x = NullableGuid.Default; + y = NullableGuid.Default; + Assert.IsTrue(x.CompareTo(y) == 0); + Assert.IsTrue(y.CompareTo(x) == 0); + + //now both with a value + x = new NullableGuid(new Guid("12345678-1234-1234-1234-123456789001")); + y = new NullableGuid(new Guid("12345678-1234-1234-1234-123456789099")); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + } } } Index: NullableDateTimeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables.Tests/NullableDateTimeFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NullableDateTimeFixture.cs 6 Dec 2004 03:17:00 -0000 1.1 --- NullableDateTimeFixture.cs 10 Dec 2004 18:24:20 -0000 1.2 *************** *** 43,46 **** --- 43,71 ---- Assert.IsTrue(v2.Equals(DBNull.Value)); } + + [Test] + public void DateTimeIComparableTest() + { + NullableDateTime x; + NullableDateTime y; + + //one null, one not + x = NullableDateTime.Default; + y = new NullableDateTime(new DateTime(2000, 12, 25)); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + + //now both null + x = NullableDateTime.Default; + y = NullableDateTime.Default; + Assert.IsTrue(x.CompareTo(y) == 0); + Assert.IsTrue(y.CompareTo(x) == 0); + + //now both with a value + x = new NullableDateTime(new DateTime(2000, 11, 1)); + y = new NullableDateTime(new DateTime(2000, 12, 25)); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + } } } Index: NullableInt16Fixture.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables.Tests/NullableInt16Fixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NullableInt16Fixture.cs 6 Dec 2004 03:17:00 -0000 1.1 --- NullableInt16Fixture.cs 10 Dec 2004 18:24:20 -0000 1.2 *************** *** 43,46 **** --- 43,71 ---- Assert.IsTrue(v2.Equals(DBNull.Value)); } + + [Test] + public void Int16IComparableTest() + { + NullableInt16 x; + NullableInt16 y; + + //one null, one not + x = NullableInt16.Default; + y = new NullableInt16(16); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + + //now both null + x = NullableInt16.Default; + y = NullableInt16.Default; + Assert.IsTrue(x.CompareTo(y) == 0); + Assert.IsTrue(y.CompareTo(x) == 0); + + //now both with a value + x = new NullableInt16(5); + y = new NullableInt16(43); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + } } } Index: NullableDoubleFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables.Tests/NullableDoubleFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NullableDoubleFixture.cs 6 Dec 2004 03:17:00 -0000 1.1 --- NullableDoubleFixture.cs 10 Dec 2004 18:24:20 -0000 1.2 *************** *** 43,46 **** --- 43,71 ---- Assert.IsTrue(v2.Equals(DBNull.Value)); } + + [Test] + public void DoubleIComparableTest() + { + NullableDouble x; + NullableDouble y; + + //one null, one not + x = NullableDouble.Default; + y = new NullableDouble(0.5); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + + //now both null + x = NullableDouble.Default; + y = NullableDouble.Default; + Assert.IsTrue(x.CompareTo(y) == 0); + Assert.IsTrue(y.CompareTo(x) == 0); + + //now both with a value + x = new NullableDouble(0.6); + y = new NullableDouble(0.67); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + } } } Index: NullableInt64Fixture.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables.Tests/NullableInt64Fixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NullableInt64Fixture.cs 6 Dec 2004 03:17:00 -0000 1.1 --- NullableInt64Fixture.cs 10 Dec 2004 18:24:20 -0000 1.2 *************** *** 44,47 **** --- 44,72 ---- } + [Test] + public void Int64IComparableTest() + { + NullableInt64 x; + NullableInt64 y; + + //one null, one not + x = NullableInt64.Default; + y = new NullableInt64(16); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + + //now both null + x = NullableInt64.Default; + y = NullableInt64.Default; + Assert.IsTrue(x.CompareTo(y) == 0); + Assert.IsTrue(y.CompareTo(x) == 0); + + //now both with a value + x = new NullableInt64(5); + y = new NullableInt64(43); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + } + } } \ No newline at end of file Index: NullableDecimalFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables.Tests/NullableDecimalFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NullableDecimalFixture.cs 6 Dec 2004 03:17:00 -0000 1.1 --- NullableDecimalFixture.cs 10 Dec 2004 18:24:20 -0000 1.2 *************** *** 43,46 **** --- 43,71 ---- Assert.IsTrue(v2.Equals(DBNull.Value)); } + + [Test] + public void DecimalIComparableTest() + { + NullableDecimal x; + NullableDecimal y; + + //one null, one not + x = NullableDecimal.Default; + y = new NullableDecimal(10.03m); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + + //now both null + x = NullableDecimal.Default; + y = NullableDecimal.Default; + Assert.IsTrue(x.CompareTo(y) == 0); + Assert.IsTrue(y.CompareTo(x) == 0); + + //now both with a value + x = new NullableDecimal(15.3m); + y = new NullableDecimal(18.02m); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + } } } --- NEW FILE: NullableSByteFixture.cs --- using System; using Nullables; using NUnit.Framework; namespace Nullables.Tests { /// <summary> /// Summary description for NullableSByteFixture. /// </summary> [TestFixture] public class NullableSByteFixture { public NullableSByteFixture() { } [Test] public void BasicTestSByte() { NullableSByte v1 = 32; //should take an int literal Assert.IsTrue(v1.HasValue); //should have a value; Assert.IsTrue(v1.Equals(32)); //implicit casting should make this result in true. Assert.IsTrue(v1.Value == 32); Assert.IsFalse(v1.Equals(NullableSByte.Default)); Assert.IsTrue(v1.Equals(new NullableSByte(32))); //should == a new instance with the same inner value. //same thing, but with == instead of .Equals() Assert.IsTrue(v1 == 32); Assert.IsFalse(v1 == 33); Assert.IsFalse(v1 == NullableSByte.Default); Assert.IsTrue(v1 == new NullableSByte(32)); //now null v1. v1 = DBNull.Value; Assert.IsTrue(v1 == NullableSByte.Default); v1 = NullableSByte.Default; Assert.IsTrue(v1 == NullableSByte.Default); NullableSByte v2 = NullableSByte.Default; //should start as "null" Assert.IsFalse(v2.HasValue); Assert.IsFalse(v2.Equals(12)); Assert.IsTrue(v2.Equals(NullableSByte.Default)); Assert.IsTrue(v2.Equals(DBNull.Value)); } [Test] public void SByteIComparableTest() { NullableSByte x; NullableSByte y; //one null, one not x = NullableSByte.Default; y = new NullableSByte(16); Assert.IsTrue(x.CompareTo(y) < 0); Assert.IsTrue(y.CompareTo(x) > 0); //now both null x = NullableSByte.Default; y = NullableSByte.Default; Assert.IsTrue(x.CompareTo(y) == 0); Assert.IsTrue(y.CompareTo(x) == 0); //now both with a value x = new NullableSByte(5); y = new NullableSByte(43); Assert.IsTrue(x.CompareTo(y) < 0); Assert.IsTrue(y.CompareTo(x) > 0); } } } Index: NullableSingleFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables.Tests/NullableSingleFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NullableSingleFixture.cs 6 Dec 2004 03:17:00 -0000 1.1 --- NullableSingleFixture.cs 10 Dec 2004 18:24:20 -0000 1.2 *************** *** 43,46 **** --- 43,71 ---- Assert.IsTrue(v2.Equals(DBNull.Value)); } + + [Test] + public void SingleIComparableTest() + { + NullableSingle x; + NullableSingle y; + + //one null, one not + x = NullableSingle.Default; + y = new NullableSingle(1.6f); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + + //now both null + x = NullableSingle.Default; + y = NullableSingle.Default; + Assert.IsTrue(x.CompareTo(y) == 0); + Assert.IsTrue(y.CompareTo(x) == 0); + + //now both with a value + x = new NullableSingle(5.1f); + y = new NullableSingle(8.9f); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + } } } Index: NullableByteFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables.Tests/NullableByteFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NullableByteFixture.cs 6 Dec 2004 03:17:00 -0000 1.1 --- NullableByteFixture.cs 10 Dec 2004 18:24:20 -0000 1.2 *************** *** 43,46 **** --- 43,71 ---- Assert.IsTrue(v2.Equals(DBNull.Value)); } + + [Test] + public void ByteIComparableTest() + { + NullableByte x; + NullableByte y; + + //one null, one not + x = NullableByte.Default; + y = new NullableByte(12); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + + //now both null + x = NullableByte.Default; + y = NullableByte.Default; + Assert.IsTrue(x.CompareTo(y) == 0); + Assert.IsTrue(y.CompareTo(x) == 0); + + //now both with a value + x = new NullableByte(5); + y = new NullableByte(101); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + } } } Index: NullableInt32Fixture.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables.Tests/NullableInt32Fixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NullableInt32Fixture.cs 6 Dec 2004 03:17:00 -0000 1.1 --- NullableInt32Fixture.cs 10 Dec 2004 18:24:20 -0000 1.2 *************** *** 44,47 **** --- 44,72 ---- Assert.IsTrue( v2==null ); } + + [Test] + public void Int32IComparableTest() + { + NullableInt32 x; + NullableInt32 y; + + //one null, one not + x = NullableInt32.Default; + y = new NullableInt32(16); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + + //now both null + x = NullableInt32.Default; + y = NullableInt32.Default; + Assert.IsTrue(x.CompareTo(y) == 0); + Assert.IsTrue(y.CompareTo(x) == 0); + + //now both with a value + x = new NullableInt32(5); + y = new NullableInt32(43); + Assert.IsTrue(x.CompareTo(y) < 0); + Assert.IsTrue(y.CompareTo(x) > 0); + } } } |
From: Donald L M. Jr. <lu...@us...> - 2004-12-10 18:25:06
|
Update of /cvsroot/nhibernate/NHibernateContrib/src/Nullables.NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5667/src/Nullables.NHibernate Modified Files: NullablesTypes.cs Added Files: NullableSByteType.cs Log Message: Implemented IComparable. Added NullableSByte, but it is inactive until further investigation. --- NEW FILE: NullableSByteType.cs --- using System; using NHibernate.Type; using NHibernate.SqlTypes; using Nullables; //Contributed by Sergey Koshcheyev namespace Nullables.NHibernate { public class NullableSByteType : NullableTypesType { public NullableSByteType() : base(new Int16SqlType()) { } public override bool Equals(object x, object y) { //get boxed values. NullableSByte xTyped = (NullableSByte)x; return xTyped.Equals(y); } public override object NullValue { get { return NullableSByte.Default; } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "NullableSByte"; } } public override System.Type ReturnedClass { get { return typeof(Nullables.NullableSByte); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableSByte has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return NullableSByte.Default; } else { return new NullableSByte((SByte)value); } } public override object Get(System.Data.IDataReader rs, string name) { //TODO: perhaps NullableSByte has a method/operator/contructor that will take an object. object value = rs[name]; if( value==DBNull.Value ) { return NullableSByte.Default; } else { return new NullableSByte((SByte)value); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; NullableSByte nullableValue = (NullableSByte)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToXML(object val) { return val.ToString(); } } } Index: NullablesTypes.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables.NHibernate/NullablesTypes.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NullablesTypes.cs 12 Nov 2004 22:08:26 -0000 1.1 --- NullablesTypes.cs 10 Dec 2004 18:24:19 -0000 1.2 *************** *** 49,52 **** --- 49,57 ---- /// </summary> public static readonly NullableType NullableDateTime = new NullableDateTimeType(); + + // /// <summary> + // /// Nullables.NHibernate.NullableSByte type + // /// </summary> + // public static readonly NullableType NullableSByte = new NullableSByteType(); /// <summary> |
From: Donald L M. Jr. <lu...@us...> - 2004-12-10 18:24:39
|
Update of /cvsroot/nhibernate/NHibernateContrib/src/Nullables/TypeConverters In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5667/src/Nullables/TypeConverters Added Files: NullableSByteConverter.cs Log Message: Implemented IComparable. Added NullableSByte, but it is inactive until further investigation. --- NEW FILE: NullableSByteConverter.cs --- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; //Contributed by Sergey Koshcheyev namespace Nullables.TypeConverters { public class NullableSByteConverter : TypeConverter { public NullableSByteConverter() { } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) return true; else return base.CanConvertFrom (context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) return true; else return base.CanConvertTo (context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value == null) { return NullableSByte.Default; } if (value is string) { string stringValue = ((string)value).Trim(); if (stringValue == string.Empty) return NullableSByte.Default; //get underlying types converter TypeConverter converter = TypeDescriptor.GetConverter(typeof(SByte)); SByte newValue = (SByte)converter.ConvertFromString(context, culture, stringValue); return new NullableSByte(newValue); } else { return base.ConvertFrom (context, culture, value); } } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor) && value is NullableSByte) { NullableSByte nullable = (NullableSByte)value; Type[] constructorArgTypes = new Type[1] { typeof(SByte) } ; ConstructorInfo constructor = typeof(NullableSByte).GetConstructor(constructorArgTypes); if (constructor != null) { object[] constructorArgValues = new object[1] { nullable.Value } ; return new InstanceDescriptor(constructor, constructorArgValues); } } return base.ConvertTo (context, culture, value, destinationType); } public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { return new NullableSByte((SByte)propertyValues["Value"]); } public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return true; } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { return TypeDescriptor.GetProperties(typeof(NullableSByte), attributes); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } } } |
From: Michael D. <mik...@us...> - 2004-12-10 16:40:43
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14749/NHibernate Modified Files: nhibernate-mapping-2.0.xsd Log Message: NH-131: Describe joined-subclasses and subclasses in seperate files. Also refactored the test a little bit. Going to being moving away from the NHibernate.DomainModel and just include everything in the TestFixture. Making the domain classes smaller and easier to demonstrate the conepts. Borrowed some of the ideas from hibernate 3 Index: nhibernate-mapping-2.0.xsd =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/nhibernate-mapping-2.0.xsd,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** nhibernate-mapping-2.0.xsd 27 Nov 2004 19:00:27 -0000 1.7 --- nhibernate-mapping-2.0.xsd 10 Dec 2004 16:40:01 -0000 1.8 *************** *** 10,14 **** <xs:element ref='meta' minOccurs='0' maxOccurs='unbounded' /> <xs:element ref='import' minOccurs='0' maxOccurs='unbounded' /> ! <xs:element ref='class' minOccurs='0' maxOccurs='unbounded' /> <xs:element ref='query' minOccurs='0' maxOccurs='unbounded' /> </xs:sequence> --- 10,18 ---- <xs:element ref='meta' minOccurs='0' maxOccurs='unbounded' /> <xs:element ref='import' minOccurs='0' maxOccurs='unbounded' /> ! <xs:choice minOccurs='0' maxOccurs='unbounded'> ! <xs:element ref='class'/> ! <xs:element ref='subclass'/> ! <xs:element ref='joined-subclass'/> ! </xs:choice> <xs:element ref='query' minOccurs='0' maxOccurs='unbounded' /> </xs:sequence> *************** *** 322,325 **** --- 326,331 ---- </xs:simpleType> </xs:attribute> + <xs:attribute name='extends' use='optional'> + </xs:attribute> </xs:complexType> </xs:element> *************** *** 378,381 **** --- 384,389 ---- </xs:simpleType> </xs:attribute> + <xs:attribute name='extends' use='optional'> + </xs:attribute> </xs:complexType> </xs:element> |
From: Michael D. <mik...@us...> - 2004-12-10 16:40:15
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14749/NHibernate.DomainModel Modified Files: NHibernate.DomainModel-1.1.csproj Log Message: NH-131: Describe joined-subclasses and subclasses in seperate files. Also refactored the test a little bit. Going to being moving away from the NHibernate.DomainModel and just include everything in the TestFixture. Making the domain classes smaller and easier to demonstrate the conepts. Borrowed some of the ideas from hibernate 3 Index: NHibernate.DomainModel-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/NHibernate.DomainModel-1.1.csproj,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** NHibernate.DomainModel-1.1.csproj 18 Nov 2004 02:45:43 -0000 1.26 --- NHibernate.DomainModel-1.1.csproj 10 Dec 2004 16:40:01 -0000 1.27 *************** *** 713,730 **** /> <File - RelPath = "NHSpecific\JoinedSubclass.hbm.xml" - BuildAction = "EmbeddedResource" - /> - <File - RelPath = "NHSpecific\JoinedSubclassBase.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File - RelPath = "NHSpecific\JoinedSubclassOne.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File RelPath = "NHSpecific\Node.cs" SubType = "Code" --- 713,716 ---- *************** *** 773,780 **** /> <File - RelPath = "NHSpecific\Subclass.hbm.xml" - BuildAction = "EmbeddedResource" - /> - <File RelPath = "NHSpecific\Team.cs" SubType = "Code" --- 759,762 ---- |
From: Michael D. <mik...@us...> - 2004-12-10 16:40:15
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14749/NHibernate.Test Modified Files: NHibernate.Test-1.1.csproj NHibernate.Test.build ObjectAssertion.cs TestCase.cs Log Message: NH-131: Describe joined-subclasses and subclasses in seperate files. Also refactored the test a little bit. Going to being moving away from the NHibernate.DomainModel and just include everything in the TestFixture. Making the domain classes smaller and easier to demonstrate the conepts. Borrowed some of the ideas from hibernate 3 Index: NHibernate.Test.build =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHibernate.Test.build,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** NHibernate.Test.build 8 Dec 2004 15:30:55 -0000 1.12 --- NHibernate.Test.build 10 Dec 2004 16:40:02 -0000 1.13 *************** *** 60,64 **** <resources prefix="NHibernate.Test" dynamicprefix="true"> ! <includes name="hibernate.cfg.xml" /> </resources> --- 60,65 ---- <resources prefix="NHibernate.Test" dynamicprefix="true"> ! <includes name="**/*.xml" /> ! <excludes name="bin/**/*.xml" /> </resources> Index: TestCase.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TestCase.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TestCase.cs 7 Jun 2004 20:35:44 -0000 1.12 --- TestCase.cs 10 Dec 2004 16:40:02 -0000 1.13 *************** *** 1,8 **** using System; ! using System.Reflection; using System.Data; ! using System.Data.SqlClient; using NHibernate.DomainModel; using NHibernate.Cfg; using NHibernate.Dialect; --- 1,9 ---- using System; ! using System.Collections; using System.Data; ! using System.Reflection; using NHibernate.DomainModel; + using NHibernate.Cfg; using NHibernate.Dialect; *************** *** 35,50 **** } ! public void ExportSchema(string[] files) { ExportSchema(files, true); } ! public void ExportSchema(string[] files, bool exportSchema) { cfg = new Configuration(); ! for (int i=0; i<files.Length; i++) { ! cfg.AddResource("NHibernate.DomainModel." + files[i], Assembly.Load("NHibernate.DomainModel")); } --- 36,56 ---- } ! public void ExportSchema(IList files) { ExportSchema(files, true); } ! public void ExportSchema(IList files, bool exportSchema) ! { ! ExportSchema( files, exportSchema, "NHibernate.DomainModel" ); ! } ! ! public void ExportSchema(IList files, bool exportSchema, string assemblyName) { cfg = new Configuration(); ! for (int i=0; i<files.Count; i++) { ! cfg.AddResource( assemblyName + "." + files[i].ToString(), Assembly.Load( assemblyName ) ); } Index: NHibernate.Test-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHibernate.Test-1.1.csproj,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** NHibernate.Test-1.1.csproj 21 Nov 2004 22:54:56 -0000 1.51 --- NHibernate.Test-1.1.csproj 10 Dec 2004 16:40:02 -0000 1.52 *************** *** 311,314 **** --- 311,360 ---- /> <File + RelPath = "JoinedSubclass\Address.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "JoinedSubclass\Customer.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "JoinedSubclass\Employee.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "JoinedSubclass\JoinedSubclass.Customer.hbm.xml" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "JoinedSubclass\JoinedSubclass.Employee.hbm.xml" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "JoinedSubclass\JoinedSubclass.hbm.xml" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "JoinedSubclass\JoinedSubclass.Person.hbm.xml" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "JoinedSubclass\JoinedSubclassExtendsFixture.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "JoinedSubclass\JoinedSubclassFixture.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "JoinedSubclass\Person.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "MappingTest\TableFixture.cs" SubType = "Code" *************** *** 356,364 **** /> <File - RelPath = "NHSpecificTest\JoinedSubclassFixture.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File RelPath = "NHSpecificTest\MapFixture.cs" SubType = "Code" --- 402,405 ---- *************** *** 381,389 **** /> <File - RelPath = "NHSpecificTest\SubclassFixture.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File RelPath = "NHSpecificTest\UnsavedValueFixture.cs" SubType = "Code" --- 422,425 ---- *************** *** 501,504 **** --- 537,577 ---- /> <File + RelPath = "Subclass\Subclass.Base.hbm.xml" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "Subclass\Subclass.hbm.xml" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "Subclass\Subclass.One.hbm.xml" + BuildAction = "EmbeddedResource" + /> + <File + RelPath = "Subclass\SubclassAssert.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Subclass\SubclassBase.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Subclass\SubclassExtendsFixture.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Subclass\SubclassFixture.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Subclass\SubclassOne.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TypesTest\BaseTypeFixture.cs" SubType = "Code" Index: ObjectAssertion.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ObjectAssertion.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ObjectAssertion.cs 18 Nov 2004 02:46:59 -0000 1.6 --- ObjectAssertion.cs 10 Dec 2004 16:40:02 -0000 1.7 *************** *** 3,6 **** --- 3,7 ---- using NUnit.Framework; + using NHibernate.DomainModel; using NHibernate.DomainModel.NHSpecific; *************** *** 18,35 **** } - internal static void AssertPropertiesEqual(JoinedSubclassBase expected, JoinedSubclassBase actual) - { - Assert.AreEqual(expected.Id, actual.Id); - Assert.AreEqual(expected.TestDateTime, actual.TestDateTime); - Assert.AreEqual(expected.TestLong, actual.TestLong); - Assert.AreEqual(expected.TestString, actual.TestString); - } - - internal static void AssertPropertiesEqual(JoinedSubclassOne expected, JoinedSubclassOne actual) - { - ObjectAssert.AssertPropertiesEqual((JoinedSubclassBase)expected, (JoinedSubclassBase)actual); - Assert.AreEqual(expected.OneTestLong, actual.OneTestLong); - } - internal static void AssertEquals(Iesi.Collections.ISet expected, Iesi.Collections.ISet actual) { --- 19,22 ---- |
From: Michael D. <mik...@us...> - 2004-12-10 16:40:14
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14749/NHibernate/Cfg Modified Files: Binder.cs Log Message: NH-131: Describe joined-subclasses and subclasses in seperate files. Also refactored the test a little bit. Going to being moving away from the NHibernate.DomainModel and just include everything in the TestFixture. Making the domain classes smaller and easier to demonstrate the conepts. Borrowed some of the ideas from hibernate 3 Index: Binder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Binder.cs,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Binder.cs 29 Oct 2004 05:58:06 -0000 1.33 --- Binder.cs 10 Dec 2004 16:40:04 -0000 1.34 *************** *** 966,980 **** else if ( "subclass".Equals(name) ) { ! Subclass subclass = new Subclass(model); ! BindSubclass( subnode, subclass, mappings ); ! model.AddSubclass(subclass); ! mappings.AddClass(subclass); } else if ( "joined-subclass".Equals(name) ) { ! Subclass subclass = new Subclass(model); ! BindJoinedSubclass( subnode, subclass, mappings); ! model.AddSubclass(subclass); ! mappings.AddClass(subclass); } if ( value!=null) --- 966,974 ---- else if ( "subclass".Equals(name) ) { ! HandleSubclass( model, mappings, subnode ); } else if ( "joined-subclass".Equals(name) ) { ! HandleJoinedSubclass( model, mappings, subnode ); } if ( value!=null) *************** *** 1059,1063 **** } else if ( "index-many-to-any".Equals(name) ) ! { Any any = new Any( model.Table ); BindAny( subnode, any, model.IsOneToMany ); model.Index = any; } } if ( !model.IsInverse ) model.Index.CreateForeignKey(); --- 1053,1061 ---- } else if ( "index-many-to-any".Equals(name) ) ! { ! Any any = new Any( model.Table ); ! BindAny( subnode, any, model.IsOneToMany ); ! model.Index = any; ! } } if ( !model.IsInverse ) model.Index.CreateForeignKey(); *************** *** 1131,1135 **** } else if ( "many-to-any".Equals(name) ) ! { Any element = new Any( model.Table ); model.Element = element; BindAny(subnode, element, true); } else if ( "jcs-cache".Equals(name) ) { --- 1129,1137 ---- } else if ( "many-to-any".Equals(name) ) ! { ! Any element = new Any( model.Table ); ! model.Element = element; ! BindAny(subnode, element, true); ! } else if ( "jcs-cache".Equals(name) ) { *************** *** 1181,1184 **** --- 1183,1198 ---- } + foreach(XmlNode n in hmNode.SelectNodes(nsPrefix + ":subclass", nsmgr) ) + { + PersistentClass superModel = GetSuperclass(model, n); + HandleSubclass(superModel, model, n); + } + + foreach(XmlNode n in hmNode.SelectNodes(nsPrefix + ":joined-subclass", nsmgr) ) + { + PersistentClass superModel = GetSuperclass(model, n); + HandleJoinedSubclass(superModel, model, n); + } + foreach(XmlNode n in hmNode.SelectNodes(nsPrefix + ":query", nsmgr) ) { *************** *** 1209,1212 **** --- 1223,1266 ---- } + private static void HandleJoinedSubclass( PersistentClass model, Mappings mappings, XmlNode subnode ) + { + Subclass subclass = new Subclass( model ); + BindJoinedSubclass( subnode, subclass, mappings ); + model.AddSubclass( subclass ); + mappings.AddClass( subclass ); + } + + private static void HandleSubclass( PersistentClass model, Mappings mappings, XmlNode subnode ) + { + Subclass subclass = new Subclass( model ); + BindSubclass( subnode, subclass, mappings ); + model.AddSubclass( subclass ); + mappings.AddClass( subclass ); + } + + private static PersistentClass GetSuperclass( Mappings model, XmlNode subnode ) + { + XmlAttribute extendsAttr = subnode.Attributes["extends"]; + if( extendsAttr == null ) + throw new MappingException( "'extends' attribute is not found." ); + String extendsValue = extendsAttr.Value; + System.Type superclass; + try + { + superclass = ReflectHelper.ClassForName( extendsValue ); + } + catch( Exception e ) + { + throw new MappingException( "extended class not found: " + extendsValue, e ); + } + PersistentClass superModel = model.GetClass( superclass ); + + if( superModel == null ) + { + throw new MappingException( "Cannot extend unmapped class: " + extendsValue ); + } + return superModel; + } + public abstract class SecondPass { |
From: Michael D. <mik...@us...> - 2004-12-10 16:40:13
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14749/NHibernate.Test/NHSpecificTest Removed Files: JoinedSubclassFixture.cs SubclassFixture.cs Log Message: NH-131: Describe joined-subclasses and subclasses in seperate files. Also refactored the test a little bit. Going to being moving away from the NHibernate.DomainModel and just include everything in the TestFixture. Making the domain classes smaller and easier to demonstrate the conepts. Borrowed some of the ideas from hibernate 3 --- SubclassFixture.cs DELETED --- --- JoinedSubclassFixture.cs DELETED --- |
From: Michael D. <mik...@us...> - 2004-12-10 16:40:13
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/Subclass In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14749/NHibernate.Test/Subclass Added Files: Subclass.Base.hbm.xml Subclass.hbm.xml Subclass.One.hbm.xml SubclassAssert.cs SubclassBase.cs SubclassExtendsFixture.cs SubclassFixture.cs SubclassOne.cs Log Message: NH-131: Describe joined-subclasses and subclasses in seperate files. Also refactored the test a little bit. Going to being moving away from the NHibernate.DomainModel and just include everything in the TestFixture. Making the domain classes smaller and easier to demonstrate the conepts. Borrowed some of the ideas from hibernate 3 --- NEW FILE: SubclassOne.cs --- using System; namespace NHibernate.Test.Subclass { /// <summary> /// Summary description for JoinedSubclassOne. /// </summary> public class SubclassOne: SubclassBase { private long _oneTestLong; public SubclassOne() {} public long OneTestLong { get {return _oneTestLong;} set {_oneTestLong = value;} } } } --- NEW FILE: SubclassFixture.cs --- using System; using System.Collections; using NUnit.Framework; namespace NHibernate.Test.Subclass { /// <summary> /// Test the use of <c><class></c> and <c><subclass></c> mappings. /// </summary> [TestFixture] public class SubclassFixture : TestCase { private DateTime testDateTime = new DateTime(2003, 8, 16); private DateTime updateDateTime = new DateTime(2003, 8, 17); [SetUp] public virtual void SetUp() { ExportSchema( new string[] { "Subclass.Subclass.hbm.xml" }, true, "NHibernate.Test" ); } [Test] public void TestCRUD() { // test the Save ISession s1 = sessions.OpenSession(); ITransaction t1 = s1.BeginTransaction(); int oneId; int baseId; SubclassOne one1 = new SubclassOne(); one1.TestDateTime = new System.DateTime(2003, 10, 17); one1.TestString = "the test one string"; one1.TestLong = 6; one1.OneTestLong = 1; oneId = (int)s1.Save(one1); SubclassBase base1 = new SubclassBase(); base1.TestDateTime = new System.DateTime(2003, 10, 17); base1.TestString = "the test string"; base1.TestLong = 5; baseId = (int)s1.Save(base1); t1.Commit(); s1.Close(); // lets verify the correct classes were saved ISession s2 = sessions.OpenSession(); ITransaction t2 = s2.BeginTransaction(); // perform a load based on the base class SubclassBase base2 = (SubclassBase)s2.Load(typeof(SubclassBase), baseId); SubclassBase oneBase2 = (SubclassBase)s2.Load(typeof(SubclassBase), oneId); // do some quick checks to make sure s2 loaded an object with the same data as s2 saved. SubclassAssert.AreEqual(base1, base2); // the object with id=2 was loaded using the base class - lets make sure it actually loaded // the sublcass SubclassOne one2 = oneBase2 as SubclassOne; Assert.IsNotNull(one2); // lets update the objects base2.TestString = "Did it get updated"; // update the properties from the subclass and base class one2.TestString = "Updated SubclassOne String"; one2.OneTestLong = 21; // save it through the base class reference and make sure that the // subclass properties get updated. s2.Update(base2); s2.Update(oneBase2); t2.Commit(); s2.Close(); // lets test the Criteria interface for subclassing ISession s3 = sessions.OpenSession(); ITransaction t3 = s3.BeginTransaction(); IList results3 = s3.CreateCriteria(typeof(SubclassBase)) .Add(Expression.Expression.In("TestString", new string[] {"Did it get updated", "Updated SubclassOne String" })) .List(); Assert.AreEqual(2, results3.Count); SubclassBase base3 = null; SubclassOne one3 = null; foreach(SubclassBase obj in results3) { if(obj is SubclassOne) one3 = (SubclassOne)obj; else base3 = obj; } // verify the properties got updated SubclassAssert.AreEqual(base2, base3); SubclassAssert.AreEqual(one2, one3); s3.Delete(base3); s3.Delete(one3); t3.Commit(); s3.Close(); } [Test] public void HqlClassKeyword() { // test the Save ISession s = sessions.OpenSession(); ITransaction t = s.BeginTransaction(); int oneId; int baseId; SubclassOne one1 = new SubclassOne(); one1.TestDateTime = new System.DateTime(2003, 10, 17); one1.TestString = "the test one string"; one1.TestLong = 6; one1.OneTestLong = 1; oneId = (int)s.Save(one1); SubclassBase base1 = new SubclassBase(); base1.TestDateTime = new System.DateTime(2003, 10, 17); base1.TestString = "the test string"; base1.TestLong = 5; baseId = (int)s.Save(base1); t.Commit(); s.Close(); s = sessions.OpenSession(); IList list = s.Find( "from SubclassBase as sb where sb.class=SubclassBase" ); Assert.AreEqual( 1, list.Count ); Assert.AreEqual( typeof(SubclassBase), list[0].GetType(), "should be base" ); list = s.Find( "from SubclassBase as sb where sb.class=SubclassOne" ); Assert.AreEqual( 1, list.Count ); Assert.AreEqual( typeof(SubclassOne), list[0].GetType(), "should be one" ); s.Close(); } } } --- NEW FILE: Subclass.One.hbm.xml --- <?xml version="1.0" encoding="utf-8" ?> <!-- This is the a mapping for the subclass where it is mapped in different hbm.xml file through the use of the "extends" attribute. The order the hbm.xml files are added to nhibernate are important. The base class must be added first and then the subclass can be added. It is used by the SubclassExtendsFixture. --> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"> <subclass extends="NHibernate.Test.Subclass.SubclassBase, NHibernate.Test" name="NHibernate.Test.Subclass.SubclassOne, NHibernate.Test" discriminator-value="SUB" > <property name="OneTestLong" column="one_test_long" type="Int64" /> </subclass> </hibernate-mapping> --- NEW FILE: Subclass.hbm.xml --- <?xml version="1.0"?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"> <class name="NHibernate.Test.Subclass.SubclassBase, NHibernate.Test" table="one_tab" discriminator-value="SUPER" > <id name="Id" type="Int32" unsaved-value="0" column="class_id" access="nosetter.camelcase-underscore" > <generator class="native" /> </id> <discriminator column="disc_column" type="String" /> <property name="TestLong" column="test_long" type="Int64" /> <property name="TestString" column="test_string" type="String" /> <property name="TestDateTime" column="test_date_time" type="DateTime" /> <subclass name="NHibernate.Test.Subclass.SubclassOne, NHibernate.Test" discriminator-value="SUB" > <property name="OneTestLong" column="one_test_long" type="Int64" /> </subclass> </class> </hibernate-mapping> --- NEW FILE: SubclassAssert.cs --- using System; using NUnit.Framework; namespace NHibernate.Test.Subclass { /// <summary> /// Summary description for SubclassAssert. /// </summary> public sealed class SubclassAssert { private SubclassAssert() {} internal static void AreEqual(SubclassBase expected, SubclassBase actual) { Assert.AreEqual( expected.Id, actual.Id ); Assert.AreEqual( expected.TestDateTime, actual.TestDateTime ); Assert.AreEqual( expected.TestLong, actual.TestLong ); Assert.AreEqual( expected.TestString, actual.TestString ); } internal static void AreEqual(SubclassOne expected, SubclassOne actual) { AreEqual( (SubclassBase)expected, (SubclassBase)actual ); Assert.AreEqual( expected.OneTestLong, actual.OneTestLong ); } } } --- NEW FILE: SubclassExtendsFixture.cs --- using System; using System.Collections; using NUnit.Framework; namespace NHibernate.Test.Subclass { /// <summary> /// Test the use of <c><class></c> and <c><subclass></c> mappings /// that are in different files through the use of the <c>extends</c> attribute. /// </summary> /// <remarks> /// Inheriting from <see cref="SubclassFixture"/> because the only thing different /// is how the classes are mapped. /// </remarks> [TestFixture] public class SubclassExtendsFixture : SubclassFixture { [SetUp] public override void SetUp() { // order is important! The base classes must be configured before // the subclasses. ArrayList files = new ArrayList(); files.Add( "Subclass.Subclass.Base.hbm.xml" ); files.Add( "Subclass.Subclass.One.hbm.xml" ); ExportSchema( files, true, "NHibernate.Test" ); } } } --- NEW FILE: SubclassBase.cs --- using System; namespace NHibernate.Test.Subclass { /// <summary> /// Summary description for SubclassBase. /// </summary> public class SubclassBase { private int _id = 0; private long _testLong; private string _testString; private System.DateTime _testDate; public SubclassBase() { } public int Id { get { return _id; } } public long TestLong { get { return _testLong; } set { _testLong = value; } } public string TestString { get { return _testString; } set { _testString = value; } } public System.DateTime TestDateTime { get { return _testDate; } set { _testDate = value; } } } } --- NEW FILE: Subclass.Base.hbm.xml --- (This appears to be a binary file; contents omitted.) |
From: Michael D. <mik...@us...> - 2004-12-10 16:40:13
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/JoinedSubclass In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14749/NHibernate.Test/JoinedSubclass Added Files: Address.cs Customer.cs Employee.cs JoinedSubclass.Customer.hbm.xml JoinedSubclass.Employee.hbm.xml JoinedSubclass.hbm.xml JoinedSubclass.Person.hbm.xml JoinedSubclassExtendsFixture.cs JoinedSubclassFixture.cs Person.cs Log Message: NH-131: Describe joined-subclasses and subclasses in seperate files. Also refactored the test a little bit. Going to being moving away from the NHibernate.DomainModel and just include everything in the TestFixture. Making the domain classes smaller and easier to demonstrate the conepts. Borrowed some of the ideas from hibernate 3 --- NEW FILE: Employee.cs --- using System; namespace NHibernate.Test.JoinedSubclass { /// <summary> /// Summary description for Employee. /// </summary> public class Employee: Person { private string _title; private Decimal _salary; private Employee _manager; public Employee() {} public string Title { get { return _title; } set { _title = value; } } public Decimal Salary { get { return _salary; } set { _salary = value; } } public Employee Manager { get { return _manager; } set { _manager = value; } } } } --- NEW FILE: JoinedSubclass.hbm.xml --- <?xml version="1.0"?> <!-- This mapping demonstrates (1) a table-per-subclass mapping strategy (2) a simple component mapping (3) recursive associations withing an inheritance tree --> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"> <class name="NHibernate.Test.JoinedSubclass.Person, NHibernate.Test" table="person" > <id name="Id" type="Int32" unsaved-value="0" column="person_id" access="nosetter.camelcase-underscore" > <generator class="native" /> </id> <property name="Name" column="name" /> <property name="Sex" column="sex" /> <component name="Address"> <property name="Street"/> <property name="Zip"/> <property name="Country"/> </component> <joined-subclass name="NHibernate.Test.JoinedSubclass.Employee, NHibernate.Test" table="empl" > <key column="person_id"/> <property name="Title" not-null="true" length="20"/> <property name="Salary" length="0"/> <many-to-one name="Manager"/> </joined-subclass> <joined-subclass name="NHibernate.Test.JoinedSubclass.Customer, NHibernate.Test" table="cust" > <key column="person_id"/> <property name="Comments"/> <many-to-one name="Salesperson"/> </joined-subclass> </class> </hibernate-mapping> --- NEW FILE: JoinedSubclassFixture.cs --- using System; using System.Collections; using NUnit.Framework; namespace NHibernate.Test.JoinedSubclass { /// <summary> /// Test the use of <c><class></c> and <c><joined-subclass></c> mappings. /// </summary> [TestFixture] public class JoinedSubclassFixture : TestCase { private DateTime testDateTime = new DateTime(2003, 8, 16); private DateTime updateDateTime = new DateTime(2003, 8, 17); [SetUp] public virtual void SetUp() { ExportSchema( new string[] { "JoinedSubclass.JoinedSubclass.hbm.xml" }, true, "NHibernate.Test" ); } [Test] public void TestJoinedSubclass() { ISession s = sessions.OpenSession(); Employee mark = new Employee(); mark.Name = "Mark"; mark.Title = "internal sales"; mark.Sex = 'M'; mark.Address.Street = "buckhead"; mark.Address.Zip = "30305"; mark.Address.Country = "USA"; Customer joe = new Customer(); joe.Name = "Joe"; joe.Address.Street = "San Francisco"; joe.Address.Zip = "54353"; joe.Address.Country = "USA"; joe.Comments = "very demanding"; joe.Sex = 'M'; joe.Salesperson = mark; Person mom = new Person(); mom.Name = "mom"; mom.Sex = 'F'; s.Save( mom ); s.Save( mark ); s.Save( joe ); s.Flush(); Assert.AreEqual( 3, s.CreateQuery( "from Person" ).List().Count ); IQuery query = s.CreateQuery( "from Customer" ); IList results = query.List(); Assert.AreEqual( 1, results.Count ); Assert.IsTrue( results[0] is Customer, "should be a customer" ); // in later versions of hibernate a Clear method was added to session s.Close(); s = sessions.OpenSession(); IList customers = s.CreateQuery( "from Customer c left join fetch c.Salesperson" ).List(); foreach( Customer c in customers ) { // when proxies is working this is important Assert.IsTrue( NHibernate.IsInitialized( c.Salesperson ) ); Assert.AreEqual( "Mark", c.Salesperson.Name ); } Assert.AreEqual( 1, customers.Count ); s.Close(); s = sessions.OpenSession(); customers = s.CreateQuery( "from Customer" ).List(); foreach( Customer c in customers ) { //TODO: proxies make this work // Assert.IsFalse( NHibernate.IsInitialized( c.Salesperson ) ); Assert.AreEqual( "Mark", c.Salesperson.Name ); } Assert.AreEqual( 1, customers.Count ); s.Close(); s = sessions.OpenSession(); mark = (Employee)s.Load( typeof(Employee), mark.Id ); joe = (Customer)s.Load( typeof(Customer), joe.Id ); mark.Address.Zip = "30306" ; Assert.AreEqual( 1, s.CreateQuery( "from Person p where p.Address.Zip = '30306'" ).List().Count ); s.Delete( mom ); s.Delete( joe ); s.Delete( mark ); Assert.AreEqual( 0, s.CreateQuery( "from Person" ).List().Count ); s.Close(); } /// <summary> /// Test the ability to insert a new row with a User Assigned Key /// Right now - the only way to verify this is to watch SQL Profiler /// </summary> [Test] public void TestCRUD() { // test the Save ISession s = sessions.OpenSession(); ITransaction t = s.BeginTransaction(); Employee emp = new Employee(); emp.Name = "test one"; emp.Title = "office clown"; s.Save(emp); Person person = new Person(); person.Name = "the test string"; s.Save(person); t.Commit(); s.Close(); int empId = emp.Id; int personId = person.Id; // lets verify the correct classes were saved s = sessions.OpenSession(); t = s.BeginTransaction(); // perform a load based on the base class Person empAsPerson = (Person)s.Load( typeof(Person), empId ); person = (Person)s.Load( typeof(Person), personId ); // the object with id=2 was loaded using the base class - lets make sure it actually loaded // the sublcass emp = empAsPerson as Employee; Assert.IsNotNull(emp); // lets update the objects person.Name = "Did it get updated"; person.Sex = 'M'; // update the properties from the subclass and base class emp.Name = "Updated Employee String"; emp.Title = "office dunce"; // save it through the base class reference and make sure that the // subclass properties get updated. s.Update( empAsPerson ); s.Update( person ); t.Commit(); s.Close(); // lets test the Criteria interface for subclassing s = sessions.OpenSession(); t = s.BeginTransaction(); IList results = s.CreateCriteria( typeof(Person) ) .Add(Expression.Expression.In( "Name", new string[] {"Did it get updated", "Updated Employee String" })) .List(); Assert.AreEqual( 2, results.Count); person = null; emp = null; foreach(Person obj in results) { if(obj is Employee) emp = (Employee)obj; else person = obj; } // verify the properties got updated Assert.AreEqual( 'M', person.Sex ); Assert.AreEqual( "office dunce", emp.Title ); s.Delete( emp ); s.Delete( person ); t.Commit(); s.Close(); } } } --- NEW FILE: JoinedSubclassExtendsFixture.cs --- using System; using System.Collections; using NUnit.Framework; namespace NHibernate.Test.JoinedSubclass { /// <summary> /// Test the use of <c><class></c> and <c><joined-subclass></c> mappings /// that are in different files through the use of the <c>extends</c> attribute. /// </summary> /// <remarks> /// Inheriting from <see cref="JoinedSubclassFixture"/> because the only thing different /// is how the classes are mapped. /// </remarks> [TestFixture] public class JoinedSubclassExtendsFixture : JoinedSubclassFixture { [SetUp] public override void SetUp() { // order is important! The base classes must be configured before // the subclasses. ArrayList files = new ArrayList(); files.Add( "JoinedSubclass.JoinedSubclass.Person.hbm.xml" ); files.Add( "JoinedSubclass.JoinedSubclass.Employee.hbm.xml" ); files.Add( "JoinedSubclass.JoinedSubclass.Customer.hbm.xml" ); ExportSchema( files, true, "NHibernate.Test" ); } } } --- NEW FILE: JoinedSubclass.Employee.hbm.xml --- (This appears to be a binary file; contents omitted.) --- NEW FILE: Customer.cs --- using System; namespace NHibernate.Test.JoinedSubclass { /// <summary> /// Summary description for Customer. /// </summary> public class Customer : Person { private Employee _salesperson; private string _comments; public Customer() { } public Employee Salesperson { get { return _salesperson; } set { _salesperson = value; } } public string Comments { get { return _comments; } set { _comments = value; } } } } --- NEW FILE: JoinedSubclass.Customer.hbm.xml --- (This appears to be a binary file; contents omitted.) --- NEW FILE: JoinedSubclass.Person.hbm.xml --- (This appears to be a binary file; contents omitted.) --- NEW FILE: Person.cs --- using System; namespace NHibernate.Test.JoinedSubclass { /// <summary> /// Summary description for Person. /// </summary> public class Person { private int _id = 0; private string _name; private char _sex; private Address _address = new Address(); public Person() { } public int Id { get { return _id; } } public string Name { get { return _name; } set { _name = value; } } public char Sex { get { return _sex; } set { _sex = value; } } public Address Address { get { return _address; } set { _address = value; } } } } --- NEW FILE: Address.cs --- using System; namespace NHibernate.Test.JoinedSubclass { /// <summary> /// An Address that is used as a <c>component</c>. /// </summary> public class Address { private string _street; private string _zip; private string _country; public Address() { } public string Street { get { return _street; } set { _street = value; } } public string Zip { get { return _zip; } set { _zip = value; } } public string Country { get { return _country; } set { _country = value; } } } } |
From: Michael D. <mik...@us...> - 2004-12-10 16:40:11
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/NHSpecific In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14749/NHibernate.DomainModel/NHSpecific Removed Files: JoinedSubclass.hbm.xml JoinedSubclassBase.cs JoinedSubclassOne.cs Subclass.hbm.xml Log Message: NH-131: Describe joined-subclasses and subclasses in seperate files. Also refactored the test a little bit. Going to being moving away from the NHibernate.DomainModel and just include everything in the TestFixture. Making the domain classes smaller and easier to demonstrate the conepts. Borrowed some of the ideas from hibernate 3 --- JoinedSubclass.hbm.xml DELETED --- --- JoinedSubclassOne.cs DELETED --- --- Subclass.hbm.xml DELETED --- --- JoinedSubclassBase.cs DELETED --- |
From: Michael D. <mik...@us...> - 2004-12-10 16:31:45
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/Subclass In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13251/Subclass Log Message: Directory /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/Subclass added to the repository |
From: Michael D. <mik...@us...> - 2004-12-10 16:31:10
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/JoinedSubclass In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13071/JoinedSubclass Log Message: Directory /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/JoinedSubclass added to the repository |
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20391/NHibernate/Impl Modified Files: ScheduledCollectionAction.cs ScheduledEntityAction.cs SessionImpl.cs Added Files: CollectionEntry.cs EntityEntry.cs IExecutable.cs Status.cs Log Message: Moved some nested classes out from SessionImpl into their own class. Index: SessionImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionImpl.cs,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** SessionImpl.cs 9 Dec 2004 17:52:15 -0000 1.55 --- SessionImpl.cs 9 Dec 2004 22:08:54 -0000 1.56 *************** *** 104,618 **** [NonSerialized] private IBatcher batcher; - /// <summary> - /// Represents the status of an entity with respect to - /// this session. These statuses are for internal - /// book-keeping only and are not intended to represent - /// any notion that is visible to the <b>application</b>. - /// </summary> - [Serializable] - internal enum Status - { - /// <summary> - /// The Entity is snapshotted in the Session with the same state as the database. - /// </summary> - Loaded, - - /// <summary> - /// The Entity is in the Session and has been marked for deletion but not - /// deleted from the database yet. - /// </summary> - Deleted, - - /// <summary> - /// The Entity has been deleted from database. - /// </summary> - Gone, - - /// <summary> - /// The Entity is in the process of being loaded. - /// </summary> - Loading, - - /// <summary> - /// The Entity is in the process of being saved. - /// </summary> - Saving - } - - /// <summary> - /// An action that <see cref="ISession"/> can Execute during a - /// <c>Flush</c>. - /// </summary> - internal interface IExecutable - { - /// <summary> - /// Execute the action required to write changes to the database. - /// </summary> - void Execute(); - - /// <summary> - /// Called after the Transaction has been completed. - /// </summary> - /// <remarks> - /// Actions should make sure that the Cache is notified about - /// what just happened. - /// </remarks> - void AfterTransactionCompletion(); - - /// <summary> - /// The spaces (tables) that are affectd by this Executable action. - /// </summary> - /// <remarks> - /// This is used to determine if the ISession needs to be flushed before - /// a query is executed so stale data is not returned. - /// </remarks> - object[] PropertySpaces { get; } - } - - /// <summary> - /// We need an entry to tell us all about the current state - /// of an object with respect to its persistent state - /// </summary> - [Serializable] - sealed internal class EntityEntry - { - private LockMode _lockMode; - private Status _status; - private object _id; - private object[] _loadedState; - private object[] _deletedState; - private bool _existsInDatabase; - private object _version; - // for convenience to save some lookups - [NonSerialized] private IClassPersister _persister; - private string _className; - - /// <summary> - /// Initializes a new instance of EntityEntry. - /// </summary> - /// <param name="status">The current <see cref="Status"/> of the Entity.</param> - /// <param name="loadedState">The snapshot of the Entity's state when it was loaded.</param> - /// <param name="id">The identifier of the Entity in the database.</param> - /// <param name="version">The version of the Entity.</param> - /// <param name="lockMode">The <see cref="LockMode"/> for the Entity.</param> - /// <param name="existsInDatabase">A boolean indicating if the Entity exists in the database.</param> - /// <param name="persister">The <see cref="IClassPersister"/> that is responsible for this Entity.</param> - public EntityEntry(Status status, object[] loadedState, object id, object version, LockMode lockMode, bool existsInDatabase, IClassPersister persister) - { - _status = status; - _loadedState = loadedState; - _id = id; - _existsInDatabase = existsInDatabase; - _version = version; - _lockMode = lockMode; - _persister = persister; - if (_persister!=null) _className = _persister.ClassName; - } - - /// <summary> - /// Gets or sets the current <see cref="LockMode"/> of the Entity. - /// </summary> - /// <value>The <see cref="LockMode"/> of the Entity.</value> - public LockMode LockMode - { - get { return _lockMode; } - set { _lockMode = value; } - } - - /// <summary> - /// Gets or sets the <see cref="Status"/> of this Entity with respect to its - /// persistence in the database. - /// </summary> - /// <value>The <see cref="Status"/> of this Entity.</value> - public Status Status - { - get { return _status; } - set { _status = value; } - } - - /// <summary> - /// Gets or sets the identifier of the Entity in the database. - /// </summary> - /// <value>The identifier of the Entity in the database if one has been assigned.</value> - /// <remarks>This might be <c>null</c> when the <see cref="EntityEntry.Status"/> is - /// <see cref="Status.Saving"/> and the database generates the id.</remarks> - public object Id - { - get { return _id; } - set { _id = value; } - } - - /// <summary> - /// Gets or sets the snapshot of the Entity when it was loaded from the database. - /// </summary> - /// <value>The snapshot of the Entity.</value> - /// <remarks> - /// There will only be a value when the Entity was loaded in the current Session. - /// </remarks> - public object[] LoadedState - { - get { return _loadedState; } - set { _loadedState = value; } - } - - /// <summary> - /// Gets or sets the snapshot of the Entity when it was marked as being ready for deletion. - /// </summary> - /// <value>The snapshot of the Entity.</value> - /// <remarks>This will be <c>null</c> if the Entity is not being deleted.</remarks> - public object[] DeletedState - { - get { return _deletedState; } - set { _deletedState = value; } - } - - /// <summary> - /// Gets or sets a <see cref="Boolean"/> indicating if this Entity exists in the database. - /// </summary> - /// <value><c>true</c> if it is already in the database.</value> - /// <remarks> - /// It can also be <c>true</c> if it does not exists in the database yet and the - /// <see cref="IClassPersister.IsIdentifierAssignedByInsert"/> is <c>true</c>. - /// </remarks> - public bool ExistsInDatabase - { - get { return _existsInDatabase; } - set { _existsInDatabase = value; } - } - - /// <summary> - /// Gets or sets the version of the Entity. - /// </summary> - /// <value>The version of the Entity.</value> - public object Version - { - get { return _version; } - set { _version = value; } - } - - /// <summary> - /// Gets or sets the <see cref="IClassPersister"/> that is responsible for this Entity. - /// </summary> - /// <value>The <see cref="IClassPersister"/> that is reponsible for this Entity.</value> - public IClassPersister Persister - { - get { return _persister; } - set { _persister = value; } - } - - /// <summary> - /// Gets the Fully Qualified Name of the class this Entity is an instance of. - /// </summary> - /// <value>The Fully Qualified Name of the class this Entity is an instance of.</value> - public string ClassName - { - get { return _className; } - } - - } - - - /// <summary> - /// We need an entry to tell us all about the current state - /// of a collection with respect to its persistent state - /// </summary> - [Serializable] - public class CollectionEntry : ICollectionSnapshot - { - internal bool dirty; - - /// <summary> - /// Indicates that the Collection can still be reached by an Entity - /// that exist in the <see cref="ISession"/>. - /// </summary> - /// <remarks> - /// It is also used to ensure that the Collection is not shared between - /// two Entities. - /// </remarks> - [NonSerialized] internal bool reached; - - /// <summary> - /// Indicates that the Collection has been processed and is ready - /// to have its state synchronized with the database. - /// </summary> - [NonSerialized] internal bool processed; - - /// <summary> - /// Indicates that a Collection needs to be updated. - /// </summary> - /// <remarks> - /// A Collection needs to be updated whenever the contents of the Collection - /// have been changed. - /// </remarks> - [NonSerialized] internal bool doupdate; - - /// <summary> - /// Indicates that a Collection has old elements that need to be removed. - /// </summary> - /// <remarks> - /// A Collection needs to have removals performed whenever its role changes or - /// the key changes and it has a loadedPersister - ie - it was loaded by NHibernate. - /// </remarks> - [NonSerialized] internal bool doremove; - - /// <summary> - /// Indicates that a Collection needs to be recreated. - /// </summary> - /// <remarks> - /// A Collection needs to be recreated whenever its role changes - /// or the owner changes. - /// </remarks> - [NonSerialized] internal bool dorecreate; - - /// <summary> - /// Indicates that the Collection has been fully initialized. - /// </summary> - internal bool initialized; - - /// <summary> - /// The <see cref="CollectionPersister"/> that is currently responsible - /// for the Collection. - /// </summary> - /// <remarks> - /// This is set when NHibernate is updating a reachable or an - /// unreachable collection. - /// </remarks> - [NonSerialized] internal CollectionPersister currentPersister; - - /// <summary> - /// The <see cref="CollectionPersister"/> when the Collection was loaded. - /// </summary> - /// <remarks> - /// This can be <c>null</c> if the Collection was not loaded by NHibernate and - /// was passed in along with a transient object. - /// </remarks> - [NonSerialized] internal CollectionPersister loadedPersister; - [NonSerialized] internal object currentKey; - internal object loadedKey; - internal object snapshot; //session-start/post-flush persistent state - internal string role; - - /// <summary> - /// Initializes a new instance of <see cref="CollectionEntry"/>. - /// </summary> - /// <remarks> - /// The CollectionEntry is for a Collection that is not dirty and - /// has already been initialized. - /// </remarks> - public CollectionEntry() - { - this.dirty = false; - this.initialized = true; - } - - /// <summary> - /// Initializes a new instance of <see cref="CollectionEntry"/>. - /// </summary> - /// <param name="loadedPersister">The <see cref="CollectionPersister"/> that persists this Collection type.</param> - /// <param name="loadedID">The identifier of the Entity that is the owner of this Collection.</param> - /// <param name="initialized">A boolean indicating if the collection has been initialized.</param> - public CollectionEntry(CollectionPersister loadedPersister, object loadedID, bool initialized) - { - this.dirty = false; - this.initialized = initialized; - this.loadedKey = loadedID; - SetLoadedPersister(loadedPersister); - } - - /// <summary> - /// Initializes a new instance of <see cref="CollectionEntry"/>. - /// </summary> - /// <param name="cs">The <see cref="ICollectionSnapshot"/> from another <see cref="ISession"/>.</param> - /// <param name="factory">The <see cref="ISessionFactoryImplementor"/> that created this <see cref="ISession"/>.</param> - /// <remarks> - /// This takes an <see cref="ICollectionSnapshot"/> from another <see cref="ISession"/> and - /// creates an entry for it in this <see cref="ISession"/> by copying the values from the - /// <c>cs</c> parameter. - /// </remarks> - public CollectionEntry(ICollectionSnapshot cs, ISessionFactoryImplementor factory) - { - this.dirty = cs.Dirty; - this.snapshot = cs.Snapshot; - this.loadedKey = cs.Key; - SetLoadedPersister( factory.GetCollectionPersister( cs.Role ) ); - this.initialized = true; - } - - /// <summary> - /// Checks to see if the <see cref="PersistentCollection"/> has had any changes to the - /// collections contents or if any of the elements in the collection have been modified. - /// </summary> - /// <param name="coll"></param> - /// <returns><c>true</c> if the <see cref="PersistentCollection"/> is dirty.</returns> - /// <remarks> - /// default behavior; will be overridden in deep lazy collections - /// </remarks> - public virtual bool IsDirty(PersistentCollection coll) - { - // if this has already been marked as dirty or the collection can not - // be directly accessed (ie- we can guarantee that the NHibernate collection - // wrappers are used) and the elements in the collection are not mutable - // then return the dirty flag. - if ( dirty || ( - !coll.IsDirectlyAccessible && !loadedPersister.ElementType.IsMutable - ) ) - { - return dirty; - } - else - { - // need to have the coll determine if it is the same as the snapshot - // that was last taken. - return !coll.EqualsSnapshot( loadedPersister.ElementType ); - } - } - - /// <summary> - /// Prepares this CollectionEntry for the Flush process. - /// </summary> - /// <param name="collection">The <see cref="PersistentCollection"/> that this CollectionEntry will be responsible for flushing.</param> - public void PreFlush(PersistentCollection collection) - { - // if the collection is initialized and it was previously persistent - // initialize the dirty flag - dirty = ( initialized && loadedPersister!=null && IsDirty(collection) ) || - (!initialized && dirty ); //only need this so collection with queued adds will be removed from JCS cache - - if ( log.IsDebugEnabled && dirty && loadedPersister!=null ) - { - log.Debug("Collection dirty: " + MessageHelper.InfoString(loadedPersister, loadedKey) ); - } - - // reset all of these values so any previous flush status - // information is cleared from this CollectionEntry - doupdate = false; - doremove = false; - dorecreate = false; - reached = false; - processed = false; - } - - /// <summary> - /// Updates the CollectionEntry to reflect that the <see cref="PersistentCollection"/> - /// has been initialized. - /// </summary> - /// <param name="collection">The initialized <see cref="PersistentCollection"/> that this Entry is for.</param> - public void PostInitialize(PersistentCollection collection) - { - initialized = true; - snapshot = collection.GetSnapshot(loadedPersister); - } - - /// <summary> - /// Updates the CollectionEntry to reflect that it is has been successfully flushed to the database. - /// </summary> - /// <param name="collection">The <see cref="PersistentCollection"/> that was flushed.</param> - public void PostFlush(PersistentCollection collection) - { - // the CollectionEntry should be processed if we are in the PostFlush() - if( !processed ) - { - throw new AssertionFailure("Hibernate has a bug processing collections"); - } - - // now that the flush has gone through move everything that is the current - // over to the loaded fields and set dirty to false since the db & collection - // are in synch. - loadedKey = currentKey; - SetLoadedPersister( currentPersister ); - dirty = false; - - // collection needs to know its' representation in memory and with - // the db is now in synch - esp important for collections like a bag - // that can add without initializing the collection. - collection.PostFlush(); - - // if it was initialized or any of the scheduled actions were performed then - // need to resnpashot the contents of the collection. - if ( initialized && ( doremove || dorecreate || doupdate ) ) - { - snapshot = collection.GetSnapshot(loadedPersister); //re-snapshot - } - } - - #region Engine.ICollectionSnapshot Members - - public object Key - { - get { return loadedKey; } - } - - public string Role - { - get { return role; } - } - - public object Snapshot - { - get { return snapshot; } - } - - public bool Dirty - { - get { return dirty; } - } - - public void SetDirty() - { - dirty = true; - } - public bool IsInitialized - { - get { return initialized;} - } - - - #endregion - - /// <summary> - /// Sets the information in this CollectionEntry that is specific to the - /// <see cref="CollectionPersister"/>. - /// </summary> - /// <param name="persister"> - /// The <see cref="CollectionPersister"/> that is - /// responsible for the Collection. - /// </param> - private void SetLoadedPersister(CollectionPersister persister) - { - loadedPersister = persister; - if (persister!=null) - { - role=persister.Role; - } - } - - public bool SnapshotIsEmpty - { - get - { - //TODO: implementation here is non-extensible ... - //should use polymorphism - // return initialized && snapshot!=null && ( - // ( snapshot is IList && ( (IList) snapshot ).Count==0 ) || // if snapshot is a collection - // ( snapshot is Map && ( (Map) snapshot ).Count==0 ) || // if snapshot is a map - // (snapshot.GetType().IsArray && ( (Array) snapshot).Length==0 )// if snapshot is an array - // ); - - // TODO: in .NET an IList, IDictionary, and Array are all collections so we might be able - // to just cast it to a ICollection instead of all the diff collections. - return initialized && snapshot!=null && ( - ( snapshot is IList && ( (IList) snapshot ).Count==0 ) || // if snapshot is a collection - ( snapshot is IDictionary && ( (IDictionary) snapshot ).Count==0 ) || // if snapshot is a map - (snapshot.GetType().IsArray && ( (Array) snapshot).Length==0 )// if snapshot is an array - ); - } - } - public bool IsNew - { - // TODO: is this correct implementation - h2.0.3 - get { return initialized && (snapshot==null); } - } - } - #region System.Runtime.Serialization.ISerializable Members --- 104,107 ---- Index: ScheduledCollectionAction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionAction.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ScheduledCollectionAction.cs 29 Nov 2004 15:31:07 -0000 1.7 --- ScheduledCollectionAction.cs 9 Dec 2004 22:08:54 -0000 1.8 *************** *** 10,14 **** /// flush. /// </summary> ! internal abstract class ScheduledCollectionAction : SessionImpl.IExecutable { private CollectionPersister _persister; --- 10,14 ---- /// flush. /// </summary> ! internal abstract class ScheduledCollectionAction : IExecutable { private CollectionPersister _persister; --- NEW FILE: IExecutable.cs --- using System; namespace NHibernate.Impl { /// <summary> /// An action that <see cref="ISession"/> can Execute during a /// <c>Flush</c>. /// </summary> internal interface IExecutable { /// <summary> /// Execute the action required to write changes to the database. /// </summary> void Execute(); /// <summary> /// Called after the Transaction has been completed. /// </summary> /// <remarks> /// Actions should make sure that the Cache is notified about /// what just happened. /// </remarks> void AfterTransactionCompletion(); /// <summary> /// The spaces (tables) that are affectd by this Executable action. /// </summary> /// <remarks> /// This is used to determine if the ISession needs to be flushed before /// a query is executed so stale data is not returned. /// </remarks> object[] PropertySpaces { get; } } } Index: ScheduledEntityAction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledEntityAction.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ScheduledEntityAction.cs 29 Nov 2004 15:31:07 -0000 1.6 --- ScheduledEntityAction.cs 9 Dec 2004 22:08:54 -0000 1.7 *************** *** 10,14 **** /// flush. /// </summary> ! internal abstract class ScheduledEntityAction : SessionImpl.IExecutable { --- 10,14 ---- /// flush. /// </summary> ! internal abstract class ScheduledEntityAction : IExecutable { --- NEW FILE: EntityEntry.cs --- using System; using NHibernate.Persister; namespace NHibernate.Impl { /// <summary> /// We need an entry to tell us all about the current state /// of an object with respect to its persistent state /// </summary> [Serializable] sealed internal class EntityEntry { private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(EntityEntry) ); private LockMode _lockMode; private Status _status; private object _id; private object[] _loadedState; private object[] _deletedState; private bool _existsInDatabase; private object _version; // for convenience to save some lookups [NonSerialized] private IClassPersister _persister; private string _className; /// <summary> /// Initializes a new instance of EntityEntry. /// </summary> /// <param name="status">The current <see cref="Status"/> of the Entity.</param> /// <param name="loadedState">The snapshot of the Entity's state when it was loaded.</param> /// <param name="id">The identifier of the Entity in the database.</param> /// <param name="version">The version of the Entity.</param> /// <param name="lockMode">The <see cref="LockMode"/> for the Entity.</param> /// <param name="existsInDatabase">A boolean indicating if the Entity exists in the database.</param> /// <param name="persister">The <see cref="IClassPersister"/> that is responsible for this Entity.</param> public EntityEntry(Status status, object[] loadedState, object id, object version, LockMode lockMode, bool existsInDatabase, IClassPersister persister) { _status = status; _loadedState = loadedState; _id = id; _existsInDatabase = existsInDatabase; _version = version; _lockMode = lockMode; _persister = persister; if (_persister!=null) _className = _persister.ClassName; } /// <summary> /// Gets or sets the current <see cref="LockMode"/> of the Entity. /// </summary> /// <value>The <see cref="LockMode"/> of the Entity.</value> public LockMode LockMode { get { return _lockMode; } set { _lockMode = value; } } /// <summary> /// Gets or sets the <see cref="Status"/> of this Entity with respect to its /// persistence in the database. /// </summary> /// <value>The <see cref="Status"/> of this Entity.</value> public Status Status { get { return _status; } set { _status = value; } } /// <summary> /// Gets or sets the identifier of the Entity in the database. /// </summary> /// <value>The identifier of the Entity in the database if one has been assigned.</value> /// <remarks>This might be <c>null</c> when the <see cref="EntityEntry.Status"/> is /// <see cref="Status.Saving"/> and the database generates the id.</remarks> public object Id { get { return _id; } set { _id = value; } } /// <summary> /// Gets or sets the snapshot of the Entity when it was loaded from the database. /// </summary> /// <value>The snapshot of the Entity.</value> /// <remarks> /// There will only be a value when the Entity was loaded in the current Session. /// </remarks> public object[] LoadedState { get { return _loadedState; } set { _loadedState = value; } } /// <summary> /// Gets or sets the snapshot of the Entity when it was marked as being ready for deletion. /// </summary> /// <value>The snapshot of the Entity.</value> /// <remarks>This will be <c>null</c> if the Entity is not being deleted.</remarks> public object[] DeletedState { get { return _deletedState; } set { _deletedState = value; } } /// <summary> /// Gets or sets a <see cref="Boolean"/> indicating if this Entity exists in the database. /// </summary> /// <value><c>true</c> if it is already in the database.</value> /// <remarks> /// It can also be <c>true</c> if it does not exists in the database yet and the /// <see cref="IClassPersister.IsIdentifierAssignedByInsert"/> is <c>true</c>. /// </remarks> public bool ExistsInDatabase { get { return _existsInDatabase; } set { _existsInDatabase = value; } } /// <summary> /// Gets or sets the version of the Entity. /// </summary> /// <value>The version of the Entity.</value> public object Version { get { return _version; } set { _version = value; } } /// <summary> /// Gets or sets the <see cref="IClassPersister"/> that is responsible for this Entity. /// </summary> /// <value>The <see cref="IClassPersister"/> that is reponsible for this Entity.</value> public IClassPersister Persister { get { return _persister; } set { _persister = value; } } /// <summary> /// Gets the Fully Qualified Name of the class this Entity is an instance of. /// </summary> /// <value>The Fully Qualified Name of the class this Entity is an instance of.</value> public string ClassName { get { return _className; } } } } --- NEW FILE: CollectionEntry.cs --- using System; using System.Collections; using NHibernate.Collection; using NHibernate.Engine; namespace NHibernate.Impl { /// <summary> /// We need an entry to tell us all about the current state /// of a collection with respect to its persistent state /// </summary> [Serializable] public class CollectionEntry : ICollectionSnapshot { private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(CollectionEntry) ); internal bool dirty; /// <summary> /// Indicates that the Collection can still be reached by an Entity /// that exist in the <see cref="ISession"/>. /// </summary> /// <remarks> /// It is also used to ensure that the Collection is not shared between /// two Entities. /// </remarks> [NonSerialized] internal bool reached; /// <summary> /// Indicates that the Collection has been processed and is ready /// to have its state synchronized with the database. /// </summary> [NonSerialized] internal bool processed; /// <summary> /// Indicates that a Collection needs to be updated. /// </summary> /// <remarks> /// A Collection needs to be updated whenever the contents of the Collection /// have been changed. /// </remarks> [NonSerialized] internal bool doupdate; /// <summary> /// Indicates that a Collection has old elements that need to be removed. /// </summary> /// <remarks> /// A Collection needs to have removals performed whenever its role changes or /// the key changes and it has a loadedPersister - ie - it was loaded by NHibernate. /// </remarks> [NonSerialized] internal bool doremove; /// <summary> /// Indicates that a Collection needs to be recreated. /// </summary> /// <remarks> /// A Collection needs to be recreated whenever its role changes /// or the owner changes. /// </remarks> [NonSerialized] internal bool dorecreate; /// <summary> /// Indicates that the Collection has been fully initialized. /// </summary> internal bool initialized; /// <summary> /// The <see cref="CollectionPersister"/> that is currently responsible /// for the Collection. /// </summary> /// <remarks> /// This is set when NHibernate is updating a reachable or an /// unreachable collection. /// </remarks> [NonSerialized] internal CollectionPersister currentPersister; /// <summary> /// The <see cref="CollectionPersister"/> when the Collection was loaded. /// </summary> /// <remarks> /// This can be <c>null</c> if the Collection was not loaded by NHibernate and /// was passed in along with a transient object. /// </remarks> [NonSerialized] internal CollectionPersister loadedPersister; [NonSerialized] internal object currentKey; internal object loadedKey; internal object snapshot; //session-start/post-flush persistent state internal string role; /// <summary> /// Initializes a new instance of <see cref="CollectionEntry"/>. /// </summary> /// <remarks> /// The CollectionEntry is for a Collection that is not dirty and /// has already been initialized. /// </remarks> public CollectionEntry() { this.dirty = false; this.initialized = true; } /// <summary> /// Initializes a new instance of <see cref="CollectionEntry"/>. /// </summary> /// <param name="loadedPersister">The <see cref="CollectionPersister"/> that persists this Collection type.</param> /// <param name="loadedID">The identifier of the Entity that is the owner of this Collection.</param> /// <param name="initialized">A boolean indicating if the collection has been initialized.</param> public CollectionEntry(CollectionPersister loadedPersister, object loadedID, bool initialized) { this.dirty = false; this.initialized = initialized; this.loadedKey = loadedID; SetLoadedPersister(loadedPersister); } /// <summary> /// Initializes a new instance of <see cref="CollectionEntry"/>. /// </summary> /// <param name="cs">The <see cref="ICollectionSnapshot"/> from another <see cref="ISession"/>.</param> /// <param name="factory">The <see cref="ISessionFactoryImplementor"/> that created this <see cref="ISession"/>.</param> /// <remarks> /// This takes an <see cref="ICollectionSnapshot"/> from another <see cref="ISession"/> and /// creates an entry for it in this <see cref="ISession"/> by copying the values from the /// <c>cs</c> parameter. /// </remarks> public CollectionEntry(ICollectionSnapshot cs, ISessionFactoryImplementor factory) { this.dirty = cs.Dirty; this.snapshot = cs.Snapshot; this.loadedKey = cs.Key; SetLoadedPersister( factory.GetCollectionPersister( cs.Role ) ); this.initialized = true; } /// <summary> /// Checks to see if the <see cref="PersistentCollection"/> has had any changes to the /// collections contents or if any of the elements in the collection have been modified. /// </summary> /// <param name="coll"></param> /// <returns><c>true</c> if the <see cref="PersistentCollection"/> is dirty.</returns> /// <remarks> /// default behavior; will be overridden in deep lazy collections /// </remarks> public virtual bool IsDirty(PersistentCollection coll) { // if this has already been marked as dirty or the collection can not // be directly accessed (ie- we can guarantee that the NHibernate collection // wrappers are used) and the elements in the collection are not mutable // then return the dirty flag. if ( dirty || ( !coll.IsDirectlyAccessible && !loadedPersister.ElementType.IsMutable ) ) { return dirty; } else { // need to have the coll determine if it is the same as the snapshot // that was last taken. return !coll.EqualsSnapshot( loadedPersister.ElementType ); } } /// <summary> /// Prepares this CollectionEntry for the Flush process. /// </summary> /// <param name="collection">The <see cref="PersistentCollection"/> that this CollectionEntry will be responsible for flushing.</param> public void PreFlush(PersistentCollection collection) { // if the collection is initialized and it was previously persistent // initialize the dirty flag dirty = ( initialized && loadedPersister!=null && IsDirty(collection) ) || (!initialized && dirty ); //only need this so collection with queued adds will be removed from JCS cache if ( log.IsDebugEnabled && dirty && loadedPersister!=null ) { log.Debug("Collection dirty: " + MessageHelper.InfoString(loadedPersister, loadedKey) ); } // reset all of these values so any previous flush status // information is cleared from this CollectionEntry doupdate = false; doremove = false; dorecreate = false; reached = false; processed = false; } /// <summary> /// Updates the CollectionEntry to reflect that the <see cref="PersistentCollection"/> /// has been initialized. /// </summary> /// <param name="collection">The initialized <see cref="PersistentCollection"/> that this Entry is for.</param> public void PostInitialize(PersistentCollection collection) { initialized = true; snapshot = collection.GetSnapshot(loadedPersister); } /// <summary> /// Updates the CollectionEntry to reflect that it is has been successfully flushed to the database. /// </summary> /// <param name="collection">The <see cref="PersistentCollection"/> that was flushed.</param> public void PostFlush(PersistentCollection collection) { // the CollectionEntry should be processed if we are in the PostFlush() if( !processed ) { throw new AssertionFailure("Hibernate has a bug processing collections"); } // now that the flush has gone through move everything that is the current // over to the loaded fields and set dirty to false since the db & collection // are in synch. loadedKey = currentKey; SetLoadedPersister( currentPersister ); dirty = false; // collection needs to know its' representation in memory and with // the db is now in synch - esp important for collections like a bag // that can add without initializing the collection. collection.PostFlush(); // if it was initialized or any of the scheduled actions were performed then // need to resnpashot the contents of the collection. if ( initialized && ( doremove || dorecreate || doupdate ) ) { snapshot = collection.GetSnapshot(loadedPersister); //re-snapshot } } #region Engine.ICollectionSnapshot Members public object Key { get { return loadedKey; } } public string Role { get { return role; } } public object Snapshot { get { return snapshot; } } public bool Dirty { get { return dirty; } } public void SetDirty() { dirty = true; } public bool IsInitialized { get { return initialized;} } #endregion /// <summary> /// Sets the information in this CollectionEntry that is specific to the /// <see cref="CollectionPersister"/>. /// </summary> /// <param name="persister"> /// The <see cref="CollectionPersister"/> that is /// responsible for the Collection. /// </param> private void SetLoadedPersister(CollectionPersister persister) { loadedPersister = persister; if (persister!=null) { role=persister.Role; } } public bool SnapshotIsEmpty { get { //TODO: implementation here is non-extensible ... //should use polymorphism // return initialized && snapshot!=null && ( // ( snapshot is IList && ( (IList) snapshot ).Count==0 ) || // if snapshot is a collection // ( snapshot is Map && ( (Map) snapshot ).Count==0 ) || // if snapshot is a map // (snapshot.GetType().IsArray && ( (Array) snapshot).Length==0 )// if snapshot is an array // ); // TODO: in .NET an IList, IDictionary, and Array are all collections so we might be able // to just cast it to a ICollection instead of all the diff collections. return initialized && snapshot!=null && ( ( snapshot is IList && ( (IList) snapshot ).Count==0 ) || // if snapshot is a collection ( snapshot is IDictionary && ( (IDictionary) snapshot ).Count==0 ) || // if snapshot is a map (snapshot.GetType().IsArray && ( (Array) snapshot).Length==0 )// if snapshot is an array ); } } public bool IsNew { // TODO: is this correct implementation - h2.0.3 get { return initialized && (snapshot==null); } } } } --- NEW FILE: Status.cs --- using System; namespace NHibernate.Impl { /// <summary> /// Represents the status of an entity with respect to /// this session. These statuses are for internal /// book-keeping only and are not intended to represent /// any notion that is visible to the <b>application</b>. /// </summary> [Serializable] internal enum Status { /// <summary> /// The Entity is snapshotted in the Session with the same state as the database. /// </summary> Loaded, /// <summary> /// The Entity is in the Session and has been marked for deletion but not /// deleted from the database yet. /// </summary> Deleted, /// <summary> /// The Entity has been deleted from database. /// </summary> Gone, /// <summary> /// The Entity is in the process of being loaded. /// </summary> Loading, /// <summary> /// The Entity is in the process of being saved. /// </summary> Saving } } |
From: Michael D. <mik...@us...> - 2004-12-09 22:09:05
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20391/NHibernate Modified Files: NHibernate-1.1.csproj Log Message: Moved some nested classes out from SessionImpl into their own class. Index: NHibernate-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate-1.1.csproj,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** NHibernate-1.1.csproj 9 Dec 2004 17:52:14 -0000 1.62 --- NHibernate-1.1.csproj 9 Dec 2004 22:08:55 -0000 1.63 *************** *** 950,953 **** --- 950,958 ---- /> <File + RelPath = "Impl\CollectionEntry.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Impl\CriteriaImpl.cs" SubType = "Code" *************** *** 955,958 **** --- 960,968 ---- /> <File + RelPath = "Impl\EntityEntry.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Impl\EnumerableImpl.cs" SubType = "Code" *************** *** 965,968 **** --- 975,983 ---- /> <File + RelPath = "Impl\IExecutable.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Impl\MessageHelper.cs" SubType = "Code" *************** *** 1035,1038 **** --- 1050,1058 ---- /> <File + RelPath = "Impl\Status.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Loader\AbstractEntityLoader.cs" SubType = "Code" |
From: Michael D. <mik...@us...> - 2004-12-09 20:57:41
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2622/NHibernate.Test Modified Files: FooBarTest.cs Log Message: Modified DomainModel and Test classes with changes on proxy branch. Index: FooBarTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** FooBarTest.cs 20 Nov 2004 15:20:10 -0000 1.74 --- FooBarTest.cs 9 Dec 2004 20:57:26 -0000 1.75 *************** *** 351,354 **** --- 351,384 ---- public void ForceOuterJoin() { + if( ((Engine.ISessionFactoryImplementor)sessions).EnableJoinedFetch==false ) + { + // don't bother to run the test if we can't test it + return; + } + + ISession s = sessions.OpenSession(); + Glarch g = new Glarch(); + FooComponent fc = new FooComponent(); + fc.Glarch = g; + FooProxy f = new Foo(); + FooProxy f2 = new Foo(); + f.Component = fc; + f.TheFoo = f2; + s.Save( f2 ); + object id = s.Save( f ); + object gid = s.GetIdentifier( f.Component.Glarch ); + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + f = (FooProxy)s.Load( typeof(Foo), id ); + Assert.IsFalse( NHibernate.IsInitialized( f ) ); + Assert.IsTrue( NHibernate.IsInitialized( f.Component.Glarch ) ); //outer-join="true" + Assert.IsFalse( NHibernate.IsInitialized( f.TheFoo ) ); //outer-join="auto" + Assert.AreEqual( gid, s.GetIdentifier( f.Component.Glarch ) ); + s.Delete( f ); + s.Delete( f.TheFoo ); + s.Flush(); + s.Close(); } *************** *** 542,545 **** --- 572,614 ---- Assert.IsTrue( row is object[] && ( (object[])row).Length==3 ); + IQuery q = s.CreateQuery( + "select bar, b " + + "from Bar bar " + + "left join bar.Baz baz left join baz.CascadingBars b " + + "where (bar.Name in (:nameList) or bar.Name in (:nameList)) and bar.String = :stringVal" ); + + IList nameList = new ArrayList(); + nameList.Add( "bar" ); + nameList.Add( "Bar" ); + nameList.Add( "Bar Two" ); + q.SetParameterList( "nameList", nameList ); + q.SetParameter( "stringVal", "a string" ); + list = q.List(); + // a check for SAPDialect here + Assert.AreEqual( 2, list.Count ); + + q = s.CreateQuery( + "select bar, b " + + "from Bar bar " + + "inner join bar.Baz baz inner join baz.CascadingBars b " + + "where bar.Name like 'bar%'" ); + list = q.List(); + Assert.AreEqual( 1, list.Count ); + + q = s.CreateQuery( + "select bar, b " + + "from Bar bar " + + "left join bar.Baz baz left join baz.CascadingBars b " + + "where bar.Name like :name and b.Name like :name" ); + + // add a check for HSQLDialect + q.SetString( "name", "Bar%" ); + list = q.List(); + Assert.AreEqual( 1, list.Count ); + + s.Delete( baz ); + s.Delete( bar2 ); + s.Flush(); + s.Close(); } *************** *** 2854,2857 **** --- 2923,2973 ---- public void ProxyArray() { + ISession s = sessions.OpenSession(); + GlarchProxy g = new Glarch(); + Glarch g1 = new Glarch(); + Glarch g2 = new Glarch(); + g.ProxyArray = new GlarchProxy[] { g1, g2 }; + Glarch g3 = new Glarch(); + s.Save( g3 ); + g2.ProxyArray = new GlarchProxy[] { null, g3, g }; + + object emptyObject = new object(); + Iesi.Collections.ISet hashset = new Iesi.Collections.HashedSet(); + hashset.Add( g1 ); + hashset.Add( g2 ); + g.ProxySet = hashset; + s.Save( g ); + s.Save( g1 ); + s.Save( g2 ); + object id = s.GetIdentifier( g ); + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + g = (GlarchProxy)s.Load( typeof(Glarch), id ); + Assert.AreEqual( 2, g.ProxyArray.Length, "array of proxies" ); + Assert.IsNotNull( g.ProxyArray[0], "array of proxies" ); + Assert.IsNull( g.ProxyArray[1].ProxyArray[0], "deferred load test" ); + Assert.AreEqual( g, g.ProxyArray[1].ProxyArray[2], "deferred load test" ); + Assert.AreEqual( 2, g.ProxySet.Count, "set of proxies" ); + + IEnumerator enumer = s.Enumerable( "from g in class NHibernate.DomainModel.Glarch" ).GetEnumerator(); + while( enumer.MoveNext() ) + { + s.Delete( enumer.Current ); + } + + s.Flush(); + s.Disconnect(); + + // serialize and then deserialize the session. + System.IO.Stream stream = new System.IO.MemoryStream(); + System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); + formatter.Serialize(stream, s); + stream.Position = 0; + s = (ISession)formatter.Deserialize(stream); + stream.Close(); + + s.Close(); } *************** *** 3169,3173 **** catch(LazyInitializationException lie) { ! Assert.IsNotNull(lie); //getting ride of 'lie' is never used compile warning err = true; } --- 3285,3289 ---- catch(LazyInitializationException lie) { ! Assert.IsNotNull( lie ); //getting ride of 'lie' is never used compile warning err = true; } *************** *** 3404,3407 **** --- 3520,3581 ---- public void ProxiesInCollections() { + ISession s = sessions.OpenSession(); + Baz baz = new Baz(); + Bar bar = new Bar(); + Bar bar2 = new Bar(); + s.Save( bar ); + object bar2id = s.Save( bar2 ); + baz.FooArray = new Foo[] { bar, bar2 }; + + object emptyObject = new object(); + Iesi.Collections.ISet hashset = new Iesi.Collections.HashedSet(); + bar = new Bar(); + s.Save( bar ); + hashset.Add( bar ); + baz.FooSet = hashset; + hashset = new Iesi.Collections.HashedSet(); + hashset.Add( new Bar() ); + hashset.Add( new Bar() ); + baz.CascadingBars = hashset; + ArrayList list = new ArrayList(); + list.Add( new Foo() ); + baz.FooBag = list; + object id = s.Save( baz ); + IEnumerator enumer = baz.CascadingBars.GetEnumerator(); + enumer.MoveNext(); + object bid = ((Bar)enumer.Current).Key; + s.Flush(); + s.Close(); + + s = sessions.OpenSession(); + BarProxy barprox = (BarProxy)s.Load( typeof(Bar), bid ); + BarProxy bar2prox = (BarProxy)s.Load( typeof(Bar), bar2id ); + Assert.IsTrue( bar2prox is Proxy.INHibernateProxy ); + Assert.IsTrue( barprox is Proxy.INHibernateProxy ); + baz = (Baz)s.Load( typeof(Baz), id ); + enumer = baz.CascadingBars.GetEnumerator(); + enumer.MoveNext(); + BarProxy b1 = (BarProxy)enumer.Current; + enumer.MoveNext(); + BarProxy b2 = (BarProxy)enumer.Current; + Assert.IsTrue( + ( b1==barprox && !(b2 is Proxy.INHibernateProxy) ) + || ( b2==barprox && !(b1 is Proxy.INHibernateProxy) ) ); //one-to-many + Assert.IsTrue( baz.FooArray[0] is Proxy.INHibernateProxy ); //many-to-many + Assert.AreEqual( bar2prox, baz.FooArray[1] ); + if( ((Engine.ISessionFactoryImplementor)sessions).EnableJoinedFetch ) + { + enumer = baz.FooBag.GetEnumerator(); + enumer.MoveNext(); + Assert.IsFalse( enumer.Current is Proxy.INHibernateProxy ); // many-to-many outer-join="true" + } + + enumer = baz.FooSet.GetEnumerator(); + enumer.MoveNext(); + Assert.IsFalse( enumer.Current is Proxy.INHibernateProxy ); //one-to-many + s.Delete( "from o in class Baz" ); + s.Delete( "from o in class Foo" ); + s.Flush(); + s.Close(); } *************** *** 3418,3422 **** } - } } --- 3592,3595 ---- |
From: Michael D. <mik...@us...> - 2004-12-09 20:57:36
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2622/NHibernate.DomainModel Modified Files: A.cs B.cs Baz.cs C1.cs C2.cs Contained.cs Container.cs D.cs Qux.cs Z.cs Log Message: Modified DomainModel and Test classes with changes on proxy branch. Index: A.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/A.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** A.cs 17 Jun 2004 21:17:13 -0000 1.3 --- A.cs 9 Dec 2004 20:57:25 -0000 1.4 *************** *** 1,3 **** - using System; --- 1,2 ---- *************** *** 48,61 **** /// Get/set for id /// </summary> ! public Int64 Id ! { ! get ! { ! return _id; ! } ! set { ! _id = value; ! } } --- 47,54 ---- /// Get/set for id /// </summary> ! public virtual Int64 Id { ! get { return _id; } ! set { _id = value; } } *************** *** 63,76 **** /// Get/set for name /// </summary> ! public String Name { ! get ! { ! return _name; ! } ! set ! { ! _name = value; ! } } --- 56,63 ---- /// Get/set for name /// </summary> ! public virtual String Name { ! get { return _name; } ! set { _name = value; } } Index: Contained.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/Contained.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Contained.cs 2 Jun 2004 04:53:24 -0000 1.1 --- Contained.cs 9 Dec 2004 20:57:25 -0000 1.2 *************** *** 29,33 **** #endregion ! public Container Container { get { return _container; } --- 29,33 ---- #endregion ! public virtual Container Container { get { return _container; } *************** *** 35,39 **** } ! public long Id { get { return _id; } --- 35,39 ---- } ! public virtual long Id { get { return _id; } *************** *** 41,45 **** } ! public IList Bag { get { return _bag; } --- 41,45 ---- } ! public virtual IList Bag { get { return _bag; } *************** *** 47,51 **** } ! public IList LazyBag { get { return _lazyBag; } --- 47,51 ---- } ! public virtual IList LazyBag { get { return _lazyBag; } Index: B.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/B.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** B.cs 4 Jun 2004 12:02:43 -0000 1.3 --- B.cs 9 Dec 2004 20:57:25 -0000 1.4 *************** *** 62,75 **** /// Get/set for count /// </summary> ! public Int32 Count { ! get ! { ! return this._count; ! } ! set ! { ! this._count = value; ! } } --- 62,69 ---- /// Get/set for count /// </summary> ! public virtual Int32 Count { ! get { return _count; } ! set { _count = value; } } *************** *** 77,90 **** /// Get/set for map /// </summary> ! public System.Collections.IDictionary Map { ! get ! { ! return this._map; ! } ! set ! { ! this._map = value; ! } } --- 71,78 ---- /// Get/set for map /// </summary> ! public virtual System.Collections.IDictionary Map { ! get { return _map; } ! set { _map = value; } } Index: Container.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/Container.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Container.cs 18 Nov 2004 02:45:43 -0000 1.3 --- Container.cs 9 Dec 2004 20:57:25 -0000 1.4 *************** *** 97,101 **** ! public IList OneToMany { get { return _oneToMany; } --- 97,101 ---- ! public virtual IList OneToMany { get { return _oneToMany; } *************** *** 103,107 **** } ! public IList ManyToMany { get { return _manyToMany; } --- 103,107 ---- } ! public virtual IList ManyToMany { get { return _manyToMany; } *************** *** 109,113 **** } ! public IList Components { get { return _components; } --- 109,113 ---- } ! public virtual IList Components { get { return _components; } *************** *** 115,119 **** } ! public Iesi.Collections.ISet Composites { get { return _composites; } --- 115,119 ---- } ! public virtual Iesi.Collections.ISet Composites { get { return _composites; } *************** *** 121,125 **** } ! public IList Cascades { get { return _cascades; } --- 121,125 ---- } ! public virtual IList Cascades { get { return _cascades; } *************** *** 127,131 **** } ! public long Id { get { return _id; } --- 127,131 ---- } ! public virtual long Id { get { return _id; } *************** *** 133,137 **** } ! public IList Bag { get { return _bag; } --- 133,137 ---- } ! public virtual IList Bag { get { return _bag; } *************** *** 139,143 **** } ! public IList LazyBag { get { return _lazyBag; } --- 139,143 ---- } ! public virtual IList LazyBag { get { return _lazyBag; } *************** *** 145,149 **** } ! public IDictionary TernaryMap { get { return _ternaryMap; } --- 145,149 ---- } ! public virtual IDictionary TernaryMap { get { return _ternaryMap; } *************** *** 151,155 **** } ! public Iesi.Collections.ISet TernarySet { get { return _ternarySet; } --- 151,155 ---- } ! public virtual Iesi.Collections.ISet TernarySet { get { return _ternarySet; } Index: D.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/D.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** D.cs 17 Jun 2004 21:17:13 -0000 1.2 --- D.cs 9 Dec 2004 20:57:25 -0000 1.3 *************** *** 51,55 **** /// Get/set for id /// </summary> ! public Int64 Id { get { return _id; } --- 51,55 ---- /// Get/set for id /// </summary> ! public virtual Int64 Id { get { return _id; } *************** *** 60,64 **** /// Get/set for Amount /// </summary> ! public Double Amount { get { return _amount; } --- 60,64 ---- /// Get/set for Amount /// </summary> ! public virtual Double Amount { get { return _amount; } Index: Qux.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/Qux.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Qux.cs 18 Nov 2004 02:45:43 -0000 1.6 --- Qux.cs 9 Dec 2004 20:57:25 -0000 1.7 *************** *** 16,20 **** private bool _stored; private string _stuff; - // <set> private Iesi.Collections.ISet _fums; private IList _moreFums; --- 16,19 ---- *************** *** 82,86 **** /// Gets or sets the _foo /// </summary> ! public FooProxy Foo { get { return _foo; } --- 81,85 ---- /// Gets or sets the _foo /// </summary> ! public virtual FooProxy Foo { get { return _foo; } *************** *** 91,95 **** /// Gets or sets the _created /// </summary> ! public bool Created { get { return _created; } --- 90,94 ---- /// Gets or sets the _created /// </summary> ! public virtual bool Created { get { return _created; } *************** *** 100,104 **** /// Gets or sets the _deleted /// </summary> ! public bool Deleted { get { return _deleted; } --- 99,103 ---- /// Gets or sets the _deleted /// </summary> ! public virtual bool Deleted { get { return _deleted; } *************** *** 109,113 **** /// Gets or sets the _loaded /// </summary> ! public bool Loaded { get { return _loaded; } --- 108,112 ---- /// Gets or sets the _loaded /// </summary> ! public virtual bool Loaded { get { return _loaded; } *************** *** 118,122 **** /// Gets or sets the _stored /// </summary> ! public bool Stored { get { return _stored; } --- 117,121 ---- /// Gets or sets the _stored /// </summary> ! public virtual bool Stored { get { return _stored; } *************** *** 127,131 **** /// Gets or sets the _key /// </summary> ! public long Key { get { return _key; } --- 126,130 ---- /// Gets or sets the _key /// </summary> ! public virtual long Key { get { return _key; } *************** *** 133,137 **** } ! public long TheKey { set { _key = value; } --- 132,136 ---- } ! public virtual long TheKey { set { _key = value; } *************** *** 141,145 **** /// Gets or sets the _stuff /// </summary> ! public string Stuff { get { return _stuff; } --- 140,144 ---- /// Gets or sets the _stuff /// </summary> ! public virtual string Stuff { get { return _stuff; } *************** *** 150,154 **** /// Gets or sets the _fums (<set>) /// </summary> ! public Iesi.Collections.ISet Fums { get { return _fums; } --- 149,153 ---- /// Gets or sets the _fums (<set>) /// </summary> ! public virtual Iesi.Collections.ISet Fums { get { return _fums; } *************** *** 159,163 **** /// Gets or sets the _moreFums /// </summary> ! public IList MoreFums { get { return _moreFums; } --- 158,162 ---- /// Gets or sets the _moreFums /// </summary> ! public virtual IList MoreFums { get { return _moreFums; } *************** *** 165,169 **** } ! public Qux Child { get --- 164,168 ---- } ! public virtual Qux Child { get *************** *** 180,184 **** /// Gets or sets the _childKey /// </summary> ! public long ChildKey { get { return _childKey; } --- 179,183 ---- /// Gets or sets the _childKey /// </summary> ! public virtual long ChildKey { get { return _childKey; } Index: Baz.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/Baz.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Baz.cs 18 Nov 2004 02:45:43 -0000 1.11 --- Baz.cs 9 Dec 2004 20:57:25 -0000 1.12 *************** *** 39,43 **** private System.Collections.IDictionary _stringGlarchMap; private System.Collections.IDictionary _anyToAny; - //private System.Collections.IDictionary _fooSet; private Iesi.Collections.ISet _fooSet; private Iesi.Collections.ISet _stringSet; --- 39,42 ---- Index: C2.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/C2.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** C2.cs 3 Jun 2004 18:01:24 -0000 1.2 --- C2.cs 9 Dec 2004 20:57:25 -0000 1.3 *************** *** 1,12 **** - //------------------------------------------------------------------------------ - // <autogenerated> - // This code was generated by a tool. - // Runtime Version: v1.1.4322 - // - // Changes to this file may cause incorrect behavior and will be lost if - // the code is regenerated. - // </autogenerated> - //------------------------------------------------------------------------------ - using System; --- 1,2 ---- *************** *** 67,80 **** /// Get/set for address /// </summary> ! public String Address { ! get ! { ! return this._address; ! } ! set ! { ! this._address = value; ! } } --- 57,64 ---- /// Get/set for address /// </summary> ! public virtual String Address { ! get { return _address; } ! set { _address = value; } } Index: Z.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/Z.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Z.cs 3 Jun 2004 14:54:40 -0000 1.1 --- Z.cs 9 Dec 2004 20:57:25 -0000 1.2 *************** *** 11,15 **** private W _w; ! public long Id { get { return _id; } --- 11,15 ---- private W _w; ! public virtual long Id { get { return _id; } *************** *** 17,21 **** } ! public W W { get { return _w; } --- 17,21 ---- } ! public virtual W W { get { return _w; } Index: C1.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/C1.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** C1.cs 17 Jun 2004 21:17:13 -0000 1.4 --- C1.cs 9 Dec 2004 20:57:25 -0000 1.5 *************** *** 1,12 **** - //------------------------------------------------------------------------------ - // <autogenerated> - // This code was generated by a tool. - // Runtime Version: v1.1.4322 - // - // Changes to this file may cause incorrect behavior and will be lost if - // the code is regenerated. - // </autogenerated> - //------------------------------------------------------------------------------ - using System; --- 1,2 ---- *************** *** 74,87 **** /// Get/set for address /// </summary> ! public String Address ! { ! get ! { ! return _address; ! } ! set { ! _address = value; ! } } --- 64,71 ---- /// Get/set for address /// </summary> ! public virtual String Address { ! get { return _address; } ! set { _address = value; } } *************** *** 89,102 **** /// Get/set for d /// </summary> ! public D D { ! get ! { ! return _d; ! } ! set ! { ! _d = value; ! } } --- 73,80 ---- /// Get/set for d /// </summary> ! public virtual D D { ! get { return _d; } ! set { _d = value; } } |