|
From: <fab...@us...> - 2008-07-25 04:52:46
|
Revision: 3661
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3661&view=rev
Author: fabiomaulo
Date: 2008-07-25 04:52:55 +0000 (Fri, 25 Jul 2008)
Log Message:
-----------
Fix NH-1405 in a different way than 2.0 branch
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Type/EmbeddedComponentType.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Column.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Type/EmbeddedComponentType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/EmbeddedComponentType.cs 2008-07-23 23:19:37 UTC (rev 3660)
+++ trunk/nhibernate/src/NHibernate/Type/EmbeddedComponentType.cs 2008-07-25 04:52:55 UTC (rev 3661)
@@ -19,7 +19,9 @@
public override object Instantiate(object parent, ISessionImplementor session)
{
- bool useParent = parent != null && base.ReturnedClass.IsInstanceOfType(parent);
+ bool useParent= false;
+ // NH Different implemetation : since we are not sure about why H3.2 use the "parent"
+ //useParent = parent != null && base.ReturnedClass.IsInstanceOfType(parent);
return useParent ? parent : base.Instantiate(parent, session);
}
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Column.cs (from rev 3659, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Column.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Column.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Column.cs 2008-07-25 04:52:55 UTC (rev 3661)
@@ -0,0 +1,124 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH1405
+{
+ public class Column
+ {
+ /// <summary>
+ /// The column name. Part 3 of 3 of the primary key.
+ /// </summary>
+ private String _columnName;
+
+ /// <summary>
+ /// Another column in the same table.
+ /// </summary>
+ private Column _controlColumn;
+
+ /// <summary>
+ /// The system ID. Part 1 of 3 of the primary key.
+ /// </summary>
+ private String _systemId;
+
+ /// <summary>
+ /// The table name. Part 2 of 3 of the primary key.
+ /// </summary>
+ private String _tableName;
+
+ /// <summary>
+ /// The column name. Part 3 of 3 of the primary key.
+ /// </summary>
+ public virtual String ColumnName
+ {
+ get { return _columnName; }
+ set { _columnName = value; }
+ }
+
+ /// <summary>
+ /// Another column in the same table.
+ /// </summary>
+ public virtual Column ControlColumn
+ {
+ get { return _controlColumn; }
+ set { _controlColumn = value; }
+ }
+
+ /// <summary>
+ /// The system ID. Part 1 of 3 of the primary key.
+ /// </summary>
+ public virtual String SystemId
+ {
+ get { return _systemId; }
+ set { _systemId = value; }
+ }
+
+ /// <summary>
+ /// The table name. Part 2 of 3 of the primary key.
+ /// </summary>
+ public virtual String TableName
+ {
+ get { return _tableName; }
+ set { _tableName = value; }
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (GetType() != obj.GetType())
+ {
+ return false;
+ }
+ Column other = (Column) obj;
+ if (null == _systemId)
+ {
+ if (null != other._systemId)
+ {
+ return false;
+ }
+ }
+ else if (!_systemId.Equals(other._systemId))
+ {
+ return false;
+ }
+ if (null == _tableName)
+ {
+ if (null != other._tableName)
+ {
+ return false;
+ }
+ }
+ else if (!_tableName.Equals(other._tableName))
+ {
+ return false;
+ }
+ if (null == _columnName)
+ {
+ if (null != other._columnName)
+ {
+ return false;
+ }
+ }
+ else if (!_columnName.Equals(other._columnName))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ const int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + ((null == _systemId) ? 0 : _systemId.GetHashCode());
+ result = PRIME * result + ((null == _tableName) ? 0 : _tableName.GetHashCode());
+ result = PRIME * result + ((null == _columnName) ? 0 : _columnName.GetHashCode());
+ return result;
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Column.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Fixture.cs (from rev 3660, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Fixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Fixture.cs 2008-07-25 04:52:55 UTC (rev 3661)
@@ -0,0 +1,58 @@
+using System.Collections.Generic;
+using System.Data;
+using NUnit.Framework;
+namespace NHibernate.Test.NHSpecificTest.NH1405
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ [Test]
+ public void Bug()
+ {
+ string[] populate = new string[]
+ {
+ "insert into PPDM_COLUMN ( SYSTEM_ID, TABLE_NAME, COLUMN_NAME, CONTROL_COLUMN ) values ( 'SYSTEM', 'TABLE', 'COLUMN1', null )",
+ "insert into PPDM_COLUMN ( SYSTEM_ID, TABLE_NAME, COLUMN_NAME, CONTROL_COLUMN ) values ( 'SYSTEM', 'TABLE', 'COLUMN2', 'COLUMN1' )",
+ "insert into PPDM_COLUMN ( SYSTEM_ID, TABLE_NAME, COLUMN_NAME, CONTROL_COLUMN ) values ( 'SYSTEM', 'TABLE', 'COLUMN3', 'COLUMN2' )"
+ };
+
+ using (ISession session = OpenSession())
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ foreach (string sql in populate)
+ {
+ IDbCommand cmd = session.Connection.CreateCommand();
+ cmd.CommandText = sql;
+ tx.Enlist(cmd);
+ cmd.ExecuteNonQuery();
+ }
+ tx.Commit();
+ }
+
+ using (ISession session = OpenSession())
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ IQuery query = session.CreateQuery("from Column");
+ IList<Column> columns = query.List<Column>();
+ Assert.AreEqual(3, columns.Count);
+ foreach (Column column in columns)
+ {
+ Assert.IsNotNull(column.ColumnName, "Column.ColumnName should not be null.");
+ Assert.IsFalse((null != column.ControlColumn) && (null == column.ControlColumn.ColumnName),
+ "Column's control column's ColumnName should not be null.");
+ }
+ tx.Commit();
+ }
+
+ using (ISession session = OpenSession())
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ IDbCommand cmd = session.Connection.CreateCommand();
+ cmd.CommandText = "DELETE FROM PPDM_COLUMN";
+ tx.Enlist(cmd);
+ cmd.ExecuteNonQuery();
+ tx.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Fixture.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Mappings.hbm.xml (from rev 3659, branches/2.0.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Mappings.hbm.xml 2008-07-25 04:52:55 UTC (rev 3661)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1405"
+ default-lazy="false">
+
+ <class name="Column" table="PPDM_COLUMN">
+ <composite-id>
+ <key-property name="SystemId" type="String" column="SYSTEM_ID" length="20" />
+ <key-property name="TableName" type="String" column="TABLE_NAME" length="30" />
+ <key-property name="ColumnName" type="String" column="COLUMN_NAME" length="30" />
+ </composite-id>
+ <!--
+ Remove this many-to-one mapping and ColumnName will be retrieved correctly -
+ keep it and ColumnName will be null.
+ ControlColumn is never fetched correctly.
+ -->
+ <many-to-one name="ControlColumn" class="Column" update="false" insert="false" not-found="ignore">
+ <column name="SYSTEM_ID" />
+ <column name="TABLE_NAME" />
+ <column name="CONTROL_COLUMN" length="30" />
+ </many-to-one>
+ </class>
+</hibernate-mapping>
+
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1405/Mappings.hbm.xml
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-07-23 23:19:37 UTC (rev 3660)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test-2.0.csproj 2008-07-25 04:52:55 UTC (rev 3661)
@@ -401,6 +401,8 @@
<Compile Include="NHSpecificTest\NH1403\Hobby.cs" />
<Compile Include="NHSpecificTest\NH1403\Male.cs" />
<Compile Include="NHSpecificTest\NH1403\Person.cs" />
+ <Compile Include="NHSpecificTest\NH1405\Column.cs" />
+ <Compile Include="NHSpecificTest\NH1405\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -1379,6 +1381,7 @@
<EmbeddedResource Include="Any\Person.hbm.xml" />
<EmbeddedResource Include="Any\Properties.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1405\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1403\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1253\Mappings.hbm.xml" />
<EmbeddedResource Include="EntityModeTest\Map\Basic\ProductLine.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|