|
From: <dav...@us...> - 2008-12-03 20:06:22
|
Revision: 3943
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3943&view=rev
Author: davybrion
Date: 2008-12-03 20:06:17 +0000 (Wed, 03 Dec 2008)
Log Message:
-----------
applied patch for NH-1593
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1594/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1594/A.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1594/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1594/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2008-12-03 19:45:12 UTC (rev 3942)
+++ trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2008-12-03 20:06:17 UTC (rev 3943)
@@ -408,7 +408,7 @@
/// <returns>The database type name used by ddl.</returns>
public virtual string GetTypeName(SqlType sqlType)
{
- if (sqlType.LengthDefined)
+ if (sqlType.LengthDefined || sqlType.PrecisionDefined)
{
string resultWithLength = typeNames.Get(sqlType.DbType, sqlType.Length, sqlType.Precision, sqlType.Scale);
if (resultWithLength != null) return resultWithLength;
Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2008-12-03 19:45:12 UTC (rev 3942)
+++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2008-12-03 20:06:17 UTC (rev 3943)
@@ -65,6 +65,7 @@
// correctly with minimal work.
RegisterColumnType(DbType.Decimal, "DECIMAL(19,5)");
RegisterColumnType(DbType.Decimal, 19, "DECIMAL(19, $l)");
+ RegisterColumnType(DbType.Decimal, 19, "DECIMAL($p, $s)");
RegisterColumnType(DbType.Double, "DOUBLE PRECISION"); //synonym for FLOAT(53)
RegisterColumnType(DbType.Guid, "UNIQUEIDENTIFIER");
RegisterColumnType(DbType.Int16, "SMALLINT");
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1594/A.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1594/A.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1594/A.cs 2008-12-03 20:06:17 UTC (rev 3943)
@@ -0,0 +1,7 @@
+namespace NHibernate.Test.NHSpecificTest.NH1594
+{
+ public class A
+ {
+ public virtual decimal Foo { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1594/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1594/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1594/Fixture.cs 2008-12-03 20:06:17 UTC (rev 3943)
@@ -0,0 +1,28 @@
+using System.Reflection;
+using NHibernate.Cfg;
+using NHibernate.Dialect;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1594
+{
+ [TestFixture]
+ public class Fixture
+ {
+ [Test]
+ public void Bug()
+ {
+ Configuration cfg = new Configuration();
+ Assembly assembly = Assembly.GetExecutingAssembly();
+ cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1594.Mappings.hbm.xml", assembly);
+
+ string[] script = cfg.GenerateSchemaCreationScript(new MsSql2000Dialect());
+
+ bool found = string.Compare(
+ script[0],
+ "create table A (id INT IDENTITY NOT NULL, Foo DECIMAL(4, 2) null, primary key (id))",
+ true) == 0;
+
+ Assert.IsTrue(found, "when using decimal(precision,scale) Script should contain the correct create table statement");
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1594/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1594/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1594/Mappings.hbm.xml 2008-12-03 20:06:17 UTC (rev 3943)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1594">
+ <class name="A">
+ <id type="int">
+ <generator class="native"/>
+ </id>
+ <property name="Foo" type="Decimal(4,2)" />
+ </class>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-03 19:45:12 UTC (rev 3942)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-03 20:06:17 UTC (rev 3943)
@@ -532,6 +532,8 @@
<Compile Include="NHSpecificTest\NH1579\Orange.cs" />
<Compile Include="NHSpecificTest\NH1587\A.cs" />
<Compile Include="NHSpecificTest\NH1587\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1594\A.cs" />
+ <Compile Include="NHSpecificTest\NH1594\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -1552,6 +1554,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1594\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1579\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH298\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1587\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dav...@us...> - 2008-12-08 10:53:19
|
Revision: 3944
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3944&view=rev
Author: davybrion
Date: 2008-12-08 10:53:17 +0000 (Mon, 08 Dec 2008)
Log Message:
-----------
fix for NH-1593
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/TestIndex.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/TestIndex.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2008-12-03 20:06:17 UTC (rev 3943)
+++ trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2008-12-08 10:53:17 UTC (rev 3944)
@@ -1962,6 +1962,14 @@
}
}
}
+
+ foreach (var index in table.IndexIterator)
+ {
+ if (tableInfo == null || tableInfo.GetIndexMetadata(index.Name) == null)
+ {
+ script.Add(index.SqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
+ }
+ }
}
}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/Fixture.cs 2008-12-08 10:53:17 UTC (rev 3944)
@@ -0,0 +1,51 @@
+using System.Collections;
+using System.Data.Common;
+using System.Data.SqlClient;
+using System.Reflection;
+
+using NHibernate.Cfg;
+using NHibernate.Dialect;
+using NHibernate.Tool.hbm2ddl;
+
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1593
+{
+ [TestFixture]
+ public class Fixture
+ {
+ [Test]
+ public void SchemaUpdateAddsIndexesThatWerentPresentYet()
+ {
+ Configuration cfg = new Configuration();
+ Assembly assembly = Assembly.GetExecutingAssembly();
+ cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1593.TestIndex.hbm.xml", assembly);
+ cfg.Configure();
+
+ // TODO: rewrite this so we don't need to open a session just to get a reference to a DbConnection (because that's the only reason the Session is used)
+ var sessionFactory = cfg.BuildSessionFactory();
+ using (ISession session = sessionFactory.OpenSession())
+ {
+ MsSql2005Dialect dialect = new MsSql2005Dialect();
+
+ DatabaseMetadata databaseMetaData = new DatabaseMetadata((DbConnection)session.Connection, dialect);
+ string[] script = cfg.GenerateSchemaUpdateScript(dialect, databaseMetaData);
+
+ Assert.That(ScriptContainsIndexCreationLine(script));
+ }
+ }
+
+ private bool ScriptContainsIndexCreationLine(string[] script)
+ {
+ foreach (string s in script)
+ {
+ if (s.Equals("create index test_index_name on TestIndex (Name)"))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/TestIndex.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/TestIndex.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/TestIndex.cs 2008-12-08 10:53:17 UTC (rev 3944)
@@ -0,0 +1,20 @@
+namespace NHibernate.Test.NHSpecificTest.NH1593
+{
+ public class TestIndex
+ {
+ private int id;
+ private string name;
+
+ public int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/TestIndex.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/TestIndex.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/TestIndex.hbm.xml 2008-12-08 10:53:17 UTC (rev 3944)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NHibernate.Test.NHSpecificTest.NH1593" assembly="NHibernate.Test">
+ <class name="TestIndex" lazy="false">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ <property name="Name" index="test_index_name"/>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-03 20:06:17 UTC (rev 3943)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-08 10:53:17 UTC (rev 3944)
@@ -532,6 +532,8 @@
<Compile Include="NHSpecificTest\NH1579\Orange.cs" />
<Compile Include="NHSpecificTest\NH1587\A.cs" />
<Compile Include="NHSpecificTest\NH1587\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1593\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1593\TestIndex.cs" />
<Compile Include="NHSpecificTest\NH1594\A.cs" />
<Compile Include="NHSpecificTest\NH1594\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
@@ -1554,6 +1556,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1593\TestIndex.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1594\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1579\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH298\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2008-12-12 14:57:23
|
Revision: 3946
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3946&view=rev
Author: tehlike
Date: 2008-12-12 14:57:17 +0000 (Fri, 12 Dec 2008)
Log Message:
-----------
Another proposal for MsSql2005 Paging issue, by Dana Naideth
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs
trunk/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2008-12-12 14:40:38 UTC (rev 3945)
+++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2005Dialect.cs 2008-12-12 14:57:17 UTC (rev 3946)
@@ -29,12 +29,13 @@
/// The <c>LIMIT</c> SQL will look like
/// <code>
///
- /// SELECT TOP last (columns) FROM (
- /// SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_1__ {sort direction 1} [, __hibernate_sort_expr_2__ {sort direction 2}, ...]) as row, (query.columns) FROM (
- /// {original select query part}, {sort field 1} as __hibernate_sort_expr_1__ [, {sort field 2} as __hibernate_sort_expr_2__, ...]
- /// {remainder of original query minus the order by clause}
- /// ) query
- /// ) page WHERE page.row > offset
+ /// SELECT
+ /// TOP last (columns)
+ /// FROM
+ /// (SELECT (columns), ROW_NUMBER() OVER(ORDER BY {original order by, with un-aliased column names) as __hibernate_sort_row
+ /// {original from}) as query
+ /// WHERE query.__hibernate_sort_row > offset
+ /// ORDER BY query.__hibernate_sort_row
///
/// </code>
///
@@ -76,58 +77,26 @@
{
from = querySqlString.Substring(fromIndex).Trim();
// Use dummy sort to avoid errors
- sortExpressions = new[] { new SqlString("CURRENT_TIMESTAMP"), };
+ sortExpressions = new[] {new SqlString("CURRENT_TIMESTAMP"),};
}
SqlStringBuilder result =
- new SqlStringBuilder().Add("SELECT TOP ").Add(last.ToString()).Add(" ").Add(StringHelper.Join(", ", columnsOrAliases))
- .Add(" FROM (SELECT ROW_NUMBER() OVER(ORDER BY ");
+ new SqlStringBuilder()
+ .Add("SELECT TOP ")
+ .Add(last.ToString())
+ .Add(" ")
+ .Add(StringHelper.Join(", ", columnsOrAliases))
+ .Add(" FROM (")
+ .Add(select)
+ .Add(", ROW_NUMBER() OVER(ORDER BY ");
- AppendSortExpressions(columnsOrAliases, sortExpressions, result);
+ AppendSortExpressions(aliasToColumn, sortExpressions, result);
- result.Add(") as row, ");
-
- for (int i = 0; i < columnsOrAliases.Count; i++)
- {
- result.Add("query.").Add(columnsOrAliases[i]);
- bool notLastColumn = i != columnsOrAliases.Count - 1;
- if (notLastColumn)
- {
- result.Add(", ");
- }
- }
- for (int i = 0; i < sortExpressions.Length; i++)
- {
- SqlString sortExpression = RemoveSortOrderDirection(sortExpressions[i]);
- if (!columnsOrAliases.Contains(sortExpression))
- {
- result.Add(", query.__hibernate_sort_expr_").Add(i.ToString()).Add("__");
- }
- }
-
- result.Add(" FROM (").Add(select);
-
- for (int i = 0; i < sortExpressions.Length; i++)
- {
- SqlString sortExpression = RemoveSortOrderDirection(sortExpressions[i]);
-
- if (columnsOrAliases.Contains(sortExpression))
- {
- continue;
- }
-
- if (aliasToColumn.ContainsKey(sortExpression))
- {
- sortExpression = aliasToColumn[sortExpression];
- }
-
- result.Add(", ").Add(sortExpression).Add(" as __hibernate_sort_expr_").Add(i.ToString()).Add("__");
- }
-
- result.Add(" ").Add(from).Add(") query ) page WHERE page.row > ").Add(offset.ToString()).Add(" ORDER BY ");
-
- AppendSortExpressions(columnsOrAliases, sortExpressions, result);
-
+ result.Add(") as __hibernate_sort_row ")
+ .Add(from)
+ .Add(") as query WHERE query.__hibernate_sort_row > ")
+ .Add(offset.ToString()).Add(" ORDER BY query.__hibernate_sort_row");
+
return result.ToSqlString();
}
@@ -141,7 +110,7 @@
return trimmedExpression.Trim();
}
- private static void AppendSortExpressions(ICollection<SqlString> columnsOrAliases, SqlString[] sortExpressions,
+ private static void AppendSortExpressions(Dictionary<SqlString, SqlString> aliasToColumn, SqlString[] sortExpressions,
SqlStringBuilder result)
{
for (int i = 0; i < sortExpressions.Length; i++)
@@ -152,13 +121,13 @@
}
SqlString sortExpression = RemoveSortOrderDirection(sortExpressions[i]);
- if (columnsOrAliases.Contains(sortExpression))
+ if (aliasToColumn.ContainsKey(sortExpression))
{
- result.Add(sortExpression);
+ result.Add(aliasToColumn[sortExpression]);
}
else
{
- result.Add("__hibernate_sort_expr_").Add(i.ToString()).Add("__");
+ result.Add(sortExpression);
}
if (sortExpressions[i].Trim().EndsWithCaseInsensitive("desc"))
{
@@ -240,7 +209,7 @@
}
columnsOrAliases.Add(new SqlString(alias));
- aliasToColumn[new SqlString(alias)] = new SqlString(token);
+ aliasToColumn[SqlString.Parse(alias)] = SqlString.Parse(token);
}
}
@@ -443,3 +412,4 @@
}
}
}
+
Modified: trunk/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs 2008-12-12 14:40:38 UTC (rev 3945)
+++ trunk/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs 2008-12-12 14:57:17 UTC (rev 3946)
@@ -16,55 +16,65 @@
MsSql2005Dialect d = new MsSql2005Dialect();
SqlString str = d.GetLimitString(new SqlString("select distinct c.Contact_Id as Contact1_19_0_, c._Rating as Rating2_19_0_ from dbo.Contact c where COALESCE(c.Rating, 0) > 0 order by c.Rating desc , c.Last_Name , c.First_Name"), 0, 10);
+ System.Console.WriteLine(str);
Assert.AreEqual(
- "SELECT TOP 10 Contact1_19_0_, Rating2_19_0_ FROM (SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__ DESC, __hibernate_sort_expr_1__, __hibernate_sort_expr_2__) as row, query.Contact1_19_0_, query.Rating2_19_0_, query.__hibernate_sort_expr_0__, query.__hibernate_sort_expr_1__, query.__hibernate_sort_expr_2__ FROM (select distinct c.Contact_Id as Contact1_19_0_, c._Rating as Rating2_19_0_, c.Rating as __hibernate_sort_expr_0__, c.Last_Name as __hibernate_sort_expr_1__, c.First_Name as __hibernate_sort_expr_2__ from dbo.Contact c where COALESCE(c.Rating, 0) > 0) query ) page WHERE page.row > 0 ORDER BY __hibernate_sort_expr_0__ DESC, __hibernate_sort_expr_1__, __hibernate_sort_expr_2__",
+ "SELECT TOP 10 Contact1_19_0_, Rating2_19_0_ FROM (select distinct c.Contact_Id as Contact1_19_0_, c._Rating as Rating2_19_0_, ROW_NUMBER() OVER(ORDER BY c.Rating DESC, c.Last_Name, c.First_Name) as __hibernate_sort_row from dbo.Contact c where COALESCE(c.Rating, 0) > 0) as query WHERE query.__hibernate_sort_row > 0 ORDER BY query.__hibernate_sort_row",
str.ToString());
str = d.GetLimitString(new SqlString("SELECT fish.id FROM fish"), 0, 10);
+ System.Console.WriteLine(str);
Assert.AreEqual(
- "SELECT TOP 10 id FROM (SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__) as row, query.id, query.__hibernate_sort_expr_0__ FROM (SELECT fish.id, CURRENT_TIMESTAMP as __hibernate_sort_expr_0__ FROM fish) query ) page WHERE page.row > 0 ORDER BY __hibernate_sort_expr_0__",
+ "SELECT TOP 10 id FROM (SELECT fish.id, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish) as query WHERE query.__hibernate_sort_row > 0 ORDER BY query.__hibernate_sort_row",
str.ToString());
str = d.GetLimitString(new SqlString("SELECT DISTINCT fish_.id FROM fish fish_"), 0, 10);
+ System.Console.WriteLine(str);
Assert.AreEqual(
- "SELECT TOP 10 id FROM (SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__) as row, query.id, query.__hibernate_sort_expr_0__ FROM (SELECT DISTINCT fish_.id, CURRENT_TIMESTAMP as __hibernate_sort_expr_0__ FROM fish fish_) query ) page WHERE page.row > 0 ORDER BY __hibernate_sort_expr_0__",
+ "SELECT TOP 10 id FROM (SELECT DISTINCT fish_.id, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish fish_) as query WHERE query.__hibernate_sort_row > 0 ORDER BY query.__hibernate_sort_row",
str.ToString());
str = d.GetLimitString(new SqlString("SELECT DISTINCT fish_.id as ixx9_ FROM fish fish_"), 0, 10);
+ System.Console.WriteLine(str);
Assert.AreEqual(
- "SELECT TOP 10 ixx9_ FROM (SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__) as row, query.ixx9_, query.__hibernate_sort_expr_0__ FROM (SELECT DISTINCT fish_.id as ixx9_, CURRENT_TIMESTAMP as __hibernate_sort_expr_0__ FROM fish fish_) query ) page WHERE page.row > 0 ORDER BY __hibernate_sort_expr_0__",
+ "SELECT TOP 10 ixx9_ FROM (SELECT DISTINCT fish_.id as ixx9_, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish fish_) as query WHERE query.__hibernate_sort_row > 0 ORDER BY query.__hibernate_sort_row",
str.ToString());
str = d.GetLimitString(new SqlString("SELECT * FROM fish ORDER BY name"), 5, 15);
+ System.Console.WriteLine(str);
Assert.AreEqual(
- "SELECT TOP 15 * FROM (SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__) as row, query.*, query.__hibernate_sort_expr_0__ FROM (SELECT *, name as __hibernate_sort_expr_0__ FROM fish) query ) page WHERE page.row > 5 ORDER BY __hibernate_sort_expr_0__",
+ "SELECT TOP 15 * FROM (SELECT *, ROW_NUMBER() OVER(ORDER BY name) as __hibernate_sort_row FROM fish) as query WHERE query.__hibernate_sort_row > 5 ORDER BY query.__hibernate_sort_row",
str.ToString());
str = d.GetLimitString(new SqlString("SELECT fish.id, fish.name FROM fish ORDER BY name DESC"), 7, 28);
+ System.Console.WriteLine(str);
Assert.AreEqual(
- "SELECT TOP 28 id, name FROM (SELECT ROW_NUMBER() OVER(ORDER BY name DESC) as row, query.id, query.name FROM (SELECT fish.id, fish.name FROM fish) query ) page WHERE page.row > 7 ORDER BY name DESC",
+ "SELECT TOP 28 id, name FROM (SELECT fish.id, fish.name, ROW_NUMBER() OVER(ORDER BY fish.name DESC) as __hibernate_sort_row FROM fish) as query WHERE query.__hibernate_sort_row > 7 ORDER BY query.__hibernate_sort_row",
str.ToString());
str =
d.GetLimitString(
new SqlString("SELECT * FROM fish LEFT JOIN (SELECT * FROM meat ORDER BY weight) AS t ORDER BY name DESC"), 10, 20);
+ System.Console.WriteLine(str);
Assert.AreEqual(
- "SELECT TOP 20 * FROM (SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__ DESC) as row, query.*, query.__hibernate_sort_expr_0__ FROM (SELECT *, name as __hibernate_sort_expr_0__ FROM fish LEFT JOIN (SELECT * FROM meat ORDER BY weight) AS t) query ) page WHERE page.row > 10 ORDER BY __hibernate_sort_expr_0__ DESC",
+ "SELECT TOP 20 * FROM (SELECT *, ROW_NUMBER() OVER(ORDER BY name DESC) as __hibernate_sort_row FROM fish LEFT JOIN (SELECT * FROM meat ORDER BY weight) AS t) as query WHERE query.__hibernate_sort_row > 10 ORDER BY query.__hibernate_sort_row",
str.ToString());
str = d.GetLimitString(new SqlString("SELECT *, (SELECT COUNT(1) FROM fowl WHERE fish_id = fish.id) AS some_count FROM fish"), 0, 10);
+ System.Console.WriteLine(str);
Assert.AreEqual(
- "SELECT TOP 10 *, some_count FROM (SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__) as row, query.*, query.some_count, query.__hibernate_sort_expr_0__ FROM (SELECT *, (SELECT COUNT(1) FROM fowl WHERE fish_id = fish.id) AS some_count, CURRENT_TIMESTAMP as __hibernate_sort_expr_0__ FROM fish) query ) page WHERE page.row > 0 ORDER BY __hibernate_sort_expr_0__",
+ "SELECT TOP 10 *, some_count FROM (SELECT *, (SELECT COUNT(1) FROM fowl WHERE fish_id = fish.id) AS some_count, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish) as query WHERE query.__hibernate_sort_row > 0 ORDER BY query.__hibernate_sort_row",
str.ToString());
str = d.GetLimitString(new SqlString("SELECT * FROM fish WHERE scales = ", Parameter.Placeholder), 0, 10);
+ System.Console.WriteLine(str);
Assert.AreEqual(
- "SELECT TOP 10 * FROM (SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__) as row, query.*, query.__hibernate_sort_expr_0__ FROM (SELECT *, CURRENT_TIMESTAMP as __hibernate_sort_expr_0__ FROM fish WHERE scales = ?) query ) page WHERE page.row > 0 ORDER BY __hibernate_sort_expr_0__",
+ "SELECT TOP 10 * FROM (SELECT *, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish WHERE scales = ?) as query WHERE query.__hibernate_sort_row > 0 ORDER BY query.__hibernate_sort_row",
str.ToString());
str = d.GetLimitString(new SqlString("SELECT f.Type, COUNT(DISTINCT f.Name) AS Name FROM Fish f GROUP BY f.Type ORDER BY COUNT(DISTINCT f.Name)"), 0, 10);
+ System.Console.WriteLine(str);
Assert.AreEqual(
- "SELECT TOP 10 Type, Name FROM (SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__) as row, query.Type, query.Name, query.__hibernate_sort_expr_0__ FROM (SELECT f.Type, COUNT(DISTINCT f.Name) AS Name, COUNT(DISTINCT f.Name) as __hibernate_sort_expr_0__ FROM Fish f GROUP BY f.Type) query ) page WHERE page.row > 0 ORDER BY __hibernate_sort_expr_0__",
+ "SELECT TOP 10 Type, Name FROM (SELECT f.Type, COUNT(DISTINCT f.Name) AS Name, ROW_NUMBER() OVER(ORDER BY COUNT(DISTINCT f.Name)) as __hibernate_sort_row FROM Fish f GROUP BY f.Type) as query WHERE query.__hibernate_sort_row > 0 ORDER BY query.__hibernate_sort_row",
str.ToString());
}
@@ -74,13 +84,15 @@
MsSql2005Dialect d = new MsSql2005Dialect();
SqlString result =
d.GetLimitString(new SqlString("select concat(a.Description,', ', a.Description) as desc from Animal a"), 0, 10);
- Assert.AreEqual("SELECT TOP 10 desc FROM (SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__) as row, query.desc, query.__hibernate_sort_expr_0__ FROM (select concat(a.Description,', ', a.Description) as desc, CURRENT_TIMESTAMP as __hibernate_sort_expr_0__ from Animal a) query ) page WHERE page.row > 0 ORDER BY __hibernate_sort_expr_0__", result.ToString());
+ System.Console.WriteLine(result);
+ Assert.AreEqual("SELECT TOP 10 desc FROM (select concat(a.Description,', ', a.Description) as desc, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row from Animal a) as query WHERE query.__hibernate_sort_row > 0 ORDER BY query.__hibernate_sort_row", result.ToString());
// The test use the function "cast" because cast need the keyWork "as" too
SqlString str =
d.GetLimitString(new SqlString("SELECT fish.id, cast('astring, with,comma' as string) as bar FROM fish"), 0, 10);
+ System.Console.WriteLine(str);
Assert.AreEqual(
- "SELECT TOP 10 id, bar FROM (SELECT ROW_NUMBER() OVER(ORDER BY __hibernate_sort_expr_0__) as row, query.id, query.bar, query.__hibernate_sort_expr_0__ FROM (SELECT fish.id, cast('astring, with,comma' as string) as bar, CURRENT_TIMESTAMP as __hibernate_sort_expr_0__ FROM fish) query ) page WHERE page.row > 0 ORDER BY __hibernate_sort_expr_0__",
+ "SELECT TOP 10 id, bar FROM (SELECT fish.id, cast('astring, with,comma' as string) as bar, ROW_NUMBER() OVER(ORDER BY CURRENT_TIMESTAMP) as __hibernate_sort_row FROM fish) as query WHERE query.__hibernate_sort_row > 0 ORDER BY query.__hibernate_sort_row",
str.ToString());
}
[Test]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dav...@us...> - 2008-12-14 18:17:06
|
Revision: 3953
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3953&view=rev
Author: davybrion
Date: 2008-12-14 18:17:04 +0000 (Sun, 14 Dec 2008)
Log Message:
-----------
fix for NH-1608
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Util/LRUMap.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1608/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1608/Fixture.cs
Modified: trunk/nhibernate/src/NHibernate/Util/LRUMap.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/LRUMap.cs 2008-12-14 14:03:45 UTC (rev 3952)
+++ trunk/nhibernate/src/NHibernate/Util/LRUMap.cs 2008-12-14 18:17:04 UTC (rev 3953)
@@ -50,7 +50,7 @@
}
set
{
- base[key] = value;
+ Add(key, value);
}
}
@@ -68,7 +68,7 @@
}
}
- base.Add(key, value);
+ base[key] = value;
}
private void RemoveLRU()
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1608/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1608/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1608/Fixture.cs 2008-12-14 18:17:04 UTC (rev 3953)
@@ -0,0 +1,33 @@
+using NHibernate.Util;
+
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.NHSpecificTest.NH1608
+{
+ [TestFixture]
+ public class Fixture
+ {
+ [Test]
+ public void AddDoesBoundsChecking()
+ {
+ var map = new LRUMap(128);
+
+ for (int i = 0; i < 200; i++)
+ map.Add("str" + i, i);
+
+ Assert.That(map.Count, Is.EqualTo(128));
+ }
+
+ [Test]
+ public void IndexerDoesBoundsChecking()
+ {
+ var map = new LRUMap(128);
+
+ for (int i = 0; i < 200; i++)
+ map["str" + i] = i;
+
+ Assert.That(map.Count, Is.EqualTo(128));
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-14 14:03:45 UTC (rev 3952)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-14 18:17:04 UTC (rev 3953)
@@ -542,6 +542,7 @@
<Compile Include="NHSpecificTest\NH1593\TestIndex.cs" />
<Compile Include="NHSpecificTest\NH1594\A.cs" />
<Compile Include="NHSpecificTest\NH1594\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1608\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wo...@us...> - 2008-12-15 23:37:49
|
Revision: 3954
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3954&view=rev
Author: woil
Date: 2008-12-15 23:37:40 +0000 (Mon, 15 Dec 2008)
Log Message:
-----------
Fixes NH 1611, NH 1274.
1611 is an uncommon one-to-one mapping issue.
1274 fills requests for schema-action="none|drop|export|update|validate|all"
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs
trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
trunk/nhibernate/src/NHibernate/Mapping/Table.cs
trunk/nhibernate/src/NHibernate/Type/OneToOneType.cs
trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1274ExportExclude/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1274ExportExclude/Home.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1274ExportExclude/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1274ExportExclude/NH1274ExportExcludeFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1274ExportExclude/Person.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1611OneToOneIdentity/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1611OneToOneIdentity/Adjunct.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1611OneToOneIdentity/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1611OneToOneIdentity/NH1611OneToOneIdentityFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1611OneToOneIdentity/Primary.cs
trunk/nhibernate/src/NHibernate.Tool.HbmXsd/How to generate Hbm.generated.cs.txt
Modified: trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2008-12-14 18:17:04 UTC (rev 3953)
+++ trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2008-12-15 23:37:40 UTC (rev 3954)
@@ -671,11 +671,11 @@
{
foreach (var table in TableMappings)
{
- if (table.IsPhysicalTable)
+ if (table.IsPhysicalTable && table.SchemaDrop)
{
foreach (var fk in table.ForeignKeyIterator)
{
- if (fk.HasPhysicalConstraint)
+ if (fk.HasPhysicalConstraint && fk.ReferencedTable.SchemaDrop)
{
script.Add(fk.SqlDropString(dialect, defaultCatalog, defaultSchema));
}
@@ -686,7 +686,7 @@
foreach (var table in TableMappings)
{
- if (table.IsPhysicalTable)
+ if (table.IsPhysicalTable && table.SchemaDrop)
{
script.Add(table.SqlDropString(dialect, defaultCatalog, defaultSchema));
}
@@ -723,7 +723,7 @@
foreach (var table in TableMappings)
{
- if (table.IsPhysicalTable)
+ if (table.IsPhysicalTable && table.SchemaExport)
{
script.Add(table.SqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
script.AddRange(table.SqlCommentStrings(dialect, defaultCatalog, defaultSchema));
@@ -732,7 +732,7 @@
foreach (var table in TableMappings)
{
- if (table.IsPhysicalTable)
+ if (table.IsPhysicalTable && table.SchemaExport)
{
if (!dialect.SupportsUniqueConstraintInCreateAlterTable)
{
@@ -755,7 +755,7 @@
{
foreach (var fk in table.ForeignKeyIterator)
{
- if (fk.HasPhysicalConstraint)
+ if (fk.HasPhysicalConstraint && fk.ReferencedTable.SchemaExport)
{
script.Add(fk.SqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
}
@@ -790,6 +790,7 @@
foreach (var clazz in classes.Values)
{
clazz.Validate(mapping);
+
if (validateProxy)
{
ICollection<string> errors = ValidateProxyInterface(clazz, pvalidator);
@@ -1919,7 +1920,7 @@
var script = new List<string>(50);
foreach (var table in TableMappings)
{
- if (table.IsPhysicalTable)
+ if (table.IsPhysicalTable && table.SchemaUpdate)
{
ITableMetadata tableInfo = databaseMetadata.GetTableMetadata(table.Name, table.Schema ?? defaultSchema,
table.Catalog ?? defaultCatalog, table.IsQuoted);
@@ -1940,7 +1941,7 @@
foreach (var table in TableMappings)
{
- if (table.IsPhysicalTable)
+ if (table.IsPhysicalTable && table.SchemaUpdate)
{
ITableMetadata tableInfo = databaseMetadata.GetTableMetadata(table.Name, table.Schema, table.Catalog,
table.IsQuoted);
@@ -1949,7 +1950,7 @@
{
foreach (var fk in table.ForeignKeyIterator)
{
- if (fk.HasPhysicalConstraint)
+ if (fk.HasPhysicalConstraint && fk.ReferencedTable.SchemaUpdate)
{
bool create = tableInfo == null
||
@@ -1999,7 +2000,7 @@
var iter = this.TableMappings;
foreach (var table in iter)
{
- if (table.IsPhysicalTable)
+ if (table.IsPhysicalTable && table.SchemaValidate)
{
/*NH Different Implementation :
TableMetadata tableInfo = databaseMetadata.getTableMetadata(
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2008-12-14 18:17:04 UTC (rev 3953)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2008-12-15 23:37:40 UTC (rev 3954)
@@ -2,7 +2,7 @@
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -83,7 +83,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -110,7 +110,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -128,7 +128,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -193,7 +193,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -207,7 +207,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -372,7 +372,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -386,7 +386,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -413,7 +413,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmCacheUsage {
@@ -436,7 +436,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmCacheInclude {
@@ -451,7 +451,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -465,7 +465,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -524,7 +524,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmOndelete {
@@ -539,7 +539,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -565,7 +565,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -586,7 +586,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -618,7 +618,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -632,7 +632,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -770,7 +770,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -784,7 +784,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmOuterJoinStrategy {
@@ -803,7 +803,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmFetchMode {
@@ -818,7 +818,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmLaziness {
@@ -837,7 +837,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmNotFoundMode {
@@ -852,7 +852,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -888,7 +888,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1005,7 +1005,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1023,7 +1023,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1041,7 +1041,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmPropertyGeneration {
@@ -1060,7 +1060,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1121,7 +1121,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1151,7 +1151,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1255,7 +1255,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1277,7 +1277,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmRestrictedLaziness {
@@ -1292,7 +1292,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1329,7 +1329,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1343,7 +1343,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1373,7 +1373,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmCustomSQLCheck {
@@ -1392,7 +1392,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmCollectionFetchMode {
@@ -1411,7 +1411,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1591,7 +1591,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmCollectionLazy {
@@ -1610,7 +1610,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1729,6 +1729,10 @@
public bool lazySpecified;
/// <remarks/>
+ [System.Xml.Serialization.XmlAttributeAttribute("schema-action")]
+ public string schemaaction;
+
+ /// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string table;
@@ -1825,7 +1829,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1847,7 +1851,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmTuplizerEntitymode {
@@ -1866,7 +1870,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1916,7 +1920,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -1966,7 +1970,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2011,7 +2015,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmUnsavedValueType {
@@ -2030,7 +2034,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2082,7 +2086,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2100,7 +2104,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2154,7 +2158,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2181,7 +2185,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2266,7 +2270,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2330,7 +2334,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2515,7 +2519,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2709,7 +2713,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2728,7 +2732,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2747,7 +2751,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2773,7 +2777,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2803,7 +2807,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2838,7 +2842,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2873,7 +2877,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -2966,7 +2970,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
@@ -3108,7 +3112,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")]
public enum HbmPrimitivearrayOuterjoin {
@@ -3127,7 +3131,7 @@
}
/// <remarks/>
- [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.0.0.1001")]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")]
public...
[truncated message content] |
|
From: <fab...@us...> - 2008-12-16 15:39:43
|
Revision: 3956
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3956&view=rev
Author: fabiomaulo
Date: 2008-12-16 15:39:36 +0000 (Tue, 16 Dec 2008)
Log Message:
-----------
- Fixed problem with NH-1593 test
- starting fix NH-1613
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/Fixture.cs
Modified: trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs 2008-12-16 04:26:06 UTC (rev 3955)
+++ trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs 2008-12-16 15:39:36 UTC (rev 3956)
@@ -11,7 +11,7 @@
public class SchemaUpdate
{
- private static readonly ILog log = LogManager.GetLogger(typeof (SchemaUpdate));
+ private static readonly ILog log = LogManager.GetLogger(typeof(SchemaUpdate));
private readonly IConnectionHelper connectionHelper;
private readonly Configuration configuration;
private readonly Dialect.Dialect dialect;
@@ -80,7 +80,7 @@
else if (args[i].StartsWith("--naming="))
{
cfg.SetNamingStrategy(
- (INamingStrategy) Activator.CreateInstance(ReflectHelper.ClassForName(args[i].Substring(9)))
+ (INamingStrategy)Activator.CreateInstance(ReflectHelper.ClassForName(args[i].Substring(9)))
);
}
}
@@ -112,6 +112,23 @@
/// </summary>
public void Execute(bool script, bool doUpdate)
{
+ if (script)
+ {
+ Execute(Console.WriteLine, doUpdate);
+ }
+ else
+ {
+ Execute(null, doUpdate);
+ }
+ }
+
+ /// <summary>
+ /// Execute the schema updates
+ /// </summary>
+ /// <param name="scriptAction">The action to write the each schema line.</param>
+ /// <param name="doUpdate">Commit the script to DB</param>
+ public void Execute(Action<string> scriptAction, bool doUpdate)
+ {
log.Info("Running hbm2ddl schema update");
DbConnection connection;
@@ -145,9 +162,9 @@
string sql = createSQL[j];
try
{
- if (script)
+ if (scriptAction != null)
{
- Console.WriteLine(sql);
+ scriptAction(sql);
}
if (doUpdate)
{
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/Fixture.cs 2008-12-16 04:26:06 UTC (rev 3955)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1593/Fixture.cs 2008-12-16 15:39:36 UTC (rev 3956)
@@ -1,13 +1,9 @@
-using System.Collections;
-using System.Data.Common;
-using System.Data.SqlClient;
-using System.Reflection;
-
+using System.Text;
using NHibernate.Cfg;
-using NHibernate.Dialect;
using NHibernate.Tool.hbm2ddl;
using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
namespace NHibernate.Test.NHSpecificTest.NH1593
{
@@ -17,35 +13,12 @@
[Test]
public void SchemaUpdateAddsIndexesThatWerentPresentYet()
{
- Configuration cfg = new Configuration();
- Assembly assembly = Assembly.GetExecutingAssembly();
- cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1593.TestIndex.hbm.xml", assembly);
- cfg.Configure();
-
- // TODO: rewrite this so we don't need to open a session just to get a reference to a DbConnection (because that's the only reason the Session is used)
- var sessionFactory = cfg.BuildSessionFactory();
- using (ISession session = sessionFactory.OpenSession())
- {
- MsSql2005Dialect dialect = new MsSql2005Dialect();
-
- DatabaseMetadata databaseMetaData = new DatabaseMetadata((DbConnection)session.Connection, dialect);
- string[] script = cfg.GenerateSchemaUpdateScript(dialect, databaseMetaData);
-
- Assert.That(ScriptContainsIndexCreationLine(script));
- }
+ Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
+ cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1593.TestIndex.hbm.xml", GetType().Assembly);
+ var su = new SchemaUpdate(cfg);
+ var sb = new StringBuilder(500);
+ su.Execute(x => sb.AppendLine(x), false);
+ Assert.That(sb.ToString(), Text.Contains("create index test_index_name on TestIndex (Name)"));
}
-
- private bool ScriptContainsIndexCreationLine(string[] script)
- {
- foreach (string s in script)
- {
- if (s.Equals("create index test_index_name on TestIndex (Name)"))
- {
- return true;
- }
- }
-
- return false;
- }
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2008-12-16 18:39:22
|
Revision: 3958
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3958&view=rev
Author: fabiomaulo
Date: 2008-12-16 18:39:12 +0000 (Tue, 16 Dec 2008)
Log Message:
-----------
- Fix NH-1443
- prevent another bug on PK
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
trunk/nhibernate/src/NHibernate/Mapping/PrimaryKey.cs
trunk/nhibernate/src/NHibernate/Mapping/Table.cs
trunk/nhibernate/src/NHibernate.Test/MappingTest/TableFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithDefault.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithNothing.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithSpecific.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/Fixture.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs 2008-12-16 16:17:49 UTC (rev 3957)
+++ trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs 2008-12-16 18:39:12 UTC (rev 3958)
@@ -289,6 +289,7 @@
Table table = new DenormalizedTable(includedTable);
table.IsAbstract = isAbstract;
table.Name = name;
+ table.Catalog = catalog;
table.Schema = schema;
table.Subselect = subselect;
tables[key] = table;
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs 2008-12-16 16:17:49 UTC (rev 3957)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs 2008-12-16 18:39:12 UTC (rev 3958)
@@ -44,6 +44,7 @@
private void SetMappingsProperties(HbmMapping mappingSchema)
{
mappings.SchemaName = mappingSchema.schema;
+ mappings.CatalogName = mappingSchema.catalog;
mappings.DefaultCascade = mappingSchema.defaultcascade;
mappings.DefaultAccess = mappingSchema.defaultaccess;
mappings.DefaultLazy = mappingSchema.defaultlazy;
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2008-12-16 16:17:49 UTC (rev 3957)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2008-12-16 18:39:12 UTC (rev 3958)
@@ -20,7 +20,7 @@
//TABLENAME
string schema = classSchema.schema ?? mappings.SchemaName;
- string catalog = mappings.CatalogName; //string catalog = classSchema.catalog ?? mappings.CatalogName;
+ string catalog = classSchema.catalog ?? mappings.CatalogName;
string tableName = GetClassTableName(rootClass, classSchema);
if (string.IsNullOrEmpty(tableName))
{
Modified: trunk/nhibernate/src/NHibernate/Mapping/PrimaryKey.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/PrimaryKey.cs 2008-12-16 16:17:49 UTC (rev 3957)
+++ trunk/nhibernate/src/NHibernate/Mapping/PrimaryKey.cs 2008-12-16 18:39:12 UTC (rev 3958)
@@ -76,7 +76,7 @@
public override string SqlDropString(Dialect.Dialect dialect, string defaultCatalog, string defaultSchema)
{
string ifExists = dialect.GetIfExistsDropConstraint(Table, Name);
- string drop = string.Format("alter table {0}{1}", Table.GetQualifiedName(dialect, defaultSchema), dialect.GetDropPrimaryKeyConstraintString(Name));
+ string drop = string.Format("alter table {0}{1}", Table.GetQualifiedName(dialect, defaultCatalog, defaultSchema), dialect.GetDropPrimaryKeyConstraintString(Name));
string end = dialect.GetIfExistsDropConstraintEnd(Table, Name);
return ifExists + Environment.NewLine + drop + Environment.NewLine + end;
}
Modified: trunk/nhibernate/src/NHibernate/Mapping/Table.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/Table.cs 2008-12-16 16:17:49 UTC (rev 3957)
+++ trunk/nhibernate/src/NHibernate/Mapping/Table.cs 2008-12-16 18:39:12 UTC (rev 3958)
@@ -118,14 +118,10 @@
/// Gets the schema qualified name of the Table using the specified qualifier
/// </summary>
/// <param name="dialect">The <see cref="Dialect"/> that knows how to Quote the Table name.</param>
- /// <param name="defaultQualifier">The Qualifier to use when accessing the table.</param>
+ /// <param name="defaultCatalog">The catalog name.</param>
+ /// <param name="defaultSchema">The schema name.</param>
/// <returns>A String representing the Qualified name.</returns>
/// <remarks>If this were used with MSSQL it would return a dbo.table_name.</remarks>
- public string GetQualifiedName(Dialect.Dialect dialect, string defaultQualifier)
- {
- return GetQualifiedName(dialect, null, defaultQualifier);
- }
-
public virtual string GetQualifiedName(Dialect.Dialect dialect, string defaultCatalog, string defaultSchema)
{
if (!string.IsNullOrEmpty(subselect))
@@ -410,7 +406,7 @@
dialect.CreateTableString
: dialect.CreateMultisetTableString)
.Append(' ')
- .Append(GetQualifiedName(dialect, defaultSchema))
+ .Append(GetQualifiedName(dialect, defaultCatalog, defaultSchema))
.Append(" (");
bool identityColumn = idValue != null && idValue.IsIdentityColumn(dialect);
Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/TableFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingTest/TableFixture.cs 2008-12-16 16:17:49 UTC (rev 3957)
+++ trunk/nhibernate/src/NHibernate.Test/MappingTest/TableFixture.cs 2008-12-16 18:39:12 UTC (rev 3958)
@@ -20,9 +20,9 @@
Assert.AreEqual("[keyword]", tbl.GetQuotedName(dialect));
- Assert.AreEqual("dbo.[keyword]", tbl.GetQualifiedName(dialect, "dbo"));
+ Assert.AreEqual("dbo.[keyword]", tbl.GetQualifiedName(dialect, null, "dbo"));
- Assert.AreEqual("[keyword]", tbl.GetQualifiedName(dialect, null));
+ Assert.AreEqual("[keyword]", tbl.GetQualifiedName(dialect, null, null));
tbl.Schema = "sch";
@@ -39,9 +39,9 @@
Assert.AreEqual("notkeyword", tbl.GetQuotedName(dialect));
- Assert.AreEqual("dbo.notkeyword", tbl.GetQualifiedName(dialect, "dbo"));
+ Assert.AreEqual("dbo.notkeyword", tbl.GetQualifiedName(dialect, null, "dbo"));
- Assert.AreEqual("notkeyword", tbl.GetQualifiedName(dialect, null));
+ Assert.AreEqual("notkeyword", tbl.GetQualifiedName(dialect, null, null));
tbl.Schema = "sch";
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithDefault.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithDefault.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithDefault.hbm.xml 2008-12-16 18:39:12 UTC (rev 3958)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1443"
+ assembly="NHibernate.Test"
+ catalog="nhibernate"
+ schema="dbo">
+
+ <class name="Aclass">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ </class>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithNothing.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithNothing.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithNothing.hbm.xml 2008-12-16 18:39:12 UTC (rev 3958)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1443"
+ assembly="NHibernate.Test">
+
+ <class name="Aclass">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ </class>
+</hibernate-mapping>
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithNothing.hbm.xml
___________________________________________________________________
Added: svn:mergeinfo
+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithSpecific.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithSpecific.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithSpecific.hbm.xml 2008-12-16 18:39:12 UTC (rev 3958)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1443"
+ assembly="NHibernate.Test"
+ catalog="somethingDifferent"
+ schema="somethingDifferent">
+
+ <class name="Aclass" catalog="nhibernate" schema="dbo">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ </class>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/Fixture.cs 2008-12-16 18:39:12 UTC (rev 3958)
@@ -0,0 +1,63 @@
+using System.Text;
+using NHibernate.Cfg;
+using NHibernate.Tool.hbm2ddl;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.NHSpecificTest.NH1443
+{
+ [TestFixture]
+ public class Fixture
+ {
+ private static void Bug(Configuration cfg)
+ {
+ var su = new SchemaExport(cfg);
+ var sb = new StringBuilder(500);
+ su.Execute(x => sb.AppendLine(x), false, false, true);
+ string script = sb.ToString();
+ Assert.That(script, Text.Contains("drop table nhibernate.dbo.Aclass"));
+ Assert.That(script, Text.Contains("create table nhibernate.dbo.Aclass"));
+ }
+
+ [Test]
+ public void WithDefaultValuesInConfiguration()
+ {
+ Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
+ cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1443.AclassWithNothing.hbm.xml", GetType().Assembly);
+ cfg.SetProperty(Environment.DefaultCatalog, "nhibernate");
+ cfg.SetProperty(Environment.DefaultSchema, "dbo");
+ Bug(cfg);
+ }
+
+ [Test]
+ public void WithDefaultValuesInMapping()
+ {
+ Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
+ cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1443.AclassWithDefault.hbm.xml", GetType().Assembly);
+ Bug(cfg);
+ }
+
+ [Test]
+ public void WithSpecificValuesInMapping()
+ {
+ Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
+ cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1443.AclassWithSpecific.hbm.xml", GetType().Assembly);
+ Bug(cfg);
+ }
+
+ [Test]
+ public void WithDefaultValuesInConfigurationPriorityToMapping()
+ {
+ Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
+ cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1443.AclassWithDefault.hbm.xml", GetType().Assembly);
+ cfg.SetProperty(Environment.DefaultCatalog, "somethingDifferent");
+ cfg.SetProperty(Environment.DefaultSchema, "somethingDifferent");
+ Bug(cfg);
+ }
+ }
+
+ public class Aclass
+ {
+ public int Id { get; set; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-16 16:17:49 UTC (rev 3957)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-16 18:39:12 UTC (rev 3958)
@@ -376,6 +376,7 @@
<Compile Include="NHSpecificTest\NH1274ExportExclude\Home.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\NH1274ExportExcludeFixture.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\Person.cs" />
+ <Compile Include="NHSpecificTest\NH1443\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1611OneToOneIdentity\Adjunct.cs" />
<Compile Include="NHSpecificTest\NH1611OneToOneIdentity\NH1611OneToOneIdentityFixture.cs" />
<Compile Include="NHSpecificTest\NH1611OneToOneIdentity\Primary.cs" />
@@ -1569,6 +1570,9 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1443\AclassWithSpecific.hbm.xml" />
+ <EmbeddedResource Include="NHSpecificTest\NH1443\AclassWithDefault.hbm.xml" />
+ <EmbeddedResource Include="NHSpecificTest\NH1443\AclassWithNothing.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1274ExportExclude\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1611OneToOneIdentity\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1533\Mappings.hbm.xml" />
@@ -1669,4 +1673,4 @@
if exist "$(ProjectDir)hibernate.cfg.xml" (copy "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml")
copy /y "..\..\..\NHibernate.DomainModel\ABC.hbm.xml" "ABC.hbm.xml"</PostBuildEvent>
</PropertyGroup>
-</Project>
+</Project>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: T. T. <te...@gm...> - 2008-12-16 18:42:07
|
Great! I'm glad you noticed the code piece for validate thing. On Tue, Dec 16, 2008 at 8:39 PM, <fab...@us...> wrote: > Revision: 3958 > > http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3958&view=rev > Author: fabiomaulo > Date: 2008-12-16 18:39:12 +0000 (Tue, 16 Dec 2008) > > Log Message: > ----------- > - Fix NH-1443 > - prevent another bug on PK > > Modified Paths: > -------------- > trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs > trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs > trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs > trunk/nhibernate/src/NHibernate/Mapping/PrimaryKey.cs > trunk/nhibernate/src/NHibernate/Mapping/Table.cs > trunk/nhibernate/src/NHibernate.Test/MappingTest/TableFixture.cs > trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj > > Added Paths: > ----------- > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/ > > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithDefault.hbm.xml > > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithNothing.hbm.xml > > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithSpecific.hbm.xml > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/Fixture.cs > > Modified: trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs 2008-12-16 16:17:49 > UTC (rev 3957) > +++ trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs 2008-12-16 18:39:12 > UTC (rev 3958) > @@ -289,6 +289,7 @@ > Table table = new DenormalizedTable(includedTable); > table.IsAbstract = isAbstract; > table.Name = name; > + table.Catalog = catalog; > table.Schema = schema; > table.Subselect = subselect; > tables[key] = table; > > Modified: > trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs > 2008-12-16 16:17:49 UTC (rev 3957) > +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs > 2008-12-16 18:39:12 UTC (rev 3958) > @@ -44,6 +44,7 @@ > private void SetMappingsProperties(HbmMapping mappingSchema) > { > mappings.SchemaName = mappingSchema.schema; > + mappings.CatalogName = mappingSchema.catalog; > mappings.DefaultCascade = > mappingSchema.defaultcascade; > mappings.DefaultAccess = > mappingSchema.defaultaccess; > mappings.DefaultLazy = mappingSchema.defaultlazy; > > Modified: > trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs > 2008-12-16 16:17:49 UTC (rev 3957) > +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs > 2008-12-16 18:39:12 UTC (rev 3958) > @@ -20,7 +20,7 @@ > > //TABLENAME > string schema = classSchema.schema ?? > mappings.SchemaName; > - string catalog = mappings.CatalogName; //string > catalog = classSchema.catalog ?? mappings.CatalogName; > + string catalog = classSchema.catalog ?? > mappings.CatalogName; > string tableName = GetClassTableName(rootClass, > classSchema); > if (string.IsNullOrEmpty(tableName)) > { > > Modified: trunk/nhibernate/src/NHibernate/Mapping/PrimaryKey.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/Mapping/PrimaryKey.cs 2008-12-16 > 16:17:49 UTC (rev 3957) > +++ trunk/nhibernate/src/NHibernate/Mapping/PrimaryKey.cs 2008-12-16 > 18:39:12 UTC (rev 3958) > @@ -76,7 +76,7 @@ > public override string SqlDropString(Dialect.Dialect > dialect, string defaultCatalog, string defaultSchema) > { > string ifExists = > dialect.GetIfExistsDropConstraint(Table, Name); > - string drop = string.Format("alter table {0}{1}", > Table.GetQualifiedName(dialect, defaultSchema), > dialect.GetDropPrimaryKeyConstraintString(Name)); > + string drop = string.Format("alter table {0}{1}", > Table.GetQualifiedName(dialect, defaultCatalog, defaultSchema), > dialect.GetDropPrimaryKeyConstraintString(Name)); > string end = > dialect.GetIfExistsDropConstraintEnd(Table, Name); > return ifExists + Environment.NewLine + drop + > Environment.NewLine + end; > } > > Modified: trunk/nhibernate/src/NHibernate/Mapping/Table.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/Mapping/Table.cs 2008-12-16 16:17:49 > UTC (rev 3957) > +++ trunk/nhibernate/src/NHibernate/Mapping/Table.cs 2008-12-16 18:39:12 > UTC (rev 3958) > @@ -118,14 +118,10 @@ > /// Gets the schema qualified name of the Table using the > specified qualifier > /// </summary> > /// <param name="dialect">The <see cref="Dialect"/> that > knows how to Quote the Table name.</param> > - /// <param name="defaultQualifier">The Qualifier to use > when accessing the table.</param> > + /// <param name="defaultCatalog">The catalog name.</param> > + /// <param name="defaultSchema">The schema name.</param> > /// <returns>A String representing the Qualified > name.</returns> > /// <remarks>If this were used with MSSQL it would return a > dbo.table_name.</remarks> > - public string GetQualifiedName(Dialect.Dialect dialect, > string defaultQualifier) > - { > - return GetQualifiedName(dialect, null, > defaultQualifier); > - } > - > public virtual string GetQualifiedName(Dialect.Dialect > dialect, string defaultCatalog, string defaultSchema) > { > if (!string.IsNullOrEmpty(subselect)) > @@ -410,7 +406,7 @@ > > dialect.CreateTableString > : > dialect.CreateMultisetTableString) > .Append(' ') > - .Append(GetQualifiedName(dialect, > defaultSchema)) > + .Append(GetQualifiedName(dialect, > defaultCatalog, defaultSchema)) > .Append(" ("); > > bool identityColumn = idValue != null && > idValue.IsIdentityColumn(dialect); > > Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/TableFixture.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate.Test/MappingTest/TableFixture.cs > 2008-12-16 16:17:49 UTC (rev 3957) > +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/TableFixture.cs > 2008-12-16 18:39:12 UTC (rev 3958) > @@ -20,9 +20,9 @@ > > Assert.AreEqual("[keyword]", > tbl.GetQuotedName(dialect)); > > - Assert.AreEqual("dbo.[keyword]", > tbl.GetQualifiedName(dialect, "dbo")); > + Assert.AreEqual("dbo.[keyword]", > tbl.GetQualifiedName(dialect, null, "dbo")); > > - Assert.AreEqual("[keyword]", > tbl.GetQualifiedName(dialect, null)); > + Assert.AreEqual("[keyword]", > tbl.GetQualifiedName(dialect, null, null)); > > tbl.Schema = "sch"; > > @@ -39,9 +39,9 @@ > > Assert.AreEqual("notkeyword", > tbl.GetQuotedName(dialect)); > > - Assert.AreEqual("dbo.notkeyword", > tbl.GetQualifiedName(dialect, "dbo")); > + Assert.AreEqual("dbo.notkeyword", > tbl.GetQualifiedName(dialect, null, "dbo")); > > - Assert.AreEqual("notkeyword", > tbl.GetQualifiedName(dialect, null)); > + Assert.AreEqual("notkeyword", > tbl.GetQualifiedName(dialect, null, null)); > > tbl.Schema = "sch"; > > > Added: > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithDefault.hbm.xml > =================================================================== > --- > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithDefault.hbm.xml > (rev 0) > +++ > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithDefault.hbm.xml > 2008-12-16 18:39:12 UTC (rev 3958) > @@ -0,0 +1,13 @@ > +<?xml version="1.0" encoding="utf-8" ?> > +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > + > namespace="NHibernate.Test.NHSpecificTest.NH1443" > + assembly="NHibernate.Test" > + catalog="nhibernate" > + schema="dbo"> > + > + <class name="Aclass"> > + <id name="Id"> > + <generator class="native"/> > + </id> > + </class> > +</hibernate-mapping> > > Added: > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithNothing.hbm.xml > =================================================================== > --- > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithNothing.hbm.xml > (rev 0) > +++ > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithNothing.hbm.xml > 2008-12-16 18:39:12 UTC (rev 3958) > @@ -0,0 +1,11 @@ > +<?xml version="1.0" encoding="utf-8" ?> > +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > + > namespace="NHibernate.Test.NHSpecificTest.NH1443" > + assembly="NHibernate.Test"> > + > + <class name="Aclass"> > + <id name="Id"> > + <generator class="native"/> > + </id> > + </class> > +</hibernate-mapping> > > > Property changes on: > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithNothing.hbm.xml > ___________________________________________________________________ > Added: svn:mergeinfo > + > > Added: > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithSpecific.hbm.xml > =================================================================== > --- > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithSpecific.hbm.xml > (rev 0) > +++ > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithSpecific.hbm.xml > 2008-12-16 18:39:12 UTC (rev 3958) > @@ -0,0 +1,13 @@ > +<?xml version="1.0" encoding="utf-8" ?> > +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > + > namespace="NHibernate.Test.NHSpecificTest.NH1443" > + assembly="NHibernate.Test" > + catalog="somethingDifferent" > + schema="somethingDifferent"> > + > + <class name="Aclass" catalog="nhibernate" schema="dbo"> > + <id name="Id"> > + <generator class="native"/> > + </id> > + </class> > +</hibernate-mapping> > > Added: > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/Fixture.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/Fixture.cs > (rev 0) > +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/Fixture.cs > 2008-12-16 18:39:12 UTC (rev 3958) > @@ -0,0 +1,63 @@ > +using System.Text; > +using NHibernate.Cfg; > +using NHibernate.Tool.hbm2ddl; > +using NUnit.Framework; > +using NUnit.Framework.SyntaxHelpers; > + > +namespace NHibernate.Test.NHSpecificTest.NH1443 > +{ > + [TestFixture] > + public class Fixture > + { > + private static void Bug(Configuration cfg) > + { > + var su = new SchemaExport(cfg); > + var sb = new StringBuilder(500); > + su.Execute(x => sb.AppendLine(x), false, false, > true); > + string script = sb.ToString(); > + Assert.That(script, Text.Contains("drop table > nhibernate.dbo.Aclass")); > + Assert.That(script, Text.Contains("create table > nhibernate.dbo.Aclass")); > + } > + > + [Test] > + public void WithDefaultValuesInConfiguration() > + { > + Configuration cfg = > TestConfigurationHelper.GetDefaultConfiguration(); > + > cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1443.AclassWithNothing.hbm.xml", > GetType().Assembly); > + cfg.SetProperty(Environment.DefaultCatalog, > "nhibernate"); > + cfg.SetProperty(Environment.DefaultSchema, "dbo"); > + Bug(cfg); > + } > + > + [Test] > + public void WithDefaultValuesInMapping() > + { > + Configuration cfg = > TestConfigurationHelper.GetDefaultConfiguration(); > + > cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1443.AclassWithDefault.hbm.xml", > GetType().Assembly); > + Bug(cfg); > + } > + > + [Test] > + public void WithSpecificValuesInMapping() > + { > + Configuration cfg = > TestConfigurationHelper.GetDefaultConfiguration(); > + > cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1443.AclassWithSpecific.hbm.xml", > GetType().Assembly); > + Bug(cfg); > + } > + > + [Test] > + public void > WithDefaultValuesInConfigurationPriorityToMapping() > + { > + Configuration cfg = > TestConfigurationHelper.GetDefaultConfiguration(); > + > cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1443.AclassWithDefault.hbm.xml", > GetType().Assembly); > + cfg.SetProperty(Environment.DefaultCatalog, > "somethingDifferent"); > + cfg.SetProperty(Environment.DefaultSchema, > "somethingDifferent"); > + Bug(cfg); > + } > + } > + > + public class Aclass > + { > + public int Id { get; set; } > + } > +} > \ No newline at end of file > > Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj > =================================================================== > --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-16 > 16:17:49 UTC (rev 3957) > +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-16 > 18:39:12 UTC (rev 3958) > @@ -376,6 +376,7 @@ > <Compile Include="NHSpecificTest\NH1274ExportExclude\Home.cs" /> > <Compile > Include="NHSpecificTest\NH1274ExportExclude\NH1274ExportExcludeFixture.cs" > /> > <Compile Include="NHSpecificTest\NH1274ExportExclude\Person.cs" /> > + <Compile Include="NHSpecificTest\NH1443\Fixture.cs" /> > <Compile Include="NHSpecificTest\NH1611OneToOneIdentity\Adjunct.cs" /> > <Compile > Include="NHSpecificTest\NH1611OneToOneIdentity\NH1611OneToOneIdentityFixture.cs" > /> > <Compile Include="NHSpecificTest\NH1611OneToOneIdentity\Primary.cs" /> > @@ -1569,6 +1570,9 @@ > <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> > <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> > <Content Include="DynamicEntity\package.html" /> > + <EmbeddedResource > Include="NHSpecificTest\NH1443\AclassWithSpecific.hbm.xml" /> > + <EmbeddedResource > Include="NHSpecificTest\NH1443\AclassWithDefault.hbm.xml" /> > + <EmbeddedResource > Include="NHSpecificTest\NH1443\AclassWithNothing.hbm.xml" /> > <EmbeddedResource > Include="NHSpecificTest\NH1274ExportExclude\Mappings.hbm.xml" /> > <EmbeddedResource > Include="NHSpecificTest\NH1611OneToOneIdentity\Mappings.hbm.xml" /> > <EmbeddedResource Include="NHSpecificTest\NH1533\Mappings.hbm.xml" /> > @@ -1669,4 +1673,4 @@ > if exist "$(ProjectDir)hibernate.cfg.xml" (copy > "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml") > copy /y "..\..\..\NHibernate.DomainModel\ABC.hbm.xml" > "ABC.hbm.xml"</PostBuildEvent> > </PropertyGroup> > -</Project> > +</Project> > \ No newline at end of file > > > This was sent by the SourceForge.net collaborative development platform, > the world's largest Open Source development site. > > > ------------------------------------------------------------------------------ > SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. > The future of the web can't happen without you. Join us at MIX09 to help > pave the way to the Next Web now. Learn more and register at > > http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ > _______________________________________________ > Nhibernate-commit mailing list > Nhi...@li... > https://lists.sourceforge.net/lists/listinfo/nhibernate-commit > -- Tuna Toksöz http://tunatoksoz.com Typos included to enhance the readers attention! |
|
From: <fab...@us...> - 2008-12-16 20:16:20
|
Revision: 3959
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3959&view=rev
Author: fabiomaulo
Date: 2008-12-16 20:16:16 +0000 (Tue, 16 Dec 2008)
Log Message:
-----------
Refactoring of SchemaAction matters
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs
trunk/nhibernate/src/NHibernate/Mapping/Table.cs
trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs
trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs
trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaValidator.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2008-12-16 18:39:12 UTC (rev 3958)
+++ trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2008-12-16 20:16:16 UTC (rev 3959)
@@ -671,11 +671,11 @@
{
foreach (var table in TableMappings)
{
- if (table.IsPhysicalTable && table.SchemaDrop)
+ if (table.IsPhysicalTable && IncludeAction(table.SchemaActions, SchemaAction.Drop))
{
foreach (var fk in table.ForeignKeyIterator)
{
- if (fk.HasPhysicalConstraint && fk.ReferencedTable.SchemaDrop)
+ if (fk.HasPhysicalConstraint && IncludeAction(fk.ReferencedTable.SchemaActions, SchemaAction.Drop))
{
script.Add(fk.SqlDropString(dialect, defaultCatalog, defaultSchema));
}
@@ -686,7 +686,7 @@
foreach (var table in TableMappings)
{
- if (table.IsPhysicalTable && table.SchemaDrop)
+ if (table.IsPhysicalTable && IncludeAction(table.SchemaActions, SchemaAction.Drop))
{
script.Add(table.SqlDropString(dialect, defaultCatalog, defaultSchema));
}
@@ -708,6 +708,11 @@
return script.ToArray();
}
+ public static bool IncludeAction(SchemaAction actionsSource, SchemaAction includedAction)
+ {
+ return (actionsSource & includedAction) != SchemaAction.None;
+ }
+
/// <summary>
/// Generate DDL for creating tables
/// </summary>
@@ -723,7 +728,7 @@
foreach (var table in TableMappings)
{
- if (table.IsPhysicalTable && table.SchemaExport)
+ if (table.IsPhysicalTable && IncludeAction(table.SchemaActions, SchemaAction.Export))
{
script.Add(table.SqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
script.AddRange(table.SqlCommentStrings(dialect, defaultCatalog, defaultSchema));
@@ -732,7 +737,7 @@
foreach (var table in TableMappings)
{
- if (table.IsPhysicalTable && table.SchemaExport)
+ if (table.IsPhysicalTable && IncludeAction(table.SchemaActions, SchemaAction.Export))
{
if (!dialect.SupportsUniqueConstraintInCreateAlterTable)
{
@@ -755,7 +760,7 @@
{
foreach (var fk in table.ForeignKeyIterator)
{
- if (fk.HasPhysicalConstraint && fk.ReferencedTable.SchemaExport)
+ if (fk.HasPhysicalConstraint && IncludeAction(fk.ReferencedTable.SchemaActions, SchemaAction.Export))
{
script.Add(fk.SqlCreateString(dialect, mapping, defaultCatalog, defaultSchema));
}
@@ -1920,7 +1925,7 @@
var script = new List<string>(50);
foreach (var table in TableMappings)
{
- if (table.IsPhysicalTable && table.SchemaUpdate)
+ if (table.IsPhysicalTable && IncludeAction(table.SchemaActions, SchemaAction.Update))
{
ITableMetadata tableInfo = databaseMetadata.GetTableMetadata(table.Name, table.Schema ?? defaultSchema,
table.Catalog ?? defaultCatalog, table.IsQuoted);
@@ -1941,7 +1946,7 @@
foreach (var table in TableMappings)
{
- if (table.IsPhysicalTable && table.SchemaUpdate)
+ if (table.IsPhysicalTable && IncludeAction(table.SchemaActions, SchemaAction.Update))
{
ITableMetadata tableInfo = databaseMetadata.GetTableMetadata(table.Name, table.Schema, table.Catalog,
table.IsQuoted);
@@ -1950,7 +1955,7 @@
{
foreach (var fk in table.ForeignKeyIterator)
{
- if (fk.HasPhysicalConstraint && fk.ReferencedTable.SchemaUpdate)
+ if (fk.HasPhysicalConstraint && IncludeAction(fk.ReferencedTable.SchemaActions, SchemaAction.Update))
{
bool create = tableInfo == null
||
@@ -1997,10 +2002,10 @@
string defaultCatalog = PropertiesHelper.GetString(Environment.DefaultCatalog, properties, null);
string defaultSchema = PropertiesHelper.GetString(Environment.DefaultSchema, properties, null);
- var iter = this.TableMappings;
+ var iter = TableMappings;
foreach (var table in iter)
{
- if (table.IsPhysicalTable && table.SchemaValidate)
+ if (table.IsPhysicalTable && IncludeAction(table.SchemaActions, SchemaAction.Validate))
{
/*NH Different Implementation :
TableMetadata tableInfo = databaseMetadata.getTableMetadata(
@@ -2011,7 +2016,7 @@
ITableMetadata tableInfo = databaseMetadata.GetTableMetadata(
table.Name,
table.Schema??defaultSchema,
- table.Catalog,//??defaultCatalog,
+ table.Catalog??defaultCatalog,
table.IsQuoted);
if (tableInfo == null)
throw new HibernateException("Missing table: " + table.Name);
Modified: trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs 2008-12-16 18:39:12 UTC (rev 3958)
+++ trunk/nhibernate/src/NHibernate/Cfg/Mappings.cs 2008-12-16 20:16:16 UTC (rev 3959)
@@ -258,10 +258,7 @@
table.Schema = schema;
table.Catalog = catalog;
table.Subselect = subselect;
- table.SchemaDrop = SchemaActionRequested(schemaAction, "drop");
- table.SchemaUpdate = SchemaActionRequested(schemaAction, "update");
- table.SchemaExport = SchemaActionRequested(schemaAction, "export");
- table.SchemaValidate = SchemaActionRequested(schemaAction, "validate");
+ table.SchemaActions = GetSchemaActions(schemaAction);
tables[key] = table;
}
else
@@ -273,9 +270,46 @@
return table;
}
- private static bool SchemaActionRequested(string schemaAction, string check)
+ private static SchemaAction GetSchemaActions(string schemaAction)
{
- return string.IsNullOrEmpty(schemaAction) || schemaAction.Contains("all") || schemaAction.Contains(check);
+ if (string.IsNullOrEmpty(schemaAction))
+ {
+ return SchemaAction.All;
+ }
+ else
+ {
+ SchemaAction sa = SchemaAction.None;
+ string[] acts = schemaAction.Split(new[] {',', ' '});
+ foreach (var s in acts)
+ {
+ switch (s.ToLowerInvariant())
+ {
+ case "":
+ case "all":
+ sa |= SchemaAction.All;
+ break;
+ case "drop":
+ sa |= SchemaAction.Drop;
+ break;
+ case "update":
+ sa |= SchemaAction.Update;
+ break;
+ case "export":
+ sa |= SchemaAction.Export;
+ break;
+ case "validate":
+ sa |= SchemaAction.Validate;
+ break;
+ case "none":
+ sa |= SchemaAction.None;
+ break;
+ default:
+ throw new MappingException(
+ string.Format("Invalid schema-export value; Expected(all drop update export validate none), Found ({0})", s));
+ }
+ }
+ return sa;
+ }
}
public Table AddDenormalizedTable(string schema, string catalog, string name, bool isAbstract, string subselect, Table includedTable)
Modified: trunk/nhibernate/src/NHibernate/Mapping/Table.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/Table.cs 2008-12-16 18:39:12 UTC (rev 3958)
+++ trunk/nhibernate/src/NHibernate/Mapping/Table.cs 2008-12-16 20:16:16 UTC (rev 3959)
@@ -9,6 +9,17 @@
namespace NHibernate.Mapping
{
+ [Flags]
+ public enum SchemaAction
+ {
+ None = 0,
+ Drop = 1,
+ Update= 2,
+ Export= 4,
+ Validate= 8,
+ All = Drop | Update | Export | Validate
+ }
+
/// <summary>
/// Represents a Table in a database that an object gets mapped against.
/// </summary>
@@ -84,10 +95,7 @@
private string subselect;
private string rowId;
private bool isSchemaQuoted;
- private bool schemaDrop = true;
- private bool schemaUpdate = true;
- private bool schemaExport = true;
- private bool schemaValidate = true;
+ private SchemaAction schemaActions = SchemaAction.All;
/// <summary>
@@ -924,30 +932,12 @@
get { return !IsSubselect && !IsAbstractUnionTable; }
}
- public bool SchemaDrop
+ public SchemaAction SchemaActions
{
- get { return schemaDrop; }
- set { schemaDrop = value; }
+ get { return schemaActions; }
+ set { schemaActions = value; }
}
- public bool SchemaUpdate
- {
- get { return schemaUpdate; }
- set { schemaUpdate = value; }
- }
-
- public bool SchemaExport
- {
- get { return schemaExport; }
- set { schemaExport = value; }
- }
-
- public bool SchemaValidate
- {
- get { return schemaValidate; }
- set { schemaValidate = value; }
- }
-
public string RowId
{
get { return rowId; }
Modified: trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs 2008-12-16 18:39:12 UTC (rev 3958)
+++ trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs 2008-12-16 20:16:16 UTC (rev 3959)
@@ -19,23 +19,19 @@
/// </remarks>
public class SchemaExport
{
- private readonly string[] dropSQL;
- private readonly string[] createSQL;
+ private static readonly ILog log = LogManager.GetLogger(typeof (SchemaExport));
private readonly IDictionary<string, string> connectionProperties;
- private string outputFile = null;
+ private readonly string[] createSQL;
private readonly Dialect.Dialect dialect;
- private string delimiter = null;
+ private readonly string[] dropSQL;
+ private string delimiter;
+ private string outputFile;
- private static readonly ILog log = LogManager.GetLogger(typeof(SchemaExport));
-
/// <summary>
/// Create a schema exported for a given Configuration
/// </summary>
/// <param name="cfg">The NHibernate Configuration to generate the schema from.</param>
- public SchemaExport(Configuration cfg)
- : this(cfg, cfg.Properties)
- {
- }
+ public SchemaExport(Configuration cfg) : this(cfg, cfg.Properties) {}
/// <summary>
/// Create a schema exporter for the given Configuration, with the given
@@ -107,7 +103,7 @@
}
private void Execute(Action<string> scriptAction, bool export, bool format, bool throwOnError, TextWriter exportOutput,
- IDbCommand statement, string sql)
+ IDbCommand statement, string sql)
{
try
{
@@ -169,8 +165,8 @@
/// This overload is provided mainly to enable use of in memory databases.
/// It does NOT close the given connection!
/// </remarks>
- public void Execute(bool script, bool export, bool justDrop, bool format,
- IDbConnection connection, TextWriter exportOutput)
+ public void Execute(bool script, bool export, bool justDrop, bool format, IDbConnection connection,
+ TextWriter exportOutput)
{
if (script)
{
@@ -182,8 +178,8 @@
}
}
- public void Execute(Action<string> scriptAction, bool export, bool justDrop, bool format,
- IDbConnection connection, TextWriter exportOutput)
+ public void Execute(Action<string> scriptAction, bool export, bool justDrop, bool format, IDbConnection connection,
+ TextWriter exportOutput)
{
IDbCommand statement = null;
@@ -236,10 +232,8 @@
}
}
}
-
}
-
/// <summary>
/// Executes the Export of the Schema.
/// </summary>
@@ -261,21 +255,22 @@
Execute(null, export, justDrop, format);
}
}
+
public void Execute(Action<string> scriptAction, bool export, bool justDrop, bool format)
{
IDbConnection connection = null;
StreamWriter fileOutput = null;
IConnectionProvider connectionProvider = null;
- Dictionary<string, string> props = new Dictionary<string, string>();
- foreach (KeyValuePair<string, string> de in dialect.DefaultProperties)
+ var props = new Dictionary<string, string>();
+ foreach (var de in dialect.DefaultProperties)
{
props[de.Key] = de.Value;
}
if (connectionProperties != null)
{
- foreach (KeyValuePair<string, string> de in connectionProperties)
+ foreach (var de in connectionProperties)
{
props[de.Key] = de.Value;
}
@@ -314,7 +309,6 @@
connectionProvider.Dispose();
}
}
-
}
/// <summary>
@@ -350,8 +344,8 @@
if (StringHelper.StartsWithCaseInsensitive(sql, "create table"))
{
- StringBuilder result = new StringBuilder(60);
- StringTokenizer tokens = new StringTokenizer(sql, "(,)", true);
+ var result = new StringBuilder(60);
+ var tokens = new StringTokenizer(sql, "(,)", true);
int depth = 0;
Modified: trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs 2008-12-16 18:39:12 UTC (rev 3958)
+++ trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs 2008-12-16 20:16:16 UTC (rev 3959)
@@ -8,26 +8,22 @@
namespace NHibernate.Tool.hbm2ddl
{
-
public class SchemaUpdate
{
- private static readonly ILog log = LogManager.GetLogger(typeof(SchemaUpdate));
- private readonly IConnectionHelper connectionHelper;
+ private static readonly ILog log = LogManager.GetLogger(typeof (SchemaUpdate));
private readonly Configuration configuration;
+ private readonly IConnectionHelper connectionHelper;
private readonly Dialect.Dialect dialect;
private readonly List<Exception> exceptions;
- public SchemaUpdate(Configuration cfg)
- : this(cfg, cfg.Properties)
- {
- }
+ public SchemaUpdate(Configuration cfg) : this(cfg, cfg.Properties) {}
public SchemaUpdate(Configuration cfg, IDictionary<string, string> connectionProperties)
{
configuration = cfg;
- dialect = NHibernate.Dialect.Dialect.GetDialect(connectionProperties);
- Dictionary<string, string> props = new Dictionary<string, string>(dialect.DefaultProperties);
- foreach (KeyValuePair<string, string> prop in connectionProperties)
+ dialect = Dialect.Dialect.GetDialect(connectionProperties);
+ var props = new Dictionary<string, string>(dialect.DefaultProperties);
+ foreach (var prop in connectionProperties)
{
props[prop.Key] = prop.Value;
}
@@ -39,17 +35,24 @@
{
configuration = cfg;
dialect = settings.Dialect;
- connectionHelper = new SuppliedConnectionProviderConnectionHelper(
- settings.ConnectionProvider
- );
+ connectionHelper = new SuppliedConnectionProviderConnectionHelper(settings.ConnectionProvider);
exceptions = new List<Exception>();
}
+ /// <summary>
+ /// Returns a List of all Exceptions which occured during the export.
+ /// </summary>
+ /// <returns></returns>
+ public IList<Exception> Exceptions
+ {
+ get { return exceptions; }
+ }
+
public static void Main(string[] args)
{
try
{
- Configuration cfg = new Configuration();
+ var cfg = new Configuration();
bool script = true;
// If true then execute db updates, otherwise just generate and display updates
@@ -80,8 +83,7 @@
else if (args[i].StartsWith("--naming="))
{
cfg.SetNamingStrategy(
- (INamingStrategy)Activator.CreateInstance(ReflectHelper.ClassForName(args[i].Substring(9)))
- );
+ (INamingStrategy) Activator.CreateInstance(ReflectHelper.ClassForName(args[i].Substring(9))));
}
}
else
@@ -204,14 +206,5 @@
}
}
}
-
- /// <summary>
- /// Returns a List of all Exceptions which occured during the export.
- /// </summary>
- /// <returns></returns>
- public IList<Exception> Exceptions
- {
- get { return exceptions; }
- }
}
-}
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaValidator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaValidator.cs 2008-12-16 18:39:12 UTC (rev 3958)
+++ trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaValidator.cs 2008-12-16 20:16:16 UTC (rev 3959)
@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
-using System.Data;
using System.Data.Common;
-using System.Data.SqlClient;
-using System.Text;
using log4net;
-using log4net.Repository.Hierarchy;
using NHibernate.Cfg;
using NHibernate.Util;
@@ -13,30 +9,28 @@
{
public class SchemaValidator
{
-
- private static readonly ILog log = LogManager.GetLogger(typeof(SchemaValidator));
- private readonly IConnectionHelper connectionHelper;
+ private static readonly ILog log = LogManager.GetLogger(typeof (SchemaValidator));
private readonly Configuration configuration;
- private Dialect.Dialect dialect;
+ private readonly IConnectionHelper connectionHelper;
+ private readonly Dialect.Dialect dialect;
- public SchemaValidator(Configuration cfg) :
- this(cfg, cfg.Properties)
- {
- }
+ public SchemaValidator(Configuration cfg) : this(cfg, cfg.Properties) {}
public SchemaValidator(Configuration cfg, IDictionary<string, string> connectionProperties)
{
- this.configuration = cfg;
+ configuration = cfg;
dialect = Dialect.Dialect.GetDialect(connectionProperties);
IDictionary<string, string> props = new Dictionary<string, string>(dialect.DefaultProperties);
foreach (var prop in connectionProperties)
+ {
props[prop.Key] = prop.Value;
+ }
connectionHelper = new ManagedProviderConnectionHelper(props);
}
public SchemaValidator(Configuration cfg, Settings settings)
{
- this.configuration = cfg;
+ configuration = cfg;
dialect = settings.Dialect;
connectionHelper = new SuppliedConnectionProviderConnectionHelper(settings.ConnectionProvider);
}
@@ -45,33 +39,33 @@
{
try
{
- Configuration cfg = new Configuration();
+ var cfg = new Configuration();
- String propFile = null;
+ //string propFile = null;
for (int i = 0; i < args.Length; i++)
{
if (args[i].StartsWith("--"))
{
- if (args[i].StartsWith("--properties="))
+ //if (args[i].StartsWith("--properties="))
+ //{
+ // propFile = args[i].Substring(13);
+ //}
+ //else
+ if (args[i].StartsWith("--config="))
{
- propFile = args[i].Substring(13);
- }
- else if (args[i].StartsWith("--config="))
- {
cfg.Configure(args[i].Substring(9));
}
else if (args[i].StartsWith("--naming="))
{
cfg.SetNamingStrategy(
- (INamingStrategy)Activator.CreateInstance(ReflectHelper.ClassForName(args[i].Substring(9))));
+ (INamingStrategy) Activator.CreateInstance(ReflectHelper.ClassForName(args[i].Substring(9))));
}
}
else
{
cfg.AddFile(args[i]);
}
-
}
/* NH: No props file for .NET
if ( propFile != null ) {
@@ -93,32 +87,31 @@
/**
* Perform the validations.
*/
+
public void Validate()
{
log.Info("Running schema validator");
- DbConnection connection = null;
try
{
-
DatabaseMetadata meta;
try
{
log.Info("fetching database metadata");
connectionHelper.Prepare();
- connection = connectionHelper.Connection;
+ DbConnection connection = connectionHelper.Connection;
meta = new DatabaseMetadata(connection, dialect, false);
}
catch (Exception sqle)
{
log.Error("could not get database metadata", sqle);
- throw sqle;
+ throw;
}
configuration.ValidateSchema(dialect, meta);
}
catch (Exception e)
{
log.Error("could not complete schema validation", e);
- throw e;
+ throw;
}
finally
{
@@ -130,8 +123,7 @@
{
log.Error("Error closing connection", e);
}
-
}
}
}
-}
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2008-12-16 20:44:25
|
Revision: 3960
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3960&view=rev
Author: fabiomaulo
Date: 2008-12-16 20:44:19 +0000 (Tue, 16 Dec 2008)
Log Message:
-----------
- Minor refactoring
- bugfix in exception message
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
trunk/nhibernate/src/NHibernate/Mapping/Table.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2008-12-16 20:16:16 UTC (rev 3959)
+++ trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2008-12-16 20:44:19 UTC (rev 3960)
@@ -2031,7 +2031,7 @@
string key = generator.GeneratorKey();
if (!databaseMetadata.IsSequence(key) && !databaseMetadata.IsTable(key))
{
- throw new HibernateException(string.Format("Missing sequence or table: ", key));
+ throw new HibernateException(string.Format("Missing sequence or table: "+ key));
}
}
}
Modified: trunk/nhibernate/src/NHibernate/Mapping/Table.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/Table.cs 2008-12-16 20:16:16 UTC (rev 3959)
+++ trunk/nhibernate/src/NHibernate/Mapping/Table.cs 2008-12-16 20:44:19 UTC (rev 3960)
@@ -1,7 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
-using System.Data;
using System.Text;
using NHibernate.Dialect.Schema;
using NHibernate.Engine;
@@ -14,9 +13,9 @@
{
None = 0,
Drop = 1,
- Update= 2,
- Export= 4,
- Validate= 8,
+ Update = 2,
+ Export = 4,
+ Validate = 8,
All = Drop | Update | Export | Validate
}
@@ -26,78 +25,25 @@
[Serializable]
public class Table : IRelationalModel
{
- internal class ForeignKeyKey: IEqualityComparer<ForeignKeyKey>
- {
- internal string referencedClassName;
- internal List<Column> columns;
- internal List<Column> referencedColumns;
-
- internal ForeignKeyKey(IEnumerable<Column> columns, string referencedClassName, IEnumerable<Column> referencedColumns)
- {
- this.referencedClassName = referencedClassName;
- this.columns = new List<Column>(columns);
- if (referencedColumns != null)
- this.referencedColumns = new List<Column>(referencedColumns);
- else
- this.referencedColumns = new List<Column>();
- }
-
- public override int GetHashCode()
- {
- return GetHashCode(this);
- }
-
- public override bool Equals(object other)
- {
- ForeignKeyKey that = other as ForeignKeyKey;
- if (that != null)
- return Equals(this, that);
- else
- return false;
- }
-
- #region IEqualityComparer<ForeignKeyKey> Members
-
- public bool Equals(ForeignKeyKey x, ForeignKeyKey y)
- {
- // NH : Different implementation to prevent NH930 (look test)
- return //y.referencedClassName.Equals(x.referencedClassName) &&
- CollectionHelper.CollectionEquals<Column>(y.columns, x.columns) &&
- CollectionHelper.CollectionEquals<Column>(y.referencedColumns, x.referencedColumns);
- }
-
- public int GetHashCode(ForeignKeyKey obj)
- {
- int result = CollectionHelper.GetHashCode(obj.columns) ^ CollectionHelper.GetHashCode(obj.referencedColumns);
- return result;
- }
-
- #endregion
- }
-
- private string name;
- private string schema;
- private string catalog;
-
+ private static int tableCounter;
+ private readonly List<string> checkConstraints = new List<string>();
private readonly LinkedHashMap<string, Column> columns = new LinkedHashMap<string, Column>();
- private IKeyValue idValue;
- private PrimaryKey primaryKey;
- private readonly Dictionary<string, Index> indexes = new Dictionary<string, Index>();
private readonly Dictionary<ForeignKeyKey, ForeignKey> foreignKeys = new Dictionary<ForeignKeyKey, ForeignKey>();
- private readonly Dictionary<string, UniqueKey> uniqueKeys = new Dictionary<string, UniqueKey>();
+ private readonly Dictionary<string, Index> indexes = new Dictionary<string, Index>();
private readonly int uniqueInteger;
- private bool quoted;
- private static int tableCounter = 0;
- private readonly List<string> checkConstraints = new List<string>();
- private bool isAbstract;
- private bool hasDenormalizedTables = false;
+ private readonly Dictionary<string, UniqueKey> uniqueKeys = new Dictionary<string, UniqueKey>();
+ private string catalog;
private string comment;
- private string subselect;
- private string rowId;
+ private bool hasDenormalizedTables;
+ private IKeyValue idValue;
+ private bool isAbstract;
private bool isSchemaQuoted;
+ private string name;
+ private bool quoted;
+ private string schema;
private SchemaAction schemaActions = SchemaAction.All;
+ private string subselect;
-
/// <summary>
/// Initializes a new instance of <see cref="Table"/>.
/// </summary>
@@ -106,43 +52,12 @@
uniqueInteger = tableCounter++;
}
- public Table(string name)
- : this()
+ public Table(string name) : this()
{
Name = name;
}
/// <summary>
- /// Gets the schema qualified name of the Table.
- /// </summary>
- /// <param name="dialect">The <see cref="Dialect"/> that knows how to Quote the Table name.</param>
- /// <returns>The name of the table qualified with the schema if one is specified.</returns>
- public string GetQualifiedName(Dialect.Dialect dialect)
- {
- return GetQualifiedName(dialect, null, null);
- }
-
- /// <summary>
- /// Gets the schema qualified name of the Table using the specified qualifier
- /// </summary>
- /// <param name="dialect">The <see cref="Dialect"/> that knows how to Quote the Table name.</param>
- /// <param name="defaultCatalog">The catalog name.</param>
- /// <param name="defaultSchema">The schema name.</param>
- /// <returns>A String representing the Qualified name.</returns>
- /// <remarks>If this were used with MSSQL it would return a dbo.table_name.</remarks>
- public virtual string GetQualifiedName(Dialect.Dialect dialect, string defaultCatalog, string defaultSchema)
- {
- if (!string.IsNullOrEmpty(subselect))
- {
- return "( " + subselect + " )";
- }
- string quotedName = GetQuotedName(dialect);
- string usedSchema = schema == null ? defaultSchema : GetQuotedSchema(dialect);
- string usedCatalog = catalog ?? defaultCatalog;
- return dialect.Qualify(usedCatalog, usedSchema, quotedName);
- }
-
- /// <summary>
/// Gets or sets the name of the Table in the database.
/// </summary>
/// <value>
@@ -177,102 +92,7 @@
}
}
- /// <summary> returns quoted name as it would be in the mapping file.</summary>
- public string GetQuotedName()
- {
- return quoted ? "`" + name + "`" : name;
- }
-
/// <summary>
- /// Gets the name of this Table in quoted form if it is necessary.
- /// </summary>
- /// <param name="dialect">
- /// The <see cref="Dialect.Dialect"/> that knows how to quote the Table name.
- /// </param>
- /// <returns>
- /// The Table name in a form that is safe to use inside of a SQL statement.
- /// Quoted if it needs to be, not quoted if it does not need to be.
- /// </returns>
- public string GetQuotedName(Dialect.Dialect dialect)
- {
- return IsQuoted ?
- dialect.QuoteForTableName(name) :
- name;
- }
-
- /// <summary> returns quoted name as it is in the mapping file.</summary>
- public string GetQuotedSchema()
- {
- return IsSchemaQuoted ? "`" + schema + "`" : schema;
- }
-
- public string GetQuotedSchema(Dialect.Dialect dialect)
- {
- return IsSchemaQuoted ? dialect.OpenQuote + schema + dialect.CloseQuote : schema;
- }
-
- /// <summary>
- /// Gets the schema for this table in quoted form if it is necessary.
- /// </summary>
- /// <param name="dialect">
- /// The <see cref="Dialect.Dialect" /> that knows how to quote the table name.
- /// </param>
- /// <returns>
- /// The schema name for this table in a form that is safe to use inside
- /// of a SQL statement. Quoted if it needs to be, not quoted if it does not need to be.
- /// </returns>
- public string GetQuotedSchemaName(Dialect.Dialect dialect)
- {
- if (schema == null)
- {
- return null;
- }
-
- if (schema.StartsWith("`"))
- {
- return dialect.QuoteForSchemaName(schema.Substring(1, schema.Length - 2));
- }
-
- return schema;
- }
-
- /// <summary>
- /// Gets the <see cref="Column"/> at the specified index.
- /// </summary>
- /// <param name="n">The index of the Column to get.</param>
- /// <returns>
- /// The <see cref="Column"/> at the specified index.
- /// </returns>
- public Column GetColumn(int n)
- {
- IEnumerator<Column> iter = columns.Values.GetEnumerator();
- for (int i = 0; i < n; i++)
- {
- iter.MoveNext();
- }
- return iter.Current;
- }
-
- /// <summary>
- /// Adds the <see cref="Column"/> to the <see cref="ICollection"/> of
- /// Columns that are part of the Table.
- /// </summary>
- /// <param name="column">The <see cref="Column"/> to include in the Table.</param>
- public void AddColumn(Column column)
- {
- Column old = GetColumn(column);
- if (old == null)
- {
- columns[column.CanonicalName] = column;
- column.uniqueInteger = columns.Count;
- }
- else
- {
- column.uniqueInteger = old.uniqueInteger;
- }
- }
-
- /// <summary>
/// Gets the number of columns that this Table contains.
/// </summary>
/// <value>
@@ -335,67 +155,168 @@
get { return uniqueKeys.Values; }
}
- public string[] SqlAlterStrings(Dialect.Dialect dialect, IMapping p, ITableMetadata tableInfo, string defaultCatalog, string defaultSchema)
+ /// <summary>
+ /// Gets or sets the <see cref="PrimaryKey"/> of the Table.
+ /// </summary>
+ /// <value>The <see cref="PrimaryKey"/> of the Table.</value>
+ public virtual PrimaryKey PrimaryKey { get; set; }
+
+ /// <summary>
+ /// Gets or sets the schema the table is in.
+ /// </summary>
+ /// <value>
+ /// The schema the table is in or <see langword="null" /> if no schema is specified.
+ /// </value>
+ public string Schema
{
- StringBuilder root = new StringBuilder("alter table ")
- .Append(GetQualifiedName(dialect, defaultCatalog, defaultSchema))
- .Append(' ')
- .Append(dialect.AddColumnString);
+ get { return schema; }
+ set
+ {
+ if (value != null && value[0] == '`')
+ {
+ isSchemaQuoted = true;
+ schema = value.Substring(1, value.Length - 2);
+ }
+ else
+ {
+ schema = value;
+ }
+ }
+ }
- List<string> results = new List<string>(ColumnSpan);
+ /// <summary>
+ /// Gets the unique number of the Table.
+ /// </summary>
+ /// <value>The unique number of the Table.</value>
+ public int UniqueInteger
+ {
+ get { return uniqueInteger; }
+ }
- foreach (Column column in ColumnIterator)
+ /// <summary>
+ /// Gets or sets if the column needs to be quoted in SQL statements.
+ /// </summary>
+ /// <value><see langword="true" /> if the column is quoted.</value>
+ public bool IsQuoted
+ {
+ get { return quoted; }
+ set { quoted = value; }
+ }
+
+ public IEnumerable<string> CheckConstraintsIterator
+ {
+ get { return checkConstraints; }
+ }
+
+ public bool IsAbstractUnionTable
+ {
+ get { return HasDenormalizedTables && isAbstract; }
+ }
+
+ public bool HasDenormalizedTables
+ {
+ get { return hasDenormalizedTables; }
+ }
+
+ public bool IsAbstract
+ {
+ get { return isAbstract; }
+ set { isAbstract = value; }
+ }
+
+ internal IDictionary<string, UniqueKey> UniqueKeys
+ {
+ get
{
- IColumnMetadata columnInfo = tableInfo.GetColumnMetadata(column.Name);
- if (columnInfo != null)
- continue;
-
- // the column doesnt exist at all.
- StringBuilder alter = new StringBuilder(root.ToString())
- .Append(' ')
- .Append(column.GetQuotedName(dialect))
- .Append(' ')
- .Append(column.GetSqlType(dialect, p));
-
- string defaultValue = column.DefaultValue;
- if (!string.IsNullOrEmpty(defaultValue))
+ if (uniqueKeys.Count > 1)
+ {
+ //deduplicate unique constraints sharing the same columns
+ //this is needed by Hibernate Annotations since it creates automagically
+ // unique constraints for the user
+ var finalUniqueKeys = new Dictionary<string, UniqueKey>(uniqueKeys.Count);
+ foreach (var entry in uniqueKeys)
{
- alter.Append(" default ").Append(defaultValue);
-
- if (column.IsNullable)
+ UniqueKey uk = entry.Value;
+ IList<Column> _columns = uk.Columns;
+ bool skip = false;
+ var tempUks = new Dictionary<string, UniqueKey>(finalUniqueKeys);
+ foreach (var tUk in tempUks)
{
- alter.Append(dialect.NullColumnString);
+ UniqueKey currentUk = tUk.Value;
+ if (AreSameColumns(currentUk.Columns, _columns))
+ {
+ skip = true;
+ break;
+ }
}
- else
+ if (!skip)
{
- alter.Append(" not null");
+ finalUniqueKeys[entry.Key] = uk;
}
}
-
- bool useUniqueConstraint = column.Unique && dialect.SupportsUnique
- && (!column.IsNullable || dialect.SupportsNotNullUnique);
- if (useUniqueConstraint)
- {
- alter.Append(" unique");
+ return finalUniqueKeys;
}
-
- if (column.HasCheckConstraint && dialect.SupportsColumnCheck)
+ else
{
- alter.Append(" check(").Append(column.CheckConstraint).Append(") ");
+ return uniqueKeys;
}
+ }
+ }
- string columnComment = column.Comment;
- if (columnComment != null)
- {
- alter.Append(dialect.GetColumnComment(columnComment));
- }
+ public bool HasPrimaryKey
+ {
+ get { return PrimaryKey != null; }
+ }
- results.Add(alter.ToString());
- }
+ public string Catalog
+ {
+ get { return catalog; }
+ set { catalog = value; }
+ }
- return results.ToArray();
+ public string Comment
+ {
+ get { return comment; }
+ set { comment = value; }
}
+ public string Subselect
+ {
+ get { return subselect; }
+ set { subselect = value; }
+ }
+
+ public IKeyValue IdentifierValue
+ {
+ get { return idValue; }
+ set { idValue = value; }
+ }
+
+ public bool IsSubselect
+ {
+ get { return !string.IsNullOrEmpty(subselect); }
+ }
+
+ public bool IsPhysicalTable
+ {
+ get { return !IsSubselect && !IsAbstractUnionTable; }
+ }
+
+ public SchemaAction SchemaActions
+ {
+ get { return schemaActions; }
+ set { schemaActions = value; }
+ }
+
+ public string RowId { get; set; }
+
+ public bool IsSchemaQuoted
+ {
+ get { return isSchemaQuoted; }
+ }
+
+ #region IRelationalModel Members
+
/// <summary>
/// Generates the SQL string to create this Table in the database.
/// </summary>
@@ -409,13 +330,9 @@
/// </returns>
public string SqlCreateString(Dialect.Dialect dialect, IMapping p, string defaultCatalog, string defaultSchema)
{
- StringBuilder buf = new StringBuilder(HasPrimaryKey
- ?
- dialect.CreateTableString
- : dialect.CreateMultisetTableString)
- .Append(' ')
- .Append(GetQualifiedName(dialect, defaultCatalog, defaultSchema))
- .Append(" (");
+ StringBuilder buf =
+ new StringBuilder(HasPrimaryKey ? dialect.CreateTableString : dialect.CreateMultisetTableString).Append(' ').Append(
+ GetQualifiedName(dialect, defaultCatalog, defaultSchema)).Append(" (");
bool identityColumn = idValue != null && idValue.IsIdentityColumn(dialect);
@@ -439,8 +356,7 @@
}
commaNeeded = true;
- buf.Append(col.GetQuotedName(dialect))
- .Append(' ');
+ buf.Append(col.GetQuotedName(dialect)).Append(' ');
if (identityColumn && col.GetQuotedName(dialect).Equals(pkname))
{
@@ -449,14 +365,13 @@
{
buf.Append(col.GetSqlType(dialect, p));
}
- buf.Append(' ')
- .Append(dialect.GetIdentityColumnString(col.GetSqlTypeCode(p).DbType));
+ buf.Append(' ').Append(dialect.GetIdentityColumnString(col.GetSqlTypeCode(p).DbType));
}
else
{
buf.Append(col.GetSqlType(dialect, p));
- if(string.IsNullOrEmpty(col.DefaultValue)==false)
+ if (!string.IsNullOrEmpty(col.DefaultValue))
{
buf.Append(" default ").Append(col.DefaultValue).Append(" ");
}
@@ -484,14 +399,12 @@
}
}
- if(col.HasCheckConstraint && dialect.SupportsColumnCheck)
+ if (col.HasCheckConstraint && dialect.SupportsColumnCheck)
{
- buf.Append(" check( ")
- .Append(col.CheckConstraint)
- .Append(") ");
+ buf.Append(" check( ").Append(col.CheckConstraint).Append(") ");
}
- if(string.IsNullOrEmpty(col.Comment)==false)
+ if (string.IsNullOrEmpty(col.Comment) == false)
{
buf.Append(dialect.GetColumnComment(col.Comment));
}
@@ -505,20 +418,18 @@
{
buf.Append(',').Append(uk.SqlConstraintString(dialect));
}
-
- if(dialect.SupportsTableCheck)
+
+ if (dialect.SupportsTableCheck)
{
foreach (string checkConstraint in checkConstraints)
{
- buf.Append(", check (")
- .Append(checkConstraint)
- .Append(") ");
+ buf.Append(", check (").Append(checkConstraint).Append(") ");
}
}
buf.Append(StringHelper.ClosedParen);
- if(string.IsNullOrEmpty(comment)==false)
+ if (string.IsNullOrEmpty(comment) == false)
{
buf.Append(dialect.GetTableComment(comment));
}
@@ -541,28 +452,204 @@
return dialect.GetDropTableString(GetQualifiedName(dialect, defaultCatalog, defaultSchema));
}
+ #endregion
+
/// <summary>
- /// Gets or sets the <see cref="PrimaryKey"/> of the Table.
+ /// Gets the schema qualified name of the Table.
/// </summary>
- /// <value>The <see cref="PrimaryKey"/> of the Table.</value>
- public virtual PrimaryKey PrimaryKey
+ /// <param name="dialect">The <see cref="Dialect"/> that knows how to Quote the Table name.</param>
+ /// <returns>The name of the table qualified with the schema if one is specified.</returns>
+ public string GetQualifiedName(Dialect.Dialect dialect)
{
- get { return primaryKey; }
- set { primaryKey = value; }
+ return GetQualifiedName(dialect, null, null);
}
/// <summary>
+ /// Gets the schema qualified name of the Table using the specified qualifier
+ /// </summary>
+ /// <param name="dialect">The <see cref="Dialect"/> that knows how to Quote the Table name.</param>
+ /// <param name="defaultCatalog">The catalog name.</param>
+ /// <param name="defaultSchema">The schema name.</param>
+ /// <returns>A String representing the Qualified name.</returns>
+ /// <remarks>If this were used with MSSQL it would return a dbo.table_name.</remarks>
+ public virtual string GetQualifiedName(Dialect.Dialect dialect, string defaultCatalog, string defaultSchema)
+ {
+ if (!string.IsNullOrEmpty(subselect))
+ {
+ return "( " + subselect + " )";
+ }
+ string quotedName = GetQuotedName(dialect);
+ string usedSchema = schema == null ? defaultSchema : GetQuotedSchema(dialect);
+ string usedCatalog = catalog ?? defaultCatalog;
+ return dialect.Qualify(usedCatalog, usedSchema, quotedName);
+ }
+
+ /// <summary> returns quoted name as it would be in the mapping file.</summary>
+ public string GetQuotedName()
+ {
+ return quoted ? "`" + name + "`" : name;
+ }
+
+ /// <summary>
+ /// Gets the name of this Table in quoted form if it is necessary.
+ /// </summary>
+ /// <param name="dialect">
+ /// The <see cref="Dialect.Dialect"/> that knows how to quote the Table name.
+ /// </param>
+ /// <returns>
+ /// The Table name in a form that is safe to use inside of a SQL statement.
+ /// Quoted if it needs to be, not quoted if it does not need to be.
+ /// </returns>
+ public string GetQuotedName(Dialect.Dialect dialect)
+ {
+ return IsQuoted ? dialect.QuoteForTableName(name) : name;
+ }
+
+ /// <summary> returns quoted name as it is in the mapping file.</summary>
+ public string GetQuotedSchema()
+ {
+ return IsSchemaQuoted ? "`" + schema + "`" : schema;
+ }
+
+ public string GetQuotedSchema(Dialect.Dialect dialect)
+ {
+ return IsSchemaQuoted ? dialect.OpenQuote + schema + dialect.CloseQuote : schema;
+ }
+
+ /// <summary>
+ /// Gets the schema for this table in quoted form if it is necessary.
+ /// </summary>
+ /// <param name="dialect">
+ /// The <see cref="Dialect.Dialect" /> that knows how to quote the table name.
+ /// </param>
+ /// <returns>
+ /// The schema name for this table in a form that is safe to use inside
+ /// of a SQL statement. Quoted if it needs to be, not quoted if it does not need to be.
+ /// </returns>
+ public string GetQuotedSchemaName(Dialect.Dialect dialect)
+ {
+ if (schema == null)
+ {
+ return null;
+ }
+
+ if (schema.StartsWith("`"))
+ {
+ return dialect.QuoteForSchemaName(schema.Substring(1, schema.Length - 2));
+ }
+
+ return schema;
+ }
+
+ /// <summary>
+ /// Gets the <see cref="Column"/> at the specified index.
+ /// </summary>
+ /// <param name="n">The index of the Column to get.</param>
+ /// <returns>
+ /// The <see cref="Column"/> at the specified index.
+ /// </returns>
+ public Column GetColumn(int n)
+ {
+ IEnumerator<Column> iter = columns.Values.GetEnumerator();
+ for (int i = 0; i < n; i++)
+ {
+ iter.MoveNext();
+ }
+ return iter.Current;
+ }
+
+ /// <summary>
+ /// Adds the <see cref="Column"/> to the <see cref="ICollection"/> of
+ /// Columns that are part of the Table.
+ /// </summary>
+ /// <param name="column">The <see cref="Column"/> to include in the Table.</param>
+ public void AddColumn(Column column)
+ {
+ Column old = GetColumn(column);
+ if (old == null)
+ {
+ columns[column.CanonicalName] = column;
+ column.uniqueInteger = columns.Count;
+ }
+ else
+ {
+ column.uniqueInteger = old.uniqueInteger;
+ }
+ }
+
+ public string[] SqlAlterStrings(Dialect.Dialect dialect, IMapping p, ITableMetadata tableInfo, string defaultCatalog,
+ string defaultSchema)
+ {
+ StringBuilder root =
+ new StringBuilder("alter table ").Append(GetQualifiedName(dialect, defaultCatalog, defaultSchema)).Append(' ').
+ Append(dialect.AddColumnString);
+
+ var results = new List<string>(ColumnSpan);
+
+ foreach (Column column in ColumnIterator)
+ {
+ IColumnMetadata columnInfo = tableInfo.GetColumnMetadata(column.Name);
+ if (columnInfo != null)
+ {
+ continue;
+ }
+
+ // the column doesnt exist at all.
+ StringBuilder alter =
+ new StringBuilder(root.ToString()).Append(' ').Append(column.GetQuotedName(dialect)).Append(' ').Append(
+ column.GetSqlType(dialect, p));
+
+ string defaultValue = column.DefaultValue;
+ if (!string.IsNullOrEmpty(defaultValue))
+ {
+ alter.Append(" default ").Append(defaultValue);
+
+ if (column.IsNullable)
+ {
+ alter.Append(dialect.NullColumnString);
+ }
+ else
+ {
+ alter.Append(" not null");
+ }
+ }
+
+ bool useUniqueConstraint = column.Unique && dialect.SupportsUnique
+ && (!column.IsNullable || dialect.SupportsNotNullUnique);
+ if (useUniqueConstraint)
+ {
+ alter.Append(" unique");
+ }
+
+ if (column.HasCheckConstraint && dialect.SupportsColumnCheck)
+ {
+ alter.Append(" check(").Append(column.CheckConstraint).Append(") ");
+ }
+
+ string columnComment = column.Comment;
+ if (columnComment != null)
+ {
+ alter.Append(dialect.GetColumnComment(columnComment));
+ }
+
+ results.Add(alter.ToString());
+ }
+
+ return results.ToArray();
+ }
+
+ /// <summary>
/// Gets the <see cref="Index"/> identified by the name.
/// </summary>
- /// <param name="name">The name of the <see cref="Index"/> to get.</param>
+ /// <param name="indexName">The name of the <see cref="Index"/> to get.</param>
/// <returns>
/// The <see cref="Index"/> identified by the name. If the <see cref="Index"/>
/// identified by the name does not exist then it is created.
/// </returns>
- public Index GetIndex(string name)
+ public Index GetIndex(string indexName)
{
Index result;
- indexes.TryGetValue(name, out result);
+ indexes.TryGetValue(indexName, out result);
return result;
}
@@ -593,15 +680,15 @@
/// <summary>
/// Gets the <see cref="UniqueKey"/> identified by the name.
/// </summary>
- /// <param name="name">The name of the <see cref="UniqueKey"/> to get.</param>
+ /// <param name="keyName">The name of the <see cref="UniqueKey"/> to get.</param>
/// <returns>
/// The <see cref="UniqueKey"/> identified by the name. If the <see cref="UniqueKey"/>
/// identified by the name does not exist then it is created.
/// </returns>
- public UniqueKey GetUniqueKey(string name)
+ public UniqueKey GetUniqueKey(string keyName)
{
UniqueKey result;
- uniqueKeys.TryGetValue(name, out result);
+ uniqueKeys.TryGetValue(keyName, out result);
return result;
}
@@ -630,9 +717,7 @@
return uk;
}
- public virtual void CreateForeignKeys()
- {
- }
+ public virtual void CreateForeignKeys() {}
public virtual ForeignKey CreateForeignKey(string keyName, IEnumerable<Column> keyColumns, string referencedEntityName)
{
@@ -654,13 +739,13 @@
/// one already exists for the columns then it will return an
/// existing <see cref="ForeignKey"/>.
/// </remarks>
- public virtual ForeignKey CreateForeignKey(string keyName, IEnumerable<Column> keyColumns,
- string referencedEntityName, IEnumerable<Column> referencedColumns)
+ public virtual ForeignKey CreateForeignKey(string keyName, IEnumerable<Column> keyColumns, string referencedEntityName,
+ IEnumerable<Column> referencedColumns)
{
IEnumerable<Column> kCols = keyColumns;
IEnumerable<Column> refCols = referencedColumns;
- ForeignKeyKey key = new ForeignKeyKey(kCols, referencedEntityName, refCols);
+ var key = new ForeignKeyKey(kCols, referencedEntityName, refCols);
ForeignKey fk;
foreignKeys.TryGetValue(key, out fk);
@@ -707,13 +792,13 @@
/// Generates a unique string for an <see cref="ICollection"/> of
/// <see cref="Column"/> objects.
/// </summary>
- /// <param name="columns">An <see cref="ICollection"/> of <see cref="Column"/> objects.</param>
+ /// <param name="uniqueColumns">An <see cref="ICollection"/> of <see cref="Column"/> objects.</param>
/// <returns>
/// An unique string for the <see cref="Column"/> objects.
/// </returns>
- public string UniqueColumnString(IEnumerable columns)
+ public string UniqueColumnString(IEnumerable uniqueColumns)
{
- return UniqueColumnString(columns, null);
+ return UniqueColumnString(uniqueColumns, null);
}
public string UniqueColumnString(IEnumerable iterator, string referencedEntityName)
@@ -721,7 +806,9 @@
// NH Different implementation (NH-1339)
int result = 37;
if (referencedEntityName != null)
+ {
result ^= referencedEntityName.GetHashCode();
+ }
foreach (object o in iterator)
{
@@ -731,57 +818,15 @@
}
/// <summary>
- /// Gets or sets the schema the table is in.
- /// </summary>
- /// <value>
- /// The schema the table is in or <see langword="null" /> if no schema is specified.
- /// </value>
- public string Schema
- {
- get{return schema;}
- set
- {
- if (value != null && value[0] == '`')
- {
- isSchemaQuoted = true;
- schema = value.Substring(1, value.Length - 2);
- }
- else
- {
- schema = value;
- }
- }
- }
-
- /// <summary>
- /// Gets the unique number of the Table.
- /// </summary>
- /// <value>The unique number of the Table.</value>
- public int UniqueInteger
- {
- get { return uniqueInteger; }
- }
-
- /// <summary>
/// Sets the Identifier of the Table.
/// </summary>
- /// <param name="idValue">The <see cref="SimpleValue"/> that represents the Identifier.</param>
- public void SetIdentifierValue(SimpleValue idValue)
+ /// <param name="identifierValue">The <see cref="SimpleValue"/> that represents the Identifier.</param>
+ public void SetIdentifierValue(SimpleValue identifierValue)
{
- this.idValue = idValue;
+ idValue = identifierValue;
}
/// <summary>
- /// Gets or sets if the column needs to be quoted in SQL statements.
- /// </summary>
- /// <value><see langword="true" /> if the column is quoted.</value>
- public bool IsQuoted
- {
- get { return quoted; }
- set { quoted = value; }
- }
-
- /// <summary>
///
/// </summary>
/// <param name="constraint"></param>
@@ -790,32 +835,11 @@
checkConstraints.Add(constraint);
}
- public IEnumerable<string> CheckConstraintsIterator
- {
- get { return checkConstraints; }
- }
-
- public bool IsAbstractUnionTable
- {
- get { return HasDenormalizedTables && isAbstract; }
- }
-
- public bool HasDenormalizedTables
- {
- get { return hasDenormalizedTables; }
- }
-
internal void SetHasDenormalizedTables()
{
hasDenormalizedTables = true;
}
- public bool IsAbstract
- {
- get { return isAbstract; }
- set { isAbstract = value; }
- }
-
public virtual bool ContainsColumn(Column column)
{
return columns.ContainsValue(column);
@@ -830,7 +854,9 @@
public virtual Column GetColumn(Column column)
{
if (column == null)
+ {
return null;
+ }
Column result;
columns.TryGetValue(column.CanonicalName, out result);
@@ -838,131 +864,39 @@
return column.Equals(result) ? result : null;
}
- internal IDictionary<string, UniqueKey> UniqueKeys
- {
- get
- {
- if (uniqueKeys.Count > 1)
- {
- //deduplicate unique constraints sharing the same columns
- //this is needed by Hibernate Annotations since it creates automagically
- // unique constraints for the user
- Dictionary<string, UniqueKey> finalUniqueKeys = new Dictionary<string, UniqueKey>(uniqueKeys.Count);
- foreach (KeyValuePair<string, UniqueKey> entry in uniqueKeys)
- {
- UniqueKey uk = entry.Value;
- IList<Column> _columns = uk.Columns;
- bo...
[truncated message content] |
|
From: <fab...@us...> - 2008-12-16 22:39:01
|
Revision: 3963
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3963&view=rev
Author: fabiomaulo
Date: 2008-12-16 21:53:58 +0000 (Tue, 16 Dec 2008)
Log Message:
-----------
Fix NH-1605
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ResultSetMappingBinder.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1605/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1605/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1605/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ResultSetMappingBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ResultSetMappingBinder.cs 2008-12-16 21:00:05 UTC (rev 3962)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ResultSetMappingBinder.cs 2008-12-16 21:53:58 UTC (rev 3963)
@@ -73,10 +73,23 @@
return null;
}
- private static INativeSQLQueryReturn CreateScalarReturn(HbmReturnScalar returnScalarSchema)
+ private INativeSQLQueryReturn CreateScalarReturn(HbmReturnScalar returnScalarSchema)
{
- IType type = TypeFactory.HeuristicType(returnScalarSchema.type, null);
+ string typeName;
+ IDictionary<string, string> parameters = null;
+ TypeDef typeDef = mappings.GetTypeDef(returnScalarSchema.type);
+ if (typeDef != null)
+ {
+ typeName = typeDef.TypeClass;
+ parameters = typeDef.Parameters;
+ }
+ else
+ {
+ typeName = returnScalarSchema.type;
+ }
+ IType type = TypeFactory.HeuristicType(typeName, (IDictionary) parameters);
+
if (type == null)
throw new MappingException("could not interpret type: " + returnScalarSchema.type);
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1605/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1605/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1605/Fixture.cs 2008-12-16 21:53:58 UTC (rev 3963)
@@ -0,0 +1,32 @@
+using System.Reflection;
+using NHibernate.Cfg;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1605
+{
+ [TestFixture]
+ public class Fixture
+ {
+ [Test]
+ public void SupportTypedefInReturnScalarElements()
+ {
+ var cfg = new Configuration();
+ Assembly assembly = Assembly.GetExecutingAssembly();
+ cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1605.Mappings.hbm.xml", assembly);
+ using (cfg.BuildSessionFactory()) {}
+ }
+ }
+
+ public enum CapitalCities
+ {
+ Amsterdam,
+ Berlin,
+ Cairo,
+ Dublin
+ }
+
+ public class Country
+ {
+ public virtual CapitalCities CapitalCity { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1605/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1605/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1605/Mappings.hbm.xml 2008-12-16 21:53:58 UTC (rev 3963)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1605">
+
+ <typedef name="CapitalCityString" class="NHibernate.Type.EnumStringType`1[[NHibernate.Test.NHSpecificTest.NH1605.CapitalCities, NHibernate.Test]], NHibernate" />
+
+ <class name="Country">
+ <id type="int">
+ <generator class="native"/>
+ </id>
+ <property name="CapitalCity" type="CapitalCityString" />
+ </class>
+
+ <sql-query name="Country-GetCapital">
+ <return-scalar column="CapitalCity" type="CapitalCityString" />
+ -- Custom SQL omitted
+ </sql-query>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-16 21:00:05 UTC (rev 3962)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-16 21:53:58 UTC (rev 3963)
@@ -377,6 +377,7 @@
<Compile Include="NHSpecificTest\NH1274ExportExclude\NH1274ExportExcludeFixture.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\Person.cs" />
<Compile Include="NHSpecificTest\NH1443\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1605\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1611OneToOneIdentity\Adjunct.cs" />
<Compile Include="NHSpecificTest\NH1611OneToOneIdentity\NH1611OneToOneIdentityFixture.cs" />
<Compile Include="NHSpecificTest\NH1611OneToOneIdentity\Primary.cs" />
@@ -1570,6 +1571,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1605\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1443\AclassWithSpecific.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1443\AclassWithDefault.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1443\AclassWithNothing.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dav...@us...> - 2008-12-25 19:57:58
|
Revision: 3965
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3965&view=rev
Author: davybrion
Date: 2008-12-25 19:57:53 +0000 (Thu, 25 Dec 2008)
Log Message:
-----------
applying patch from Germ?\195?\161n Schuager for NH-1621
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate/Properties/PropertyAccessorFactory.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Properties/ReadonlyAccessor.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Model.cs
trunk/nhibernate/src/NHibernate.Test/PropertyTest/ReadonlyAccessorFixture.cs
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-12-17 06:50:00 UTC (rev 3964)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2008-12-25 19:57:53 UTC (rev 3965)
@@ -840,6 +840,7 @@
<Compile Include="Proxy\Map\MapProxyFactory.cs" />
<Compile Include="Proxy\Poco\BasicLazyInitializer.cs" />
<Compile Include="QueryParameterException.cs" />
+ <Compile Include="Properties\ReadonlyAccessor.cs" />
<Compile Include="SessionException.cs" />
<Compile Include="SqlCommand\InformixJoinFragment.cs" />
<Compile Include="SqlCommand\SubselectClauseExtractor.cs" />
@@ -1150,4 +1151,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project>
\ No newline at end of file
+</Project>
Modified: trunk/nhibernate/src/NHibernate/Properties/PropertyAccessorFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/PropertyAccessorFactory.cs 2008-12-17 06:50:00 UTC (rev 3964)
+++ trunk/nhibernate/src/NHibernate/Properties/PropertyAccessorFactory.cs 2008-12-25 19:57:53 UTC (rev 3965)
@@ -23,6 +23,7 @@
accessors["property"] = new BasicPropertyAccessor();
accessors["field"] = new FieldAccessor();
accessors["backfield"] = new FieldAccessor(new BackFieldStrategy());
+ accessors["readonly"] = new ReadOnlyAccessor();
accessors["field.camelcase"] = new FieldAccessor(new CamelCaseStrategy());
accessors["field.camelcase-underscore"] = new FieldAccessor(new CamelCaseUnderscoreStrategy());
accessors["field.lowercase"] = new FieldAccessor(new LowerCaseStrategy());
@@ -84,6 +85,14 @@
/// allows users of the Class to get the value of the Id but not set the value.
/// </description>
/// </item>
+ /// <item>
+ /// <term>readonly</term>
+ /// <description>
+ /// The <c>name</c> attribute is the name of the Property. NHibernate will use the
+ /// Property's get method to retrieve the value but will never set the value back in the domain.
+ /// This is used for read-only calculated properties with only a get method.
+ /// </description>
+ /// </item>
/// <item>
/// <term>Assembly Qualified Name</term>
/// <description>
Added: trunk/nhibernate/src/NHibernate/Properties/ReadonlyAccessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/ReadonlyAccessor.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Properties/ReadonlyAccessor.cs 2008-12-25 19:57:53 UTC (rev 3965)
@@ -0,0 +1,76 @@
+using System.Reflection;
+
+namespace NHibernate.Properties
+{
+ /// <summary>
+ /// Access the mapped property through a Property <c>get</c> to get the value
+ /// and do nothing to set the value.
+ /// </summary>
+ /// <remarks>
+ /// This is useful to allow calculated properties in the domain that will never
+ /// be recovered from the DB but can be used for querying.
+ /// </remarks>
+ public class ReadOnlyAccessor : IPropertyAccessor
+ {
+ /// <summary>
+ /// Initializes a new instance of <see cref="ReadOnlyAccessor"/>.
+ /// </summary>
+ public ReadOnlyAccessor()
+ {
+ }
+
+ #region IPropertyAccessor Members
+
+ /// <summary>
+ /// Creates an <see cref="BasicPropertyAccessor.BasicGetter"/> to <c>get</c> the value from the Property.
+ /// </summary>
+ /// <param name="type">The <see cref="System.Type"/> to find the Property in.</param>
+ /// <param name="propertyName">The name of the mapped Property to get.</param>
+ /// <returns>
+ /// The <see cref="BasicPropertyAccessor.BasicGetter"/> to use to get the value of the Property from an
+ /// instance of the <see cref="System.Type"/>.</returns>
+ /// <exception cref="PropertyNotFoundException" >
+ /// Thrown when a Property specified by the <c>propertyName</c> could not
+ /// be found in the <see cref="System.Type"/>.
+ /// </exception>
+ public IGetter GetGetter(System.Type type, string propertyName)
+ {
+ BasicPropertyAccessor.BasicGetter result = BasicPropertyAccessor.GetGetterOrNull(type, propertyName);
+ if (result == null)
+ {
+ throw new PropertyNotFoundException(type, propertyName, "getter");
+ }
+ return result;
+ }
+
+ /// <summary>
+ /// Create a <see cref="NoopAccessor.NoopSetter"/> to do nothing when trying to
+ /// se the value of the mapped Property
+ /// </summary>
+ /// <param name="type">The <see cref="System.Type"/> to find the mapped Property in.</param>
+ /// <param name="propertyName">The name of the mapped Property to set.</param>
+ /// <returns>
+ /// An instance of <see cref="NoopAccessor.NoopSetter"/>.
+ /// </returns>
+ public ISetter GetSetter(System.Type type, string propertyName)
+ {
+ return new NoopSetter();
+ }
+
+ public bool CanAccessThroughReflectionOptimizer
+ {
+ get { return true; }
+ }
+
+ #endregion
+
+ private class NoopSetter : ISetter
+ {
+ public void Set(object target, object value) {}
+
+ public string PropertyName { get { return null; } }
+
+ public MethodInfo Method { get { return null; } }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Fixture.cs 2008-12-25 19:57:53 UTC (rev 3965)
@@ -0,0 +1,44 @@
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.NHSpecificTest.NH1621
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ ISession session;
+
+ public override string BugNumber
+ {
+ get { return "NH1621"; }
+ }
+
+ [Test]
+ public void QueryUsingReadonlyProperty()
+ {
+ using (session = OpenSession())
+ {
+ Nums nums1 = new Nums {ID = 1, NumA = 1, NumB = 2};
+ session.Save(nums1);
+
+ Nums nums2 = new Nums {ID = 2, NumA = 2, NumB = 2 };
+ session.Save(nums2);
+
+ Nums nums3 = new Nums {ID = 3, NumA = 5, NumB = 2 };
+ session.Save(nums3);
+
+ session.Flush();
+ session.Clear();
+
+ var nums = session.CreateQuery("from Nums b where b.Sum > 4").List<Nums>();
+
+ Assert.That(nums, Has.Count(1));
+ Assert.That(nums[0].Sum, Is.EqualTo(7));
+
+ session.Delete("from Nums");
+ session.Flush();
+ session.Close();
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Mappings.hbm.xml 2008-12-25 19:57:53 UTC (rev 3965)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1621"
+ assembly="NHibernate.Test"
+>
+ <class name="Nums" table="nums">
+ <id name="ID">
+ <generator class="assigned"/>
+ </id>
+ <property name="NumA"/>
+ <property name="NumB"/>
+ <property name="Sum" access="readonly"/>
+ </class>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Model.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Model.cs 2008-12-25 19:57:53 UTC (rev 3965)
@@ -0,0 +1,17 @@
+namespace NHibernate.Test.NHSpecificTest.NH1621
+{
+ public class Nums
+ {
+ public virtual int ID { get; set; }
+
+ public virtual int NumA { get; set; }
+ public virtual int NumB { get; set; }
+ public virtual int Sum
+ {
+ get
+ {
+ return NumA + NumB;
+ }
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-17 06:50:00 UTC (rev 3964)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-25 19:57:53 UTC (rev 3965)
@@ -553,6 +553,8 @@
<Compile Include="NHSpecificTest\NH1594\A.cs" />
<Compile Include="NHSpecificTest\NH1594\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1608\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1621\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1621\Model.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -825,6 +827,7 @@
<Compile Include="PropertyRef\KeyPropertyRefFixture.cs" />
<Compile Include="PropertyTest\BackFieldAccessorFixture.cs" />
<Compile Include="PropertyTest\BasicSetterExceptionFixture.cs" />
+ <Compile Include="PropertyTest\ReadonlyAccessorFixture.cs" />
<Compile Include="PropertyTest\FieldAccessorFixture.cs" />
<Compile Include="PropertyTest\FieldCamelCaseFixture.cs" />
<Compile Include="PropertyTest\FieldCamelCaseUnderscoreFixture.cs" />
@@ -1573,6 +1576,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1621\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1609\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1605\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1443\AclassWithSpecific.hbm.xml" />
@@ -1678,4 +1682,4 @@
if exist "$(ProjectDir)hibernate.cfg.xml" (copy "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml")
copy /y "..\..\..\NHibernate.DomainModel\ABC.hbm.xml" "ABC.hbm.xml"</PostBuildEvent>
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
Added: trunk/nhibernate/src/NHibernate.Test/PropertyTest/ReadonlyAccessorFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/PropertyTest/ReadonlyAccessorFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/PropertyTest/ReadonlyAccessorFixture.cs 2008-12-25 19:57:53 UTC (rev 3965)
@@ -0,0 +1,39 @@
+using NHibernate.Properties;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.PropertyTest
+{
+ [TestFixture]
+ public class ReadonlyAccessorFixture
+ {
+ [Test]
+ public void GetValue()
+ {
+ var accessor = PropertyAccessorFactory.GetPropertyAccessor("readonly");
+ var getter = accessor.GetGetter(typeof(Calculation), "Sum");
+
+ Assert.That(getter.Get(new Calculation()), Is.EqualTo(2));
+ }
+
+ [Test]
+ public void SetValue()
+ {
+ var accessor = PropertyAccessorFactory.GetPropertyAccessor("readonly");
+ var getter = accessor.GetGetter(typeof(Calculation), "Sum");
+ var setter = accessor.GetSetter(typeof(Calculation), "Sum");
+
+ var i = new Calculation();
+ Assert.That(getter.Get(i), Is.EqualTo(2));
+ setter.Set(i, 1);
+ Assert.That(getter.Get(i), Is.EqualTo(2));
+ }
+ }
+
+ public class Calculation
+ {
+ public Calculation() { }
+
+ public int Sum { get { return 1 + 1; } }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dav...@us...> - 2008-12-28 22:21:02
|
Revision: 3967
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3967&view=rev
Author: davybrion
Date: 2008-12-28 22:20:58 +0000 (Sun, 28 Dec 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs
trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs
Modified: trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs 2008-12-27 19:53:57 UTC (rev 3966)
+++ trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs 2008-12-28 22:20:58 UTC (rev 3967)
@@ -62,7 +62,7 @@
/// underlying proxied object is needed then it returns the result <see cref="AbstractLazyInitializer.InvokeImplementation"/>
/// which indicates that the Proxy will need to forward to the real implementation.
/// </returns>
- public virtual object Invoke(MethodBase method, object[] args, object proxy)
+ public virtual object Invoke(MethodInfo method, object[] args, object proxy)
{
string methodName = method.Name;
int paramCount = method.GetParameters().Length;
@@ -73,7 +73,7 @@
{
return IdentityEqualityComparer.GetHashCode(proxy);
}
- else if (IsUninitialized && method.Equals(getIdentifierMethod))
+ else if (IsUninitialized && IsEqualToIdentifierMethod(method))
{
return Identifier;
}
@@ -135,5 +135,18 @@
return InvokeImplementation;
}
+ private bool IsEqualToIdentifierMethod(MethodInfo method)
+ {
+ if (getIdentifierMethod != null)
+ {
+ // in the case of inherited identifier methods (from a base class or an iterface) the
+ // passed in MethodBase object is not equal to the getIdentifierMethod instance that we
+ // have... but if their names and return types are identical, then it is the correct
+ // identifier method
+ return method.Name.Equals(getIdentifierMethod.Name) && method.ReturnType.Equals(getIdentifierMethod.ReturnType);
+ }
+
+ return false;
+ }
}
}
Modified: trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2008-12-27 19:53:57 UTC (rev 3966)
+++ trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2008-12-28 22:20:58 UTC (rev 3967)
@@ -19,7 +19,7 @@
private static readonly ILog log = LogManager.GetLogger(typeof(ReflectHelper));
public static BindingFlags AnyVisibilityInstance = BindingFlags.Instance | BindingFlags.Public |
- BindingFlags.NonPublic;
+ BindingFlags.NonPublic;
private ReflectHelper()
{
@@ -29,7 +29,7 @@
private static System.Type[] NoClasses = System.Type.EmptyTypes;
private static readonly MethodInfo Exception_InternalPreserveStackTrace =
- typeof (Exception).GetMethod("InternalPreserveStackTrace", BindingFlags.Instance | BindingFlags.NonPublic);
+ typeof(Exception).GetMethod("InternalPreserveStackTrace", BindingFlags.Instance | BindingFlags.NonPublic);
/// <summary>
/// Determine if the specified <see cref="System.Type"/> overrides the
@@ -41,7 +41,7 @@
{
try
{
- MethodInfo equals = clazz.GetMethod("Equals", new System.Type[] {typeof(object)});
+ MethodInfo equals = clazz.GetMethod("Equals", new System.Type[] { typeof(object) });
if (equals == null)
{
return false;
@@ -127,7 +127,7 @@
System.Type heuristicClass = propertyClass;
if (propertyClass.IsGenericType
- && propertyClass.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
+ && propertyClass.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
{
heuristicClass = propertyClass.GetGenericArguments()[0];
}
@@ -292,15 +292,15 @@
public static bool TryLoadAssembly(string assemblyName)
{
- if(string.IsNullOrEmpty(assemblyName))
+ if (string.IsNullOrEmpty(assemblyName))
return false;
- bool result= true;
+ bool result = true;
try
{
Assembly.Load(assemblyName);
}
- catch(Exception)
+ catch (Exception)
{
result = false;
}
@@ -446,7 +446,7 @@
/// <returns>The unwrapped exception.</returns>
public static Exception UnwrapTargetInvocationException(TargetInvocationException ex)
{
- Exception_InternalPreserveStackTrace.Invoke(ex.InnerException, new Object[] {});
+ Exception_InternalPreserveStackTrace.Invoke(ex.InnerException, new Object[] { });
return ex.InnerException;
}
@@ -472,14 +472,7 @@
}
System.Type[] tps = GetMethodSignature(method);
- try
- {
- return type.GetMethod(method.Name, defaultBindingFlags, null, tps, null);
- }
- catch (Exception)
- {
- return null;
- }
+ return SafeGetMethod(type, method, tps);
}
/// <summary>
@@ -493,6 +486,8 @@
/// </remarks>
public static MethodInfo TryGetMethod(IEnumerable<System.Type> types, MethodInfo method)
{
+ var bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
+
// This method will be used when we support multiple proxy interfaces.
if (types == null)
{
@@ -505,21 +500,16 @@
System.Type[] tps = GetMethodSignature(method);
MethodInfo result = null;
+
foreach (var type in types)
{
- try
+ result = SafeGetMethod(type, method, tps);
+ if (result != null)
{
- result = type.GetMethod(method.Name, defaultBindingFlags, null, tps, null);
- if (result != null)
- {
- return result;
- }
+ return result;
}
- catch (Exception)
- {
- return null;
- }
}
+
return result;
}
@@ -533,5 +523,19 @@
}
return tps;
}
+
+ private static MethodInfo SafeGetMethod(System.Type type, MethodInfo method, System.Type[] tps)
+ {
+ var bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
+
+ try
+ {
+ return type.GetMethod(method.Name, bindingFlags, null, tps, null);
+ }
+ catch (Exception)
+ {
+ return null;
+ }
+ }
}
}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs 2008-12-28 22:20:58 UTC (rev 3967)
@@ -0,0 +1,15 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH1549
+{
+ public class CategoryWithInheritedId : EntityInt32
+ {
+ public virtual string Name { get; set; }
+ }
+
+ public class CategoryWithId
+ {
+ public virtual int Id { get; set; }
+ public virtual string Name { get; set; }
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs 2008-12-28 22:20:58 UTC (rev 3967)
@@ -0,0 +1,7 @@
+namespace NHibernate.Test.NHSpecificTest.NH1549
+{
+ public abstract class EntityInt32
+ {
+ public virtual int Id { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs 2008-12-28 22:20:58 UTC (rev 3967)
@@ -0,0 +1,93 @@
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1549
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ /// <summary>
+ /// Verifies that an entity with a base class containing the id property
+ /// can have the id accessed without loading the entity
+ /// </summary>
+ [Test]
+ public void CanLoadForEntitiesWithInheritedIds()
+ {
+ //create some related products
+ var category = new CategoryWithInheritedId {Name = "Fruit"};
+ var product = new ProductWithInheritedId {CategoryWithInheritedId = category};
+
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction trans = session.BeginTransaction())
+ {
+ session.Save(category);
+ session.Save(product);
+ trans.Commit();
+ }
+ }
+
+ ProductWithInheritedId restoredProductWithInheritedId;
+
+ //restore the product from the db in another session so that
+ //the association is a proxy
+ using (ISession session = OpenSession())
+ {
+ restoredProductWithInheritedId = session.Get<ProductWithInheritedId>(product.Id);
+ }
+
+ //verify that the category is a proxy
+ Assert.IsFalse(NHibernateUtil.IsInitialized(restoredProductWithInheritedId.CategoryWithInheritedId));
+
+ //we should be able to access the id of the category outside of the session
+ Assert.AreEqual(category.Id, restoredProductWithInheritedId.CategoryWithInheritedId.Id);
+ }
+
+ [Test]
+ public void CanLoadForEntitiesWithTheirOwnIds()
+ {
+ //create some related products
+ var category = new CategoryWithId { Name = "Fruit" };
+ var product = new ProductWithId { CategoryWithId = category };
+
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction trans = session.BeginTransaction())
+ {
+ session.Save(category);
+ session.Save(product);
+ trans.Commit();
+ }
+ }
+
+ ProductWithId restoredProductWithInheritedId;
+
+ //restore the product from the db in another session so that
+ //the association is a proxy
+ using (ISession session = OpenSession())
+ {
+ restoredProductWithInheritedId = session.Get<ProductWithId>(product.Id);
+ }
+
+ //verify that the category is a proxy
+ Assert.IsFalse(NHibernateUtil.IsInitialized(restoredProductWithInheritedId.CategoryWithId));
+
+ //we should be able to access the id of the category outside of the session
+ Assert.AreEqual(category.Id, restoredProductWithInheritedId.CategoryWithId.Id);
+ }
+
+ protected override void OnTearDown()
+ {
+ using (ISession session = OpenSession()) {
+
+ using (ITransaction trans = session.BeginTransaction())
+ {
+ session.Delete("from ProductWithId");
+ session.Delete("from CategoryWithId");
+ session.Delete("from ProductWithInheritedId");
+ session.Delete("from CategoryWithInheritedId");
+ trans.Commit();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml 2008-12-28 22:20:58 UTC (rev 3967)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping
+ xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1549"
+ assembly="NHibernate.Test">
+
+ <class name="CategoryWithInheritedId">
+ <id name="Id" type="System.Int32">
+ <generator class="native" />
+ </id>
+ <property name="Name" />
+ </class>
+
+ <class name="ProductWithInheritedId" lazy="false">
+ <id name="Id" type="System.Int32">
+ <generator class="native" />
+ </id>
+ <many-to-one name="CategoryWithInheritedId"/>
+ </class>
+
+ <class name="CategoryWithId">
+ <id name="Id" type="System.Int32">
+ <generator class="native" />
+ </id>
+ <property name="Name" />
+ </class>
+
+ <class name="ProductWithId" lazy="false">
+ <id name="Id" type="System.Int32">
+ <generator class="native" />
+ </id>
+ <many-to-one name="CategoryWithId"/>
+ </class>
+
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs 2008-12-28 22:20:58 UTC (rev 3967)
@@ -0,0 +1,15 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH1549
+{
+ public class ProductWithInheritedId : EntityInt32
+ {
+ public CategoryWithInheritedId CategoryWithInheritedId { get; set; }
+ }
+
+ public class ProductWithId
+ {
+ public virtual int Id { get; set; }
+ public CategoryWithId CategoryWithId { get; set; }
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-27 19:53:57 UTC (rev 3966)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-28 22:20:58 UTC (rev 3967)
@@ -378,6 +378,10 @@
<Compile Include="NHSpecificTest\NH1274ExportExclude\Person.cs" />
<Compile Include="NHSpecificTest\NH1443\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1521\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1549\CategoryWithInheritedId.cs" />
+ <Compile Include="NHSpecificTest\NH1549\EntityInt32.cs" />
+ <Compile Include="NHSpecificTest\NH1549\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1549\ProductWithInheritedId.cs" />
<Compile Include="NHSpecificTest\NH1605\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1609\Entities.cs" />
<Compile Include="NHSpecificTest\NH1609\Fixture.cs" />
@@ -1577,6 +1581,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1549\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1521\AclassWithSpecific.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1521\AclassWithNothing.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1521\AclassWithDefault.hbm.xml" />
Modified: trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs 2008-12-27 19:53:57 UTC (rev 3966)
+++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs 2008-12-28 22:20:58 UTC (rev 3967)
@@ -56,11 +56,13 @@
[Test]
public void TryGetMethod()
{
- const BindingFlags bf = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;
- MethodInfo mig = typeof (MyBaseImplementation).GetMethod("get_Id", bf);
+ //const BindingFlags bf = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;
+ const BindingFlags bf = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
+ MethodInfo mig = typeof(MyBaseImplementation).GetMethod("get_Id", bf);
MethodInfo mis = typeof(MyBaseImplementation).GetMethod("set_Id", bf);
MethodInfo mng = typeof(MyBaseImplementation).GetMethod("get_Name", bf);
MethodInfo mns = typeof(MyBaseImplementation).GetMethod("set_Name", bf);
+
Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mig), Is.Not.Null);
Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mis), Is.Null);
Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mng), Is.Not.Null);
@@ -78,6 +80,20 @@
Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mns), Is.Not.Null);
Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mdg), Is.Not.Null);
Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mds), Is.Null);
+
+ MethodInfo mdig = typeof(MyDerivedImplementation).GetMethod("get_Id", bf);
+ MethodInfo mdis = typeof(MyDerivedImplementation).GetMethod("set_Id", bf);
+ MethodInfo mdng = typeof(MyDerivedImplementation).GetMethod("get_Name", bf);
+ MethodInfo mdns = typeof(MyDerivedImplementation).GetMethod("set_Name", bf);
+ MethodInfo mddg = typeof(MyDerivedImplementation).GetMethod("get_Description", bf);
+ MethodInfo mdds = typeof(MyDerivedImplementation).GetMethod("set_Description", bf);
+
+ Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mdig), Is.Not.Null);
+ Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mdis), Is.Null);
+ Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mdng), Is.Not.Null);
+ Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mdns), Is.Not.Null);
+ Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mddg), Is.Not.Null);
+ Assert.That(ReflectHelper.TryGetMethod(new[] { typeof(IMyBaseInterface), typeof(IMyInterface) }, mdds), Is.Null);
}
}
@@ -115,11 +131,15 @@
public string Name { get; set; }
}
+ public class MyDerivedImplementation : MyBaseImplementation, IMyInterface
+ {
+ public string Description { get; set; }
+ }
+
public class MyImplementation: IMyInterface
{
public int Id{ get; set; }
public string Name { get; set; }
public string Description { get; set; }
}
-
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: T. T. <te...@gm...> - 2008-12-28 22:23:28
|
Commit log? Tuna Toksöz http://tunatoksoz.com Typos included to enhance the readers attention! On Mon, Dec 29, 2008 at 12:20 AM, <dav...@us...> wrote: > Revision: 3967 > > http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3967&view=rev > Author: davybrion > Date: 2008-12-28 22:20:58 +0000 (Sun, 28 Dec 2008) > > Log Message: > ----------- > > > Modified Paths: > -------------- > trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs > trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs > trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj > trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs > > Added Paths: > ----------- > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ > > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs > > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs > > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml > > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs > > Modified: > trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs > 2008-12-27 19:53:57 UTC (rev 3966) > +++ trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs > 2008-12-28 22:20:58 UTC (rev 3967) > @@ -62,7 +62,7 @@ > /// underlying proxied object is needed then it returns the > result <see cref="AbstractLazyInitializer.InvokeImplementation"/> > /// which indicates that the Proxy will need to forward to > the real implementation. > /// </returns> > - public virtual object Invoke(MethodBase method, object[] > args, object proxy) > + public virtual object Invoke(MethodInfo method, object[] > args, object proxy) > { > string methodName = method.Name; > int paramCount = method.GetParameters().Length; > @@ -73,7 +73,7 @@ > { > return > IdentityEqualityComparer.GetHashCode(proxy); > } > - else if (IsUninitialized && > method.Equals(getIdentifierMethod)) > + else if (IsUninitialized && > IsEqualToIdentifierMethod(method)) > { > return Identifier; > } > @@ -135,5 +135,18 @@ > return InvokeImplementation; > } > > + private bool IsEqualToIdentifierMethod(MethodInfo method) > + { > + if (getIdentifierMethod != null) > + { > + // in the case of inherited identifier > methods (from a base class or an iterface) the > + // passed in MethodBase object is not equal > to the getIdentifierMethod instance that we > + // have... but if their names and return > types are identical, then it is the correct > + // identifier method > + return > method.Name.Equals(getIdentifierMethod.Name) && > method.ReturnType.Equals(getIdentifierMethod.ReturnType); > + } > + > + return false; > + } > } > } > > Modified: trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2008-12-27 > 19:53:57 UTC (rev 3966) > +++ trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2008-12-28 > 22:20:58 UTC (rev 3967) > @@ -19,7 +19,7 @@ > private static readonly ILog log = > LogManager.GetLogger(typeof(ReflectHelper)); > > public static BindingFlags AnyVisibilityInstance = > BindingFlags.Instance | BindingFlags.Public | > - > BindingFlags.NonPublic; > + > BindingFlags.NonPublic; > > private ReflectHelper() > { > @@ -29,7 +29,7 @@ > private static System.Type[] NoClasses = > System.Type.EmptyTypes; > > private static readonly MethodInfo > Exception_InternalPreserveStackTrace = > - typeof > (Exception).GetMethod("InternalPreserveStackTrace", BindingFlags.Instance | > BindingFlags.NonPublic); > + > typeof(Exception).GetMethod("InternalPreserveStackTrace", > BindingFlags.Instance | BindingFlags.NonPublic); > > /// <summary> > /// Determine if the specified <see cref="System.Type"/> > overrides the > @@ -41,7 +41,7 @@ > { > try > { > - MethodInfo equals = > clazz.GetMethod("Equals", new System.Type[] {typeof(object)}); > + MethodInfo equals = > clazz.GetMethod("Equals", new System.Type[] { typeof(object) }); > if (equals == null) > { > return false; > @@ -127,7 +127,7 @@ > System.Type heuristicClass = propertyClass; > > if (propertyClass.IsGenericType > - && > propertyClass.GetGenericTypeDefinition().Equals(typeof(Nullable<>))) > + && > propertyClass.GetGenericTypeDefinition().Equals(typeof(Nullable<>))) > { > heuristicClass = > propertyClass.GetGenericArguments()[0]; > } > @@ -292,15 +292,15 @@ > > public static bool TryLoadAssembly(string assemblyName) > { > - if(string.IsNullOrEmpty(assemblyName)) > + if (string.IsNullOrEmpty(assemblyName)) > return false; > > - bool result= true; > + bool result = true; > try > { > Assembly.Load(assemblyName); > } > - catch(Exception) > + catch (Exception) > { > result = false; > } > @@ -446,7 +446,7 @@ > /// <returns>The unwrapped exception.</returns> > public static Exception > UnwrapTargetInvocationException(TargetInvocationException ex) > { > - > Exception_InternalPreserveStackTrace.Invoke(ex.InnerException, new Object[] > {}); > + > Exception_InternalPreserveStackTrace.Invoke(ex.InnerException, new Object[] > { }); > return ex.InnerException; > } > > @@ -472,14 +472,7 @@ > } > > System.Type[] tps = GetMethodSignature(method); > - try > - { > - return type.GetMethod(method.Name, > defaultBindingFlags, null, tps, null); > - } > - catch (Exception) > - { > - return null; > - } > + return SafeGetMethod(type, method, tps); > } > > /// <summary> > @@ -493,6 +486,8 @@ > /// </remarks> > public static MethodInfo > TryGetMethod(IEnumerable<System.Type> types, MethodInfo method) > { > + var bindingFlags = BindingFlags.Instance | > BindingFlags.Public | BindingFlags.NonPublic; > + > // This method will be used when we support multiple > proxy interfaces. > if (types == null) > { > @@ -505,21 +500,16 @@ > > System.Type[] tps = GetMethodSignature(method); > MethodInfo result = null; > + > foreach (var type in types) > { > - try > + result = SafeGetMethod(type, method, tps); > + if (result != null) > { > - result = > type.GetMethod(method.Name, defaultBindingFlags, null, tps, null); > - if (result != null) > - { > - return result; > - } > + return result; > } > - catch (Exception) > - { > - return null; > - } > } > + > return result; > } > > @@ -533,5 +523,19 @@ > } > return tps; > } > + > + private static MethodInfo SafeGetMethod(System.Type type, > MethodInfo method, System.Type[] tps) > + { > + var bindingFlags = BindingFlags.Instance | > BindingFlags.Public | BindingFlags.NonPublic; > + > + try > + { > + return type.GetMethod(method.Name, > bindingFlags, null, tps, null); > + } > + catch (Exception) > + { > + return null; > + } > + } > } > } > > Added: > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs > =================================================================== > --- > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs > (rev 0) > +++ > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs > 2008-12-28 22:20:58 UTC (rev 3967) > @@ -0,0 +1,15 @@ > +using System; > + > +namespace NHibernate.Test.NHSpecificTest.NH1549 > +{ > + public class CategoryWithInheritedId : EntityInt32 > + { > + public virtual string Name { get; set; } > + } > + > + public class CategoryWithId > + { > + public virtual int Id { get; set; } > + public virtual string Name { get; set; } > + } > +} > \ No newline at end of file > > > Property changes on: > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs > ___________________________________________________________________ > Added: svn:mergeinfo > + > > Added: > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs > =================================================================== > --- > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs > (rev 0) > +++ > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs > 2008-12-28 22:20:58 UTC (rev 3967) > @@ -0,0 +1,7 @@ > +namespace NHibernate.Test.NHSpecificTest.NH1549 > +{ > + public abstract class EntityInt32 > + { > + public virtual int Id { get; set; } > + } > +} > \ No newline at end of file > > Added: > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs > =================================================================== > --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs > (rev 0) > +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs > 2008-12-28 22:20:58 UTC (rev 3967) > @@ -0,0 +1,93 @@ > +using NUnit.Framework; > + > +namespace NHibernate.Test.NHSpecificTest.NH1549 > +{ > + [TestFixture] > + public class Fixture : BugTestCase > + { > + /// <summary> > + /// Verifies that an entity with a base class containing > the id property > + /// can have the id accessed without loading the entity > + /// </summary> > + [Test] > + public void CanLoadForEntitiesWithInheritedIds() > + { > + //create some related products > + var category = new CategoryWithInheritedId {Name = > "Fruit"}; > + var product = new ProductWithInheritedId > {CategoryWithInheritedId = category}; > + > + using (ISession session = OpenSession()) > + { > + using (ITransaction trans = > session.BeginTransaction()) > + { > + session.Save(category); > + session.Save(product); > + trans.Commit(); > + } > + } > + > + ProductWithInheritedId > restoredProductWithInheritedId; > + > + //restore the product from the db in another > session so that > + //the association is a proxy > + using (ISession session = OpenSession()) > + { > + restoredProductWithInheritedId = > session.Get<ProductWithInheritedId>(product.Id); > + } > + > + //verify that the category is a proxy > + > Assert.IsFalse(NHibernateUtil.IsInitialized(restoredProductWithInheritedId.CategoryWithInheritedId)); > + > + //we should be able to access the id of the > category outside of the session > + Assert.AreEqual(category.Id, > restoredProductWithInheritedId.CategoryWithInheritedId.Id); > + } > + > + [Test] > + public void CanLoadForEntitiesWithTheirOwnIds() > + { > + //create some related products > + var category = new CategoryWithId { Name = "Fruit" > }; > + var product = new ProductWithId { CategoryWithId = > category }; > + > + using (ISession session = OpenSession()) > + { > + using (ITransaction trans = > session.BeginTransaction()) > + { > + session.Save(category); > + session.Save(product); > + trans.Commit(); > + } > + } > + > + ProductWithId restoredProductWithInheritedId; > + > + //restore the product from the db in another > session so that > + //the association is a proxy > + using (ISession session = OpenSession()) > + { > + restoredProductWithInheritedId = > session.Get<ProductWithId>(product.Id); > + } > + > + //verify that the category is a proxy > + > Assert.IsFalse(NHibernateUtil.IsInitialized(restoredProductWithInheritedId.CategoryWithId)); > + > + //we should be able to access the id of the > category outside of the session > + Assert.AreEqual(category.Id, > restoredProductWithInheritedId.CategoryWithId.Id); > + } > + > + protected override void OnTearDown() > + { > + using (ISession session = OpenSession()) { > + > + using (ITransaction trans = > session.BeginTransaction()) > + { > + session.Delete("from > ProductWithId"); > + session.Delete("from > CategoryWithId"); > + session.Delete("from > ProductWithInheritedId"); > + session.Delete("from > CategoryWithInheritedId"); > + trans.Commit(); > + } > + } > + } > + } > +} > \ No newline at end of file > > Added: > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml > =================================================================== > --- > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml > (rev 0) > +++ > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml > 2008-12-28 22:20:58 UTC (rev 3967) > @@ -0,0 +1,35 @@ > +<?xml version="1.0" encoding="utf-8" ?> > +<hibernate-mapping > + xmlns="urn:nhibernate-mapping-2.2" > + namespace="NHibernate.Test.NHSpecificTest.NH1549" > + assembly="NHibernate.Test"> > + > + <class name="CategoryWithInheritedId"> > + <id name="Id" type="System.Int32"> > + <generator class="native" /> > + </id> > + <property name="Name" /> > + </class> > + > + <class name="ProductWithInheritedId" lazy="false"> > + <id name="Id" type="System.Int32"> > + <generator class="native" /> > + </id> > + <many-to-one name="CategoryWithInheritedId"/> > + </class> > + > + <class name="CategoryWithId"> > + <id name="Id" type="System.Int32"> > + <generator class="native" /> > + </id> > + <property name="Name" /> > + </class> > + > + <class name="ProductWithId" lazy="false"> > + <id name="Id" type="System.Int32"> > + <generator class="native" /> > + </id> > + <many-to-one name="CategoryWithId"/> > + </class> > + > +</hibernate-mapping> > > Added: > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs > =================================================================== > --- > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs > (rev 0) > +++ > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs > 2008-12-28 22:20:58 UTC (rev 3967) > @@ -0,0 +1,15 @@ > +using System; > + > +namespace NHibernate.Test.NHSpecificTest.NH1549 > +{ > + public class ProductWithInheritedId : EntityInt32 > + { > + public CategoryWithInheritedId CategoryWithInheritedId { > get; set; } > + } > + > + public class ProductWithId > + { > + public virtual int Id { get; set; } > + public CategoryWithId CategoryWithId { get; set; } > + } > +} > \ No newline at end of file > > > Property changes on: > trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs > ___________________________________________________________________ > Added: svn:mergeinfo > + > > Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj > =================================================================== > --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-27 > 19:53:57 UTC (rev 3966) > +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-28 > 22:20:58 UTC (rev 3967) > @@ -378,6 +378,10 @@ > <Compile Include="NHSpecificTest\NH1274ExportExclude\Person.cs" /> > <Compile Include="NHSpecificTest\NH1443\Fixture.cs" /> > <Compile Include="NHSpecificTest\NH1521\Fixture.cs" /> > + <Compile Include="NHSpecificTest\NH1549\CategoryWithInheritedId.cs" /> > + <Compile Include="NHSpecificTest\NH1549\EntityInt32.cs" /> > + <Compile Include="NHSpecificTest\NH1549\Fixture.cs" /> > + <Compile Include="NHSpecificTest\NH1549\ProductWithInheritedId.cs" /> > <Compile Include="NHSpecificTest\NH1605\Fixture.cs" /> > <Compile Include="NHSpecificTest\NH1609\Entities.cs" /> > <Compile Include="NHSpecificTest\NH1609\Fixture.cs" /> > @@ -1577,6 +1581,7 @@ > <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> > <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> > <Content Include="DynamicEntity\package.html" /> > + <EmbeddedResource Include="NHSpecificTest\NH1549\Mappings.hbm.xml" /> > <EmbeddedResource > Include="NHSpecificTest\NH1521\AclassWithSpecific.hbm.xml" /> > <EmbeddedResource > Include="NHSpecificTest\NH1521\AclassWithNothing.hbm.xml" /> > <EmbeddedResource > Include="NHSpecificTest\NH1521\AclassWithDefault.hbm.xml" /> > > Modified: > trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs > =================================================================== > --- > trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs > 2008-12-27 19:53:57 UTC (rev 3966) > +++ > trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs > 2008-12-28 22:20:58 UTC (rev 3967) > @@ -56,11 +56,13 @@ > [Test] > public void TryGetMethod() > { > - const BindingFlags bf = BindingFlags.Instance | > BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; > - MethodInfo mig = typeof > (MyBaseImplementation).GetMethod("get_Id", bf); > + //const BindingFlags bf = BindingFlags.Instance | > BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; > + const BindingFlags bf = BindingFlags.Instance | > BindingFlags.Public | BindingFlags.NonPublic; > + MethodInfo mig = > typeof(MyBaseImplementation).GetMethod("get_Id", bf); > MethodInfo mis = > typeof(MyBaseImplementation).GetMethod("set_Id", bf); > MethodInfo mng = > typeof(MyBaseImplementation).GetMethod("get_Name", bf); > MethodInfo mns = > typeof(MyBaseImplementation).GetMethod("set_Name", bf); > + > > Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mig), > Is.Not.Null); > > Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mis), > Is.Null); > > Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mng), > Is.Not.Null); > @@ -78,6 +80,20 @@ > Assert.That(ReflectHelper.TryGetMethod(new[] { > typeof(IMyBaseInterface), typeof(IMyInterface) }, mns), Is.Not.Null); > Assert.That(ReflectHelper.TryGetMethod(new[] { > typeof(IMyBaseInterface), typeof(IMyInterface) }, mdg), Is.Not.Null); > Assert.That(ReflectHelper.TryGetMethod(new[] { > typeof(IMyBaseInterface), typeof(IMyInterface) }, mds), Is.Null); > + > + MethodInfo mdig = > typeof(MyDerivedImplementation).GetMethod("get_Id", bf); > + MethodInfo mdis = > typeof(MyDerivedImplementation).GetMethod("set_Id", bf); > + MethodInfo mdng = > typeof(MyDerivedImplementation).GetMethod("get_Name", bf); > + MethodInfo mdns = > typeof(MyDerivedImplementation).GetMethod("set_Name", bf); > + MethodInfo mddg = > typeof(MyDerivedImplementation).GetMethod("get_Description", bf); > + MethodInfo mdds = > typeof(MyDerivedImplementation).GetMethod("set_Description", bf); > + > + Assert.That(ReflectHelper.TryGetMethod(new[] { > typeof(IMyBaseInterface), typeof(IMyInterface) }, mdig), Is.Not.Null); > + Assert.That(ReflectHelper.TryGetMethod(new[] { > typeof(IMyBaseInterface), typeof(IMyInterface) }, mdis), Is.Null); > + Assert.That(ReflectHelper.TryGetMethod(new[] { > typeof(IMyBaseInterface), typeof(IMyInterface) }, mdng), Is.Not.Null); > + Assert.That(ReflectHelper.TryGetMethod(new[] { > typeof(IMyBaseInterface), typeof(IMyInterface) }, mdns), Is.Not.Null); > + Assert.That(ReflectHelper.TryGetMethod(new[] { > typeof(IMyBaseInterface), typeof(IMyInterface) }, mddg), Is.Not.Null); > + Assert.That(ReflectHelper.TryGetMethod(new[] { > typeof(IMyBaseInterface), typeof(IMyInterface) }, mdds), Is.Null); > } > } > > @@ -115,11 +131,15 @@ > public string Name { get; set; } > } > > + public class MyDerivedImplementation : MyBaseImplementation, > IMyInterface > + { > + public string Description { get; set; } > + } > + > public class MyImplementation: IMyInterface > { > public int Id{ get; set; } > public string Name { get; set; } > public string Description { get; set; } > } > - > } > \ No newline at end of file > > > This was sent by the SourceForge.net collaborative development platform, > the world's largest Open Source development site. > > > ------------------------------------------------------------------------------ > _______________________________________________ > Nhibernate-commit mailing list > Nhi...@li... > https://lists.sourceforge.net/lists/listinfo/nhibernate-commit > |
|
From: Davy B. <ra...@da...> - 2008-12-28 22:33:43
|
yeah sorry, forgot to add the commit message.... this commit fixed NH-1549 and NH-1590 On Sun, Dec 28, 2008 at 11:23 PM, Tuna Toksöz <te...@gm...> wrote: > Commit log? > > > Tuna Toksöz > http://tunatoksoz.com > > Typos included to enhance the readers attention! > > > > > On Mon, Dec 29, 2008 at 12:20 AM, <dav...@us...> wrote: > >> Revision: 3967 >> >> http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3967&view=rev >> Author: davybrion >> Date: 2008-12-28 22:20:58 +0000 (Sun, 28 Dec 2008) >> >> Log Message: >> ----------- >> >> >> Modified Paths: >> -------------- >> trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs >> trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs >> trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj >> >> trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs >> >> Added Paths: >> ----------- >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ >> >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs >> >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs >> >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml >> >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs >> >> Modified: >> trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs >> =================================================================== >> --- trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs >> 2008-12-27 19:53:57 UTC (rev 3966) >> +++ trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs >> 2008-12-28 22:20:58 UTC (rev 3967) >> @@ -62,7 +62,7 @@ >> /// underlying proxied object is needed then it returns the >> result <see cref="AbstractLazyInitializer.InvokeImplementation"/> >> /// which indicates that the Proxy will need to forward to >> the real implementation. >> /// </returns> >> - public virtual object Invoke(MethodBase method, object[] >> args, object proxy) >> + public virtual object Invoke(MethodInfo method, object[] >> args, object proxy) >> { >> string methodName = method.Name; >> int paramCount = method.GetParameters().Length; >> @@ -73,7 +73,7 @@ >> { >> return >> IdentityEqualityComparer.GetHashCode(proxy); >> } >> - else if (IsUninitialized && >> method.Equals(getIdentifierMethod)) >> + else if (IsUninitialized && >> IsEqualToIdentifierMethod(method)) >> { >> return Identifier; >> } >> @@ -135,5 +135,18 @@ >> return InvokeImplementation; >> } >> >> + private bool IsEqualToIdentifierMethod(MethodInfo method) >> + { >> + if (getIdentifierMethod != null) >> + { >> + // in the case of inherited identifier >> methods (from a base class or an iterface) the >> + // passed in MethodBase object is not >> equal to the getIdentifierMethod instance that we >> + // have... but if their names and return >> types are identical, then it is the correct >> + // identifier method >> + return >> method.Name.Equals(getIdentifierMethod.Name) && >> method.ReturnType.Equals(getIdentifierMethod.ReturnType); >> + } >> + >> + return false; >> + } >> } >> } >> >> Modified: trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs >> =================================================================== >> --- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2008-12-27 >> 19:53:57 UTC (rev 3966) >> +++ trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2008-12-28 >> 22:20:58 UTC (rev 3967) >> @@ -19,7 +19,7 @@ >> private static readonly ILog log = >> LogManager.GetLogger(typeof(ReflectHelper)); >> >> public static BindingFlags AnyVisibilityInstance = >> BindingFlags.Instance | BindingFlags.Public | >> - >> BindingFlags.NonPublic; >> + >> BindingFlags.NonPublic; >> >> private ReflectHelper() >> { >> @@ -29,7 +29,7 @@ >> private static System.Type[] NoClasses = >> System.Type.EmptyTypes; >> >> private static readonly MethodInfo >> Exception_InternalPreserveStackTrace = >> - typeof >> (Exception).GetMethod("InternalPreserveStackTrace", BindingFlags.Instance | >> BindingFlags.NonPublic); >> + >> typeof(Exception).GetMethod("InternalPreserveStackTrace", >> BindingFlags.Instance | BindingFlags.NonPublic); >> >> /// <summary> >> /// Determine if the specified <see cref="System.Type"/> >> overrides the >> @@ -41,7 +41,7 @@ >> { >> try >> { >> - MethodInfo equals = >> clazz.GetMethod("Equals", new System.Type[] {typeof(object)}); >> + MethodInfo equals = >> clazz.GetMethod("Equals", new System.Type[] { typeof(object) }); >> if (equals == null) >> { >> return false; >> @@ -127,7 +127,7 @@ >> System.Type heuristicClass = propertyClass; >> >> if (propertyClass.IsGenericType >> - && >> propertyClass.GetGenericTypeDefinition().Equals(typeof(Nullable<>))) >> + && >> propertyClass.GetGenericTypeDefinition().Equals(typeof(Nullable<>))) >> { >> heuristicClass = >> propertyClass.GetGenericArguments()[0]; >> } >> @@ -292,15 +292,15 @@ >> >> public static bool TryLoadAssembly(string assemblyName) >> { >> - if(string.IsNullOrEmpty(assemblyName)) >> + if (string.IsNullOrEmpty(assemblyName)) >> return false; >> >> - bool result= true; >> + bool result = true; >> try >> { >> Assembly.Load(assemblyName); >> } >> - catch(Exception) >> + catch (Exception) >> { >> result = false; >> } >> @@ -446,7 +446,7 @@ >> /// <returns>The unwrapped exception.</returns> >> public static Exception >> UnwrapTargetInvocationException(TargetInvocationException ex) >> { >> - >> Exception_InternalPreserveStackTrace.Invoke(ex.InnerException, new Object[] >> {}); >> + >> Exception_InternalPreserveStackTrace.Invoke(ex.InnerException, new Object[] >> { }); >> return ex.InnerException; >> } >> >> @@ -472,14 +472,7 @@ >> } >> >> System.Type[] tps = GetMethodSignature(method); >> - try >> - { >> - return type.GetMethod(method.Name, >> defaultBindingFlags, null, tps, null); >> - } >> - catch (Exception) >> - { >> - return null; >> - } >> + return SafeGetMethod(type, method, tps); >> } >> >> /// <summary> >> @@ -493,6 +486,8 @@ >> /// </remarks> >> public static MethodInfo >> TryGetMethod(IEnumerable<System.Type> types, MethodInfo method) >> { >> + var bindingFlags = BindingFlags.Instance | >> BindingFlags.Public | BindingFlags.NonPublic; >> + >> // This method will be used when we support >> multiple proxy interfaces. >> if (types == null) >> { >> @@ -505,21 +500,16 @@ >> >> System.Type[] tps = GetMethodSignature(method); >> MethodInfo result = null; >> + >> foreach (var type in types) >> { >> - try >> + result = SafeGetMethod(type, method, tps); >> + if (result != null) >> { >> - result = >> type.GetMethod(method.Name, defaultBindingFlags, null, tps, null); >> - if (result != null) >> - { >> - return result; >> - } >> + return result; >> } >> - catch (Exception) >> - { >> - return null; >> - } >> } >> + >> return result; >> } >> >> @@ -533,5 +523,19 @@ >> } >> return tps; >> } >> + >> + private static MethodInfo SafeGetMethod(System.Type type, >> MethodInfo method, System.Type[] tps) >> + { >> + var bindingFlags = BindingFlags.Instance | >> BindingFlags.Public | BindingFlags.NonPublic; >> + >> + try >> + { >> + return type.GetMethod(method.Name, >> bindingFlags, null, tps, null); >> + } >> + catch (Exception) >> + { >> + return null; >> + } >> + } >> } >> } >> >> Added: >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs >> =================================================================== >> --- >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs >> (rev 0) >> +++ >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs >> 2008-12-28 22:20:58 UTC (rev 3967) >> @@ -0,0 +1,15 @@ >> +using System; >> + >> +namespace NHibernate.Test.NHSpecificTest.NH1549 >> +{ >> + public class CategoryWithInheritedId : EntityInt32 >> + { >> + public virtual string Name { get; set; } >> + } >> + >> + public class CategoryWithId >> + { >> + public virtual int Id { get; set; } >> + public virtual string Name { get; set; } >> + } >> +} >> \ No newline at end of file >> >> >> Property changes on: >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs >> ___________________________________________________________________ >> Added: svn:mergeinfo >> + >> >> Added: >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs >> =================================================================== >> --- >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs >> (rev 0) >> +++ >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs >> 2008-12-28 22:20:58 UTC (rev 3967) >> @@ -0,0 +1,7 @@ >> +namespace NHibernate.Test.NHSpecificTest.NH1549 >> +{ >> + public abstract class EntityInt32 >> + { >> + public virtual int Id { get; set; } >> + } >> +} >> \ No newline at end of file >> >> Added: >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs >> =================================================================== >> --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs >> (rev 0) >> +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs >> 2008-12-28 22:20:58 UTC (rev 3967) >> @@ -0,0 +1,93 @@ >> +using NUnit.Framework; >> + >> +namespace NHibernate.Test.NHSpecificTest.NH1549 >> +{ >> + [TestFixture] >> + public class Fixture : BugTestCase >> + { >> + /// <summary> >> + /// Verifies that an entity with a base class containing >> the id property >> + /// can have the id accessed without loading the entity >> + /// </summary> >> + [Test] >> + public void CanLoadForEntitiesWithInheritedIds() >> + { >> + //create some related products >> + var category = new CategoryWithInheritedId {Name = >> "Fruit"}; >> + var product = new ProductWithInheritedId >> {CategoryWithInheritedId = category}; >> + >> + using (ISession session = OpenSession()) >> + { >> + using (ITransaction trans = >> session.BeginTransaction()) >> + { >> + session.Save(category); >> + session.Save(product); >> + trans.Commit(); >> + } >> + } >> + >> + ProductWithInheritedId >> restoredProductWithInheritedId; >> + >> + //restore the product from the db in another >> session so that >> + //the association is a proxy >> + using (ISession session = OpenSession()) >> + { >> + restoredProductWithInheritedId = >> session.Get<ProductWithInheritedId>(product.Id); >> + } >> + >> + //verify that the category is a proxy >> + >> Assert.IsFalse(NHibernateUtil.IsInitialized(restoredProductWithInheritedId.CategoryWithInheritedId)); >> + >> + //we should be able to access the id of the >> category outside of the session >> + Assert.AreEqual(category.Id, >> restoredProductWithInheritedId.CategoryWithInheritedId.Id); >> + } >> + >> + [Test] >> + public void CanLoadForEntitiesWithTheirOwnIds() >> + { >> + //create some related products >> + var category = new CategoryWithId { Name = "Fruit" >> }; >> + var product = new ProductWithId { CategoryWithId = >> category }; >> + >> + using (ISession session = OpenSession()) >> + { >> + using (ITransaction trans = >> session.BeginTransaction()) >> + { >> + session.Save(category); >> + session.Save(product); >> + trans.Commit(); >> + } >> + } >> + >> + ProductWithId restoredProductWithInheritedId; >> + >> + //restore the product from the db in another >> session so that >> + //the association is a proxy >> + using (ISession session = OpenSession()) >> + { >> + restoredProductWithInheritedId = >> session.Get<ProductWithId>(product.Id); >> + } >> + >> + //verify that the category is a proxy >> + >> Assert.IsFalse(NHibernateUtil.IsInitialized(restoredProductWithInheritedId.CategoryWithId)); >> + >> + //we should be able to access the id of the >> category outside of the session >> + Assert.AreEqual(category.Id, >> restoredProductWithInheritedId.CategoryWithId.Id); >> + } >> + >> + protected override void OnTearDown() >> + { >> + using (ISession session = OpenSession()) { >> + >> + using (ITransaction trans = >> session.BeginTransaction()) >> + { >> + session.Delete("from >> ProductWithId"); >> + session.Delete("from >> CategoryWithId"); >> + session.Delete("from >> ProductWithInheritedId"); >> + session.Delete("from >> CategoryWithInheritedId"); >> + trans.Commit(); >> + } >> + } >> + } >> + } >> +} >> \ No newline at end of file >> >> Added: >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml >> =================================================================== >> --- >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml >> (rev 0) >> +++ >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml >> 2008-12-28 22:20:58 UTC (rev 3967) >> @@ -0,0 +1,35 @@ >> +<?xml version="1.0" encoding="utf-8" ?> >> +<hibernate-mapping >> + xmlns="urn:nhibernate-mapping-2.2" >> + namespace="NHibernate.Test.NHSpecificTest.NH1549" >> + assembly="NHibernate.Test"> >> + >> + <class name="CategoryWithInheritedId"> >> + <id name="Id" type="System.Int32"> >> + <generator class="native" /> >> + </id> >> + <property name="Name" /> >> + </class> >> + >> + <class name="ProductWithInheritedId" lazy="false"> >> + <id name="Id" type="System.Int32"> >> + <generator class="native" /> >> + </id> >> + <many-to-one name="CategoryWithInheritedId"/> >> + </class> >> + >> + <class name="CategoryWithId"> >> + <id name="Id" type="System.Int32"> >> + <generator class="native" /> >> + </id> >> + <property name="Name" /> >> + </class> >> + >> + <class name="ProductWithId" lazy="false"> >> + <id name="Id" type="System.Int32"> >> + <generator class="native" /> >> + </id> >> + <many-to-one name="CategoryWithId"/> >> + </class> >> + >> +</hibernate-mapping> >> >> Added: >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs >> =================================================================== >> --- >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs >> (rev 0) >> +++ >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs >> 2008-12-28 22:20:58 UTC (rev 3967) >> @@ -0,0 +1,15 @@ >> +using System; >> + >> +namespace NHibernate.Test.NHSpecificTest.NH1549 >> +{ >> + public class ProductWithInheritedId : EntityInt32 >> + { >> + public CategoryWithInheritedId CategoryWithInheritedId { >> get; set; } >> + } >> + >> + public class ProductWithId >> + { >> + public virtual int Id { get; set; } >> + public CategoryWithId CategoryWithId { get; set; } >> + } >> +} >> \ No newline at end of file >> >> >> Property changes on: >> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs >> ___________________________________________________________________ >> Added: svn:mergeinfo >> + >> >> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj >> =================================================================== >> --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-27 >> 19:53:57 UTC (rev 3966) >> +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-28 >> 22:20:58 UTC (rev 3967) >> @@ -378,6 +378,10 @@ >> <Compile Include="NHSpecificTest\NH1274ExportExclude\Person.cs" /> >> <Compile Include="NHSpecificTest\NH1443\Fixture.cs" /> >> <Compile Include="NHSpecificTest\NH1521\Fixture.cs" /> >> + <Compile Include="NHSpecificTest\NH1549\CategoryWithInheritedId.cs" >> /> >> + <Compile Include="NHSpecificTest\NH1549\EntityInt32.cs" /> >> + <Compile Include="NHSpecificTest\NH1549\Fixture.cs" /> >> + <Compile Include="NHSpecificTest\NH1549\ProductWithInheritedId.cs" /> >> <Compile Include="NHSpecificTest\NH1605\Fixture.cs" /> >> <Compile Include="NHSpecificTest\NH1609\Entities.cs" /> >> <Compile Include="NHSpecificTest\NH1609\Fixture.cs" /> >> @@ -1577,6 +1581,7 @@ >> <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> >> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> >> <Content Include="DynamicEntity\package.html" /> >> + <EmbeddedResource Include="NHSpecificTest\NH1549\Mappings.hbm.xml" /> >> <EmbeddedResource >> Include="NHSpecificTest\NH1521\AclassWithSpecific.hbm.xml" /> >> <EmbeddedResource >> Include="NHSpecificTest\NH1521\AclassWithNothing.hbm.xml" /> >> <EmbeddedResource >> Include="NHSpecificTest\NH1521\AclassWithDefault.hbm.xml" /> >> >> Modified: >> trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs >> =================================================================== >> --- >> trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs >> 2008-12-27 19:53:57 UTC (rev 3966) >> +++ >> trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs >> 2008-12-28 22:20:58 UTC (rev 3967) >> @@ -56,11 +56,13 @@ >> [Test] >> public void TryGetMethod() >> { >> - const BindingFlags bf = BindingFlags.Instance | >> BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; >> - MethodInfo mig = typeof >> (MyBaseImplementation).GetMethod("get_Id", bf); >> + //const BindingFlags bf = BindingFlags.Instance | >> BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; >> + const BindingFlags bf = BindingFlags.Instance | >> BindingFlags.Public | BindingFlags.NonPublic; >> + MethodInfo mig = >> typeof(MyBaseImplementation).GetMethod("get_Id", bf); >> MethodInfo mis = >> typeof(MyBaseImplementation).GetMethod("set_Id", bf); >> MethodInfo mng = >> typeof(MyBaseImplementation).GetMethod("get_Name", bf); >> MethodInfo mns = >> typeof(MyBaseImplementation).GetMethod("set_Name", bf); >> + >> >> Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mig), >> Is.Not.Null); >> >> Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mis), >> Is.Null); >> >> Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mng), >> Is.Not.Null); >> @@ -78,6 +80,20 @@ >> Assert.That(ReflectHelper.TryGetMethod(new[] { >> typeof(IMyBaseInterface), typeof(IMyInterface) }, mns), Is.Not.Null); >> Assert.That(ReflectHelper.TryGetMethod(new[] { >> typeof(IMyBaseInterface), typeof(IMyInterface) }, mdg), Is.Not.Null); >> Assert.That(ReflectHelper.TryGetMethod(new[] { >> typeof(IMyBaseInterface), typeof(IMyInterface) }, mds), Is.Null); >> + >> + MethodInfo mdig = >> typeof(MyDerivedImplementation).GetMethod("get_Id", bf); >> + MethodInfo mdis = >> typeof(MyDerivedImplementation).GetMethod("set_Id", bf); >> + MethodInfo mdng = >> typeof(MyDerivedImplementation).GetMethod("get_Name", bf); >> + MethodInfo mdns = >> typeof(MyDerivedImplementation).GetMethod("set_Name", bf); >> + MethodInfo mddg = >> typeof(MyDerivedImplementation).GetMethod("get_Description", bf); >> + MethodInfo mdds = >> typeof(MyDerivedImplementation).GetMethod("set_Description", bf); >> + >> + Assert.That(ReflectHelper.TryGetMethod(new[] { >> typeof(IMyBaseInterface), typeof(IMyInterface) }, mdig), Is.Not.Null); >> + Assert.That(ReflectHelper.TryGetMethod(new[] { >> typeof(IMyBaseInterface), typeof(IMyInterface) }, mdis), Is.Null); >> + Assert.That(ReflectHelper.TryGetMethod(new[] { >> typeof(IMyBaseInterface), typeof(IMyInterface) }, mdng), Is.Not.Null); >> + Assert.That(ReflectHelper.TryGetMethod(new[] { >> typeof(IMyBaseInterface), typeof(IMyInterface) }, mdns), Is.Not.Null); >> + Assert.That(ReflectHelper.TryGetMethod(new[] { >> typeof(IMyBaseInterface), typeof(IMyInterface) }, mddg), Is.Not.Null); >> + Assert.That(ReflectHelper.TryGetMethod(new[] { >> typeof(IMyBaseInterface), typeof(IMyInterface) }, mdds), Is.Null); >> } >> } >> >> @@ -115,11 +131,15 @@ >> public string Name { get; set; } >> } >> >> + public class MyDerivedImplementation : MyBaseImplementation, >> IMyInterface >> + { >> + public string Description { get; set; } >> + } >> + >> public class MyImplementation: IMyInterface >> { >> public int Id{ get; set; } >> public string Name { get; set; } >> public string Description { get; set; } >> } >> - >> } >> \ No newline at end of file >> >> >> This was sent by the SourceForge.net collaborative development platform, >> the world's largest Open Source development site. >> >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Nhibernate-commit mailing list >> Nhi...@li... >> https://lists.sourceforge.net/lists/listinfo/nhibernate-commit >> > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Nhibernate-commit mailing list > Nhi...@li... > https://lists.sourceforge.net/lists/listinfo/nhibernate-commit > > -- Davy Brion http://davybrion.com |
|
From: T. T. <te...@gm...> - 2008-12-28 22:35:51
|
I am not sure if SF allows but some SVN providers allows you to change history logs. You may try. Tuna Toksöz http://tunatoksoz.com Typos included to enhance the readers attention! On Mon, Dec 29, 2008 at 12:27 AM, Davy Brion <ra...@da...> wrote: > yeah sorry, forgot to add the commit message.... this commit fixed NH-1549 > and NH-1590 > > > On Sun, Dec 28, 2008 at 11:23 PM, Tuna Toksöz <te...@gm...> wrote: > >> Commit log? >> >> >> Tuna Toksöz >> http://tunatoksoz.com >> >> Typos included to enhance the readers attention! >> >> >> >> >> On Mon, Dec 29, 2008 at 12:20 AM, <dav...@us...>wrote: >> >>> Revision: 3967 >>> >>> http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3967&view=rev >>> Author: davybrion >>> Date: 2008-12-28 22:20:58 +0000 (Sun, 28 Dec 2008) >>> >>> Log Message: >>> ----------- >>> >>> >>> Modified Paths: >>> -------------- >>> trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs >>> trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs >>> trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj >>> >>> trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs >>> >>> Added Paths: >>> ----------- >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ >>> >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs >>> >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs >>> >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml >>> >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs >>> >>> Modified: >>> trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs >>> 2008-12-27 19:53:57 UTC (rev 3966) >>> +++ trunk/nhibernate/src/NHibernate/Proxy/Poco/BasicLazyInitializer.cs >>> 2008-12-28 22:20:58 UTC (rev 3967) >>> @@ -62,7 +62,7 @@ >>> /// underlying proxied object is needed then it returns >>> the result <see cref="AbstractLazyInitializer.InvokeImplementation"/> >>> /// which indicates that the Proxy will need to forward to >>> the real implementation. >>> /// </returns> >>> - public virtual object Invoke(MethodBase method, object[] >>> args, object proxy) >>> + public virtual object Invoke(MethodInfo method, object[] >>> args, object proxy) >>> { >>> string methodName = method.Name; >>> int paramCount = method.GetParameters().Length; >>> @@ -73,7 +73,7 @@ >>> { >>> return >>> IdentityEqualityComparer.GetHashCode(proxy); >>> } >>> - else if (IsUninitialized && >>> method.Equals(getIdentifierMethod)) >>> + else if (IsUninitialized && >>> IsEqualToIdentifierMethod(method)) >>> { >>> return Identifier; >>> } >>> @@ -135,5 +135,18 @@ >>> return InvokeImplementation; >>> } >>> >>> + private bool IsEqualToIdentifierMethod(MethodInfo method) >>> + { >>> + if (getIdentifierMethod != null) >>> + { >>> + // in the case of inherited identifier >>> methods (from a base class or an iterface) the >>> + // passed in MethodBase object is not >>> equal to the getIdentifierMethod instance that we >>> + // have... but if their names and return >>> types are identical, then it is the correct >>> + // identifier method >>> + return >>> method.Name.Equals(getIdentifierMethod.Name) && >>> method.ReturnType.Equals(getIdentifierMethod.ReturnType); >>> + } >>> + >>> + return false; >>> + } >>> } >>> } >>> >>> Modified: trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs >>> 2008-12-27 19:53:57 UTC (rev 3966) >>> +++ trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs >>> 2008-12-28 22:20:58 UTC (rev 3967) >>> @@ -19,7 +19,7 @@ >>> private static readonly ILog log = >>> LogManager.GetLogger(typeof(ReflectHelper)); >>> >>> public static BindingFlags AnyVisibilityInstance = >>> BindingFlags.Instance | BindingFlags.Public | >>> - >>> BindingFlags.NonPublic; >>> + >>> BindingFlags.NonPublic; >>> >>> private ReflectHelper() >>> { >>> @@ -29,7 +29,7 @@ >>> private static System.Type[] NoClasses = >>> System.Type.EmptyTypes; >>> >>> private static readonly MethodInfo >>> Exception_InternalPreserveStackTrace = >>> - typeof >>> (Exception).GetMethod("InternalPreserveStackTrace", BindingFlags.Instance | >>> BindingFlags.NonPublic); >>> + >>> typeof(Exception).GetMethod("InternalPreserveStackTrace", >>> BindingFlags.Instance | BindingFlags.NonPublic); >>> >>> /// <summary> >>> /// Determine if the specified <see cref="System.Type"/> >>> overrides the >>> @@ -41,7 +41,7 @@ >>> { >>> try >>> { >>> - MethodInfo equals = >>> clazz.GetMethod("Equals", new System.Type[] {typeof(object)}); >>> + MethodInfo equals = >>> clazz.GetMethod("Equals", new System.Type[] { typeof(object) }); >>> if (equals == null) >>> { >>> return false; >>> @@ -127,7 +127,7 @@ >>> System.Type heuristicClass = propertyClass; >>> >>> if (propertyClass.IsGenericType >>> - && >>> propertyClass.GetGenericTypeDefinition().Equals(typeof(Nullable<>))) >>> + && >>> propertyClass.GetGenericTypeDefinition().Equals(typeof(Nullable<>))) >>> { >>> heuristicClass = >>> propertyClass.GetGenericArguments()[0]; >>> } >>> @@ -292,15 +292,15 @@ >>> >>> public static bool TryLoadAssembly(string assemblyName) >>> { >>> - if(string.IsNullOrEmpty(assemblyName)) >>> + if (string.IsNullOrEmpty(assemblyName)) >>> return false; >>> >>> - bool result= true; >>> + bool result = true; >>> try >>> { >>> Assembly.Load(assemblyName); >>> } >>> - catch(Exception) >>> + catch (Exception) >>> { >>> result = false; >>> } >>> @@ -446,7 +446,7 @@ >>> /// <returns>The unwrapped exception.</returns> >>> public static Exception >>> UnwrapTargetInvocationException(TargetInvocationException ex) >>> { >>> - >>> Exception_InternalPreserveStackTrace.Invoke(ex.InnerException, new Object[] >>> {}); >>> + >>> Exception_InternalPreserveStackTrace.Invoke(ex.InnerException, new Object[] >>> { }); >>> return ex.InnerException; >>> } >>> >>> @@ -472,14 +472,7 @@ >>> } >>> >>> System.Type[] tps = GetMethodSignature(method); >>> - try >>> - { >>> - return type.GetMethod(method.Name, >>> defaultBindingFlags, null, tps, null); >>> - } >>> - catch (Exception) >>> - { >>> - return null; >>> - } >>> + return SafeGetMethod(type, method, tps); >>> } >>> >>> /// <summary> >>> @@ -493,6 +486,8 @@ >>> /// </remarks> >>> public static MethodInfo >>> TryGetMethod(IEnumerable<System.Type> types, MethodInfo method) >>> { >>> + var bindingFlags = BindingFlags.Instance | >>> BindingFlags.Public | BindingFlags.NonPublic; >>> + >>> // This method will be used when we support >>> multiple proxy interfaces. >>> if (types == null) >>> { >>> @@ -505,21 +500,16 @@ >>> >>> System.Type[] tps = GetMethodSignature(method); >>> MethodInfo result = null; >>> + >>> foreach (var type in types) >>> { >>> - try >>> + result = SafeGetMethod(type, method, >>> tps); >>> + if (result != null) >>> { >>> - result = >>> type.GetMethod(method.Name, defaultBindingFlags, null, tps, null); >>> - if (result != null) >>> - { >>> - return result; >>> - } >>> + return result; >>> } >>> - catch (Exception) >>> - { >>> - return null; >>> - } >>> } >>> + >>> return result; >>> } >>> >>> @@ -533,5 +523,19 @@ >>> } >>> return tps; >>> } >>> + >>> + private static MethodInfo SafeGetMethod(System.Type type, >>> MethodInfo method, System.Type[] tps) >>> + { >>> + var bindingFlags = BindingFlags.Instance | >>> BindingFlags.Public | BindingFlags.NonPublic; >>> + >>> + try >>> + { >>> + return type.GetMethod(method.Name, >>> bindingFlags, null, tps, null); >>> + } >>> + catch (Exception) >>> + { >>> + return null; >>> + } >>> + } >>> } >>> } >>> >>> Added: >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs >>> =================================================================== >>> --- >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs >>> (rev 0) >>> +++ >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs >>> 2008-12-28 22:20:58 UTC (rev 3967) >>> @@ -0,0 +1,15 @@ >>> +using System; >>> + >>> +namespace NHibernate.Test.NHSpecificTest.NH1549 >>> +{ >>> + public class CategoryWithInheritedId : EntityInt32 >>> + { >>> + public virtual string Name { get; set; } >>> + } >>> + >>> + public class CategoryWithId >>> + { >>> + public virtual int Id { get; set; } >>> + public virtual string Name { get; set; } >>> + } >>> +} >>> \ No newline at end of file >>> >>> >>> Property changes on: >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/CategoryWithInheritedId.cs >>> ___________________________________________________________________ >>> Added: svn:mergeinfo >>> + >>> >>> Added: >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs >>> =================================================================== >>> --- >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs >>> (rev 0) >>> +++ >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/EntityInt32.cs >>> 2008-12-28 22:20:58 UTC (rev 3967) >>> @@ -0,0 +1,7 @@ >>> +namespace NHibernate.Test.NHSpecificTest.NH1549 >>> +{ >>> + public abstract class EntityInt32 >>> + { >>> + public virtual int Id { get; set; } >>> + } >>> +} >>> \ No newline at end of file >>> >>> Added: >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs >>> (rev 0) >>> +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Fixture.cs >>> 2008-12-28 22:20:58 UTC (rev 3967) >>> @@ -0,0 +1,93 @@ >>> +using NUnit.Framework; >>> + >>> +namespace NHibernate.Test.NHSpecificTest.NH1549 >>> +{ >>> + [TestFixture] >>> + public class Fixture : BugTestCase >>> + { >>> + /// <summary> >>> + /// Verifies that an entity with a base class containing >>> the id property >>> + /// can have the id accessed without loading the entity >>> + /// </summary> >>> + [Test] >>> + public void CanLoadForEntitiesWithInheritedIds() >>> + { >>> + //create some related products >>> + var category = new CategoryWithInheritedId {Name >>> = "Fruit"}; >>> + var product = new ProductWithInheritedId >>> {CategoryWithInheritedId = category}; >>> + >>> + using (ISession session = OpenSession()) >>> + { >>> + using (ITransaction trans = >>> session.BeginTransaction()) >>> + { >>> + session.Save(category); >>> + session.Save(product); >>> + trans.Commit(); >>> + } >>> + } >>> + >>> + ProductWithInheritedId >>> restoredProductWithInheritedId; >>> + >>> + //restore the product from the db in another >>> session so that >>> + //the association is a proxy >>> + using (ISession session = OpenSession()) >>> + { >>> + restoredProductWithInheritedId = >>> session.Get<ProductWithInheritedId>(product.Id); >>> + } >>> + >>> + //verify that the category is a proxy >>> + >>> Assert.IsFalse(NHibernateUtil.IsInitialized(restoredProductWithInheritedId.CategoryWithInheritedId)); >>> + >>> + //we should be able to access the id of the >>> category outside of the session >>> + Assert.AreEqual(category.Id, >>> restoredProductWithInheritedId.CategoryWithInheritedId.Id); >>> + } >>> + >>> + [Test] >>> + public void CanLoadForEntitiesWithTheirOwnIds() >>> + { >>> + //create some related products >>> + var category = new CategoryWithId { Name = >>> "Fruit" }; >>> + var product = new ProductWithId { CategoryWithId >>> = category }; >>> + >>> + using (ISession session = OpenSession()) >>> + { >>> + using (ITransaction trans = >>> session.BeginTransaction()) >>> + { >>> + session.Save(category); >>> + session.Save(product); >>> + trans.Commit(); >>> + } >>> + } >>> + >>> + ProductWithId restoredProductWithInheritedId; >>> + >>> + //restore the product from the db in another >>> session so that >>> + //the association is a proxy >>> + using (ISession session = OpenSession()) >>> + { >>> + restoredProductWithInheritedId = >>> session.Get<ProductWithId>(product.Id); >>> + } >>> + >>> + //verify that the category is a proxy >>> + >>> Assert.IsFalse(NHibernateUtil.IsInitialized(restoredProductWithInheritedId.CategoryWithId)); >>> + >>> + //we should be able to access the id of the >>> category outside of the session >>> + Assert.AreEqual(category.Id, >>> restoredProductWithInheritedId.CategoryWithId.Id); >>> + } >>> + >>> + protected override void OnTearDown() >>> + { >>> + using (ISession session = OpenSession()) { >>> + >>> + using (ITransaction trans = >>> session.BeginTransaction()) >>> + { >>> + session.Delete("from >>> ProductWithId"); >>> + session.Delete("from >>> CategoryWithId"); >>> + session.Delete("from >>> ProductWithInheritedId"); >>> + session.Delete("from >>> CategoryWithInheritedId"); >>> + trans.Commit(); >>> + } >>> + } >>> + } >>> + } >>> +} >>> \ No newline at end of file >>> >>> Added: >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml >>> =================================================================== >>> --- >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml >>> (rev 0) >>> +++ >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/Mappings.hbm.xml >>> 2008-12-28 22:20:58 UTC (rev 3967) >>> @@ -0,0 +1,35 @@ >>> +<?xml version="1.0" encoding="utf-8" ?> >>> +<hibernate-mapping >>> + xmlns="urn:nhibernate-mapping-2.2" >>> + namespace="NHibernate.Test.NHSpecificTest.NH1549" >>> + assembly="NHibernate.Test"> >>> + >>> + <class name="CategoryWithInheritedId"> >>> + <id name="Id" type="System.Int32"> >>> + <generator class="native" /> >>> + </id> >>> + <property name="Name" /> >>> + </class> >>> + >>> + <class name="ProductWithInheritedId" lazy="false"> >>> + <id name="Id" type="System.Int32"> >>> + <generator class="native" /> >>> + </id> >>> + <many-to-one name="CategoryWithInheritedId"/> >>> + </class> >>> + >>> + <class name="CategoryWithId"> >>> + <id name="Id" type="System.Int32"> >>> + <generator class="native" /> >>> + </id> >>> + <property name="Name" /> >>> + </class> >>> + >>> + <class name="ProductWithId" lazy="false"> >>> + <id name="Id" type="System.Int32"> >>> + <generator class="native" /> >>> + </id> >>> + <many-to-one name="CategoryWithId"/> >>> + </class> >>> + >>> +</hibernate-mapping> >>> >>> Added: >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs >>> =================================================================== >>> --- >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs >>> (rev 0) >>> +++ >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs >>> 2008-12-28 22:20:58 UTC (rev 3967) >>> @@ -0,0 +1,15 @@ >>> +using System; >>> + >>> +namespace NHibernate.Test.NHSpecificTest.NH1549 >>> +{ >>> + public class ProductWithInheritedId : EntityInt32 >>> + { >>> + public CategoryWithInheritedId CategoryWithInheritedId { >>> get; set; } >>> + } >>> + >>> + public class ProductWithId >>> + { >>> + public virtual int Id { get; set; } >>> + public CategoryWithId CategoryWithId { get; set; } >>> + } >>> +} >>> \ No newline at end of file >>> >>> >>> Property changes on: >>> trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1549/ProductWithInheritedId.cs >>> ___________________________________________________________________ >>> Added: svn:mergeinfo >>> + >>> >>> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj >>> =================================================================== >>> --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj >>> 2008-12-27 19:53:57 UTC (rev 3966) >>> +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj >>> 2008-12-28 22:20:58 UTC (rev 3967) >>> @@ -378,6 +378,10 @@ >>> <Compile Include="NHSpecificTest\NH1274ExportExclude\Person.cs" /> >>> <Compile Include="NHSpecificTest\NH1443\Fixture.cs" /> >>> <Compile Include="NHSpecificTest\NH1521\Fixture.cs" /> >>> + <Compile Include="NHSpecificTest\NH1549\CategoryWithInheritedId.cs" >>> /> >>> + <Compile Include="NHSpecificTest\NH1549\EntityInt32.cs" /> >>> + <Compile Include="NHSpecificTest\NH1549\Fixture.cs" /> >>> + <Compile Include="NHSpecificTest\NH1549\ProductWithInheritedId.cs" >>> /> >>> <Compile Include="NHSpecificTest\NH1605\Fixture.cs" /> >>> <Compile Include="NHSpecificTest\NH1609\Entities.cs" /> >>> <Compile Include="NHSpecificTest\NH1609\Fixture.cs" /> >>> @@ -1577,6 +1581,7 @@ >>> <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" /> >>> <EmbeddedResource Include="Deletetransient\Person.hbm.xml" /> >>> <Content Include="DynamicEntity\package.html" /> >>> + <EmbeddedResource Include="NHSpecificTest\NH1549\Mappings.hbm.xml" >>> /> >>> <EmbeddedResource >>> Include="NHSpecificTest\NH1521\AclassWithSpecific.hbm.xml" /> >>> <EmbeddedResource >>> Include="NHSpecificTest\NH1521\AclassWithNothing.hbm.xml" /> >>> <EmbeddedResource >>> Include="NHSpecificTest\NH1521\AclassWithDefault.hbm.xml" /> >>> >>> Modified: >>> trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs >>> =================================================================== >>> --- >>> trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs >>> 2008-12-27 19:53:57 UTC (rev 3966) >>> +++ >>> trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs >>> 2008-12-28 22:20:58 UTC (rev 3967) >>> @@ -56,11 +56,13 @@ >>> [Test] >>> public void TryGetMethod() >>> { >>> - const BindingFlags bf = BindingFlags.Instance | >>> BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; >>> - MethodInfo mig = typeof >>> (MyBaseImplementation).GetMethod("get_Id", bf); >>> + //const BindingFlags bf = BindingFlags.Instance | >>> BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; >>> + const BindingFlags bf = BindingFlags.Instance | >>> BindingFlags.Public | BindingFlags.NonPublic; >>> + MethodInfo mig = >>> typeof(MyBaseImplementation).GetMethod("get_Id", bf); >>> MethodInfo mis = >>> typeof(MyBaseImplementation).GetMethod("set_Id", bf); >>> MethodInfo mng = >>> typeof(MyBaseImplementation).GetMethod("get_Name", bf); >>> MethodInfo mns = >>> typeof(MyBaseImplementation).GetMethod("set_Name", bf); >>> + >>> >>> Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mig), >>> Is.Not.Null); >>> >>> Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mis), >>> Is.Null); >>> >>> Assert.That(ReflectHelper.TryGetMethod(typeof(IMyBaseInterface), mng), >>> Is.Not.Null); >>> @@ -78,6 +80,20 @@ >>> Assert.That(ReflectHelper.TryGetMethod(new[] { >>> typeof(IMyBaseInterface), typeof(IMyInterface) }, mns), Is.Not.Null); >>> Assert.That(ReflectHelper.TryGetMethod(new[] { >>> typeof(IMyBaseInterface), typeof(IMyInterface) }, mdg), Is.Not.Null); >>> Assert.That(ReflectHelper.TryGetMethod(new[] { >>> typeof(IMyBaseInterface), typeof(IMyInterface) }, mds), Is.Null); >>> + >>> + MethodInfo mdig = >>> typeof(MyDerivedImplementation).GetMethod("get_Id", bf); >>> + MethodInfo mdis = >>> typeof(MyDerivedImplementation).GetMethod("set_Id", bf); >>> + MethodInfo mdng = >>> typeof(MyDerivedImplementation).GetMethod("get_Name", bf); >>> + MethodInfo mdns = >>> typeof(MyDerivedImplementation).GetMethod("set_Name", bf); >>> + MethodInfo mddg = >>> typeof(MyDerivedImplementation).GetMethod("get_Description", bf); >>> + MethodInfo mdds = >>> typeof(MyDerivedImplementation).GetMethod("set_Description", bf); >>> + >>> + Assert.That(ReflectHelper.TryGetMethod(new[] { >>> typeof(IMyBaseInterface), typeof(IMyInterface) }, mdig), Is.Not.Null); >>> + Assert.That(ReflectHelper.TryGetMethod(new[] { >>> typeof(IMyBaseInterface), typeof(IMyInterface) }, mdis), Is.Null); >>> + Assert.That(ReflectHelper.TryGetMethod(new[] { >>> typeof(IMyBaseInterface), typeof(IMyInterface) }, mdng), Is.Not.Null); >>> + Assert.That(ReflectHelper.TryGetMethod(new[] { >>> typeof(IMyBaseInterface), typeof(IMyInterface) }, mdns), Is.Not.Null); >>> + Assert.That(ReflectHelper.TryGetMethod(new[] { >>> typeof(IMyBaseInterface), typeof(IMyInterface) }, mddg), Is.Not.Null); >>> + Assert.That(ReflectHelper.TryGetMethod(new[] { >>> typeof(IMyBaseInterface), typeof(IMyInterface) }, mdds), Is.Null); >>> } >>> } >>> >>> @@ -115,11 +131,15 @@ >>> public string Name { get; set; } >>> } >>> >>> + public class MyDerivedImplementation : MyBaseImplementation, >>> IMyInterface >>> + { >>> + public string Description { get; set; } >>> + } >>> + >>> public class MyImplementation: IMyInterface >>> { >>> public int Id{ get; set; } >>> public string Name { get; set; } >>> public string Description { get; set; } >>> } >>> - >>> } >>> \ No newline at end of file >>> >>> >>> This was sent by the SourceForge.net collaborative development platform, >>> the world's largest Open Source development site. >>> >>> >>> ------------------------------------------------------------------------------ >>> _______________________________________________ >>> Nhibernate-commit mailing list >>> Nhi...@li... >>> https://lists.sourceforge.net/lists/listinfo/nhibernate-commit >>> >> >> >> >> ------------------------------------------------------------------------------ >> >> _______________________________________________ >> Nhibernate-commit mailing list >> Nhi...@li... >> https://lists.sourceforge.net/lists/listinfo/nhibernate-commit >> >> > > > -- > Davy Brion > http://davybrion.com > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Nhibernate-commit mailing list > Nhi...@li... > https://lists.sourceforge.net/lists/listinfo/nhibernate-commit > > |
|
From: <dav...@us...> - 2008-12-30 19:41:36
|
Revision: 3968
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3968&view=rev
Author: davybrion
Date: 2008-12-30 19:41:26 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
fix for NH-1609
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
trunk/nhibernate/src/NHibernate/Driver/DriverBase.cs
trunk/nhibernate/src/NHibernate/Driver/IDriver.cs
trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs
trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs
trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Fixture.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2008-12-28 22:20:58 UTC (rev 3967)
+++ trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2008-12-30 19:41:26 UTC (rev 3968)
@@ -989,14 +989,6 @@
}
/// <summary>
- /// How we separate the queries when we use multiply queries.
- /// </summary>
- public virtual string MultipleQueriesSeparator
- {
- get { return ";"; }
- }
-
- /// <summary>
/// The syntax used to drop a foreign key constraint from a table.
/// </summary>
/// <param name="constraintName">The name of the foreign key constraint to drop.</param>
Modified: trunk/nhibernate/src/NHibernate/Driver/DriverBase.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Driver/DriverBase.cs 2008-12-28 22:20:58 UTC (rev 3967)
+++ trunk/nhibernate/src/NHibernate/Driver/DriverBase.cs 2008-12-30 19:41:26 UTC (rev 3968)
@@ -166,7 +166,7 @@
private void SetCommandText(IDbCommand cmd, SqlString sqlString)
{
- SqlStringFormatter formatter = new SqlStringFormatter(this);
+ SqlStringFormatter formatter = new SqlStringFormatter(this, MultipleQueriesSeparator);
formatter.Format(sqlString);
cmd.CommandText = formatter.GetFormattedText();
}
@@ -227,5 +227,10 @@
{
get { return false; }
}
+
+ public virtual string MultipleQueriesSeparator
+ {
+ get { return ";"; }
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Driver/IDriver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Driver/IDriver.cs 2008-12-28 22:20:58 UTC (rev 3967)
+++ trunk/nhibernate/src/NHibernate/Driver/IDriver.cs 2008-12-30 19:41:26 UTC (rev 3968)
@@ -66,6 +66,11 @@
bool SupportsMultipleQueries { get; }
/// <summary>
+ /// How we separate the queries when we use multiply queries.
+ /// </summary>
+ string MultipleQueriesSeparator { get; }
+
+ /// <summary>
/// Generates an IDbCommand from the SqlString according to the requirements of the DataProvider.
/// </summary>
/// <param name="type">The <see cref="CommandType"/> of the command to generate.</param>
Modified: trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs 2008-12-28 22:20:58 UTC (rev 3967)
+++ trunk/nhibernate/src/NHibernate/Driver/SqlStringFormatter.cs 2008-12-30 19:41:26 UTC (rev 3968)
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Text;
using NHibernate.SqlCommand;
@@ -6,17 +7,23 @@
{
public class SqlStringFormatter : ISqlStringVisitor
{
- private StringBuilder result = new StringBuilder();
+ private readonly StringBuilder result = new StringBuilder();
private int parameterIndex = 0;
- private ISqlParameterFormatter formatter;
+ private readonly ISqlParameterFormatter formatter;
+ private readonly string multipleQueriesSeparator;
- public SqlStringFormatter(ISqlParameterFormatter formatter)
+ private readonly Dictionary<int, int> queryIndexToNumberOfPreceedingParameters = new Dictionary<int, int>();
+ private readonly Dictionary<int, int> parameterIndexToQueryIndex = new Dictionary<int, int>();
+
+ public SqlStringFormatter(ISqlParameterFormatter formatter, string multipleQueriesSeparator)
{
this.formatter = formatter;
+ this.multipleQueriesSeparator = multipleQueriesSeparator;
}
public void Format(SqlString text)
{
+ DetermineNumberOfPreceedingParametersForEachQuery(text);
text.Visit(this);
}
@@ -37,10 +44,62 @@
void ISqlStringVisitor.Parameter(Parameter parameter)
{
- string name = formatter.GetParameterName(
- parameter.OriginalPositionInQuery ?? parameterIndex);
+ string name;
+
+ if (queryIndexToNumberOfPreceedingParameters.Count == 0)
+ {
+ // there's only one query... no need to worry about indexes of parameters of previous queries
+ name = formatter.GetParameterName(parameter.OriginalPositionInQuery ?? parameterIndex);
+ }
+ else
+ {
+ // multiple queries... in case the parameters were switched around (for SQL paging for instance) we need
+ // to keep the number of preceeding parameters (in previous queries of the batch) into account
+ if (parameter.OriginalPositionInQuery != null)
+ {
+ name = formatter.GetParameterName(GetNumberOfPreceedingParameters() + parameter.OriginalPositionInQuery.Value);
+ }
+ else
+ {
+ name = formatter.GetParameterName(parameterIndex);
+ }
+ }
+
parameterIndex++;
result.Append(name);
}
+
+ private int GetNumberOfPreceedingParameters()
+ {
+ int queryIndex = parameterIndexToQueryIndex[parameterIndex];
+ return queryIndexToNumberOfPreceedingParameters[queryIndex];
+ }
+
+ private void DetermineNumberOfPreceedingParametersForEachQuery(SqlString text)
+ {
+ int currentParameterIndex = 0;
+ int currentQueryParameterCount = 0;
+ int currentQueryIndex = 0;
+
+ foreach (object part in text.Parts)
+ {
+ if (part.ToString().Equals(multipleQueriesSeparator))
+ {
+ queryIndexToNumberOfPreceedingParameters[currentQueryIndex] = currentParameterIndex - currentQueryParameterCount;
+ currentQueryParameterCount = 0;
+ currentQueryIndex++;
+ continue;
+ }
+
+ Parameter parameter = part as Parameter;
+
+ if (parameter != null)
+ {
+ parameterIndexToQueryIndex[currentParameterIndex] = currentQueryIndex;
+ currentQueryParameterCount++;
+ currentParameterIndex++;
+ }
+ }
+ }
}
}
Modified: trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2008-12-28 22:20:58 UTC (rev 3967)
+++ trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2008-12-30 19:41:26 UTC (rev 3968)
@@ -174,7 +174,7 @@
parameters.Add(queryParameters);
SqlCommandInfo commandInfo = loader.GetQueryStringAndTypes(session, queryParameters);
sqlString = sqlString.Append(commandInfo.Text)
- .Append(dialect.MultipleQueriesSeparator)
+ .Append(session.Factory.ConnectionProvider.Driver.MultipleQueriesSeparator)
.Append(Environment.NewLine);
types.AddRange(commandInfo.ParameterTypes);
}
Modified: trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2008-12-28 22:20:58 UTC (rev 3967)
+++ trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2008-12-30 19:41:26 UTC (rev 3968)
@@ -581,7 +581,7 @@
parameters.Add(queryParameters);
queryParameters = GetFilteredQueryParameters(queryParameters, translator);
SqlCommandInfo commandInfo = translator.GetQueryStringAndTypes(session, queryParameters);
- sqlString = sqlString.Append(commandInfo.Text).Append(dialect.MultipleQueriesSeparator).Append(Environment.NewLine);
+ sqlString = sqlString.Append(commandInfo.Text).Append(session.Factory.ConnectionProvider.Driver.MultipleQueriesSeparator).Append(Environment.NewLine);
types.AddRange(commandInfo.ParameterTypes);
}
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Fixture.cs 2008-12-28 22:20:58 UTC (rev 3967)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Fixture.cs 2008-12-30 19:41:26 UTC (rev 3968)
@@ -8,7 +8,6 @@
namespace NHibernate.Test.NHSpecificTest.NH1609
{
[TestFixture]
- [Ignore("not fixed yet")]
public class Fixture : BugTestCase
{
[Test]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-01-02 18:37:17
|
Revision: 3971
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3971&view=rev
Author: fabiomaulo
Date: 2009-01-02 18:37:13 +0000 (Fri, 02 Jan 2009)
Log Message:
-----------
Fix NH-1633
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs
trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs 2009-01-02 14:41:58 UTC (rev 3970)
+++ trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs 2009-01-02 18:37:13 UTC (rev 3971)
@@ -368,7 +368,8 @@
public object BuildResultRow(object[] data, IDataReader resultSet, bool hasTransformer, ISessionImplementor session)
{
object[] resultRow;
- if (!hasScalars)
+ // NH Different behavior (patched in NH-1612 to solve Hibernate issue HHH-2831).
+ if (!hasScalars && hasTransformer)
{
resultRow = data;
}
Modified: trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs 2009-01-02 14:41:58 UTC (rev 3970)
+++ trunk/nhibernate/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs 2009-01-02 18:37:13 UTC (rev 3971)
@@ -214,7 +214,8 @@
IList results = s.GetNamedQuery("UserSessionData").SetParameter("uname", "%in").List();
Assert.AreEqual(2, results.Count);
- gavin = (User) ((object[]) results[0])[0];
+ // NH Different behavior : NH1612, HHH-2831
+ gavin = (User)results[0];
Assert.AreEqual("gavin", gavin.Name);
Assert.AreEqual(2, gavin.Session.Count);
t.Commit();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-01-02 18:41:36
|
Revision: 3972
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3972&view=rev
Author: fabiomaulo
Date: 2009-01-02 18:41:32 +0000 (Fri, 02 Jan 2009)
Log Message:
-----------
- Fix test case
- Minor refactoring
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Engine/ResultSetMappingDefinition.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Engine/ResultSetMappingDefinition.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/ResultSetMappingDefinition.cs 2009-01-02 18:37:13 UTC (rev 3971)
+++ trunk/nhibernate/src/NHibernate/Engine/ResultSetMappingDefinition.cs 2009-01-02 18:41:32 UTC (rev 3972)
@@ -1,4 +1,3 @@
-using System.Collections;
using System.Collections.Generic;
using NHibernate.Engine.Query.Sql;
@@ -8,7 +7,7 @@
public class ResultSetMappingDefinition
{
private readonly string name;
- private readonly IList<INativeSQLQueryReturn> queryReturns = new List<INativeSQLQueryReturn>();
+ private readonly List<INativeSQLQueryReturn> queryReturns = new List<INativeSQLQueryReturn>();
public ResultSetMappingDefinition(string name)
{
@@ -22,14 +21,15 @@
public void AddQueryReturn(INativeSQLQueryReturn queryReturn)
{
- queryReturns.Add(queryReturn);
+ if (queryReturn != null)
+ {
+ queryReturns.Add(queryReturn);
+ }
}
public INativeSQLQueryReturn[] GetQueryReturns()
{
- INativeSQLQueryReturn[] result = new INativeSQLQueryReturn[queryReturns.Count];
- queryReturns.CopyTo(result, 0);
- return result;
+ return queryReturns.ToArray();
}
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Mappings.hbm.xml 2009-01-02 18:37:13 UTC (rev 3971)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Mappings.hbm.xml 2009-01-02 18:41:32 UTC (rev 3972)
@@ -73,7 +73,7 @@
AND ci.area_type = 'CI'
</sql-query>
- <sql-query name="CountryStatisticsLoader" xml:space="preserve">
+ <sql-query name="AreaStatisticsLoader" xml:space="preserve">
<load-collection role="Area.Statistics" alias="s">
<return-property name="key" column="code" />
<return-property name="index" column="year" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-01-03 17:26:41
|
Revision: 3974
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3974&view=rev
Author: fabiomaulo
Date: 2009-01-03 17:26:30 +0000 (Sat, 03 Jan 2009)
Log Message:
-----------
Fix NH-1612 (thanks to Gerke Geurts)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs
trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryParser.cs
trunk/nhibernate/src/NHibernate/Loader/GeneratedCollectionAliases.cs
trunk/nhibernate/src/NHibernate/Loader/Loader.cs
trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs
trunk/nhibernate/src/NHibernate.Test/App.config
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/NativeSqlCollectionLoaderFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs 2009-01-02 18:52:54 UTC (rev 3973)
+++ trunk/nhibernate/src/NHibernate/Loader/Custom/CustomLoader.cs 2009-01-03 17:26:30 UTC (rev 3974)
@@ -369,7 +369,7 @@
{
object[] resultRow;
// NH Different behavior (patched in NH-1612 to solve Hibernate issue HHH-2831).
- if (!hasScalars && hasTransformer)
+ if (!hasScalars && (hasTransformer || data.Length == 0))
{
resultRow = data;
}
Modified: trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryParser.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryParser.cs 2009-01-02 18:52:54 UTC (rev 3973)
+++ trunk/nhibernate/src/NHibernate/Loader/Custom/Sql/SQLQueryParser.cs 2009-01-03 17:26:30 UTC (rev 3974)
@@ -131,6 +131,7 @@
ISqlLoadableCollection collectionPersister = context.GetCollectionPersisterByAlias(aliasName);
string collectionSuffix = context.GetCollectionSuffixByAlias(aliasName);
+ // NH Different behavior for NH-1612
if ("*".Equals(propertyName))
{
if (fieldResults.Count != 0)
@@ -140,37 +141,50 @@
string selectFragment = collectionPersister.SelectFragment(aliasName, collectionSuffix);
aliasesFound++;
- return selectFragment + ", " + ResolveProperties(aliasName, propertyName);
+
+ // Collection may just contain elements and no entities, in which case resolution of
+ // collection properties is enough.
+ return collectionPersister.ElementType.IsEntityType
+ ? selectFragment + ", " + ResolveProperties(aliasName, "*")
+ : selectFragment;
}
- else if ("element.*".Equals(propertyName))
+
+ if (propertyName.StartsWith("element."))
{
- return ResolveProperties(aliasName, "*");
- }
- else
- {
- string[] columnAliases;
+ string elementPropertyName = propertyName.Substring("element.".Length);
- // Let return-propertys override whatever the persister has for aliases.
- if (!fieldResults.TryGetValue(propertyName,out columnAliases))
+ if (collectionPersister.ElementType.IsEntityType)
{
- columnAliases = collectionPersister.GetCollectionPropertyColumnAliases(propertyName, collectionSuffix);
+ return ResolveProperties(aliasName, elementPropertyName);
}
-
- if (columnAliases == null || columnAliases.Length == 0)
+ else if (elementPropertyName == "*")
{
- throw new QueryException("No column name found for property [" + propertyName + "] for alias [" + aliasName + "]",
- originalQueryString);
+ throw new QueryException("Using element.* syntax is only supported for entity elements.");
}
- if (columnAliases.Length != 1)
- {
- // TODO: better error message since we actually support composites if names are explicitly listed.
- throw new QueryException(
- "SQL queries only support properties mapped to a single column - property [" + propertyName + "] is mapped to "
- + columnAliases.Length + " columns.", originalQueryString);
- }
- aliasesFound++;
- return columnAliases[0];
}
+
+ string[] columnAliases;
+
+ // Let return-propertys override whatever the persister has for aliases.
+ if (!fieldResults.TryGetValue(propertyName, out columnAliases))
+ {
+ columnAliases = collectionPersister.GetCollectionPropertyColumnAliases(propertyName, collectionSuffix);
+ }
+
+ if (columnAliases == null || columnAliases.Length == 0)
+ {
+ throw new QueryException("No column name found for property [" + propertyName + "] for alias [" + aliasName + "]",
+ originalQueryString);
+ }
+ if (columnAliases.Length != 1)
+ {
+ // TODO: better error message since we actually support composites if names are explicitly listed.
+ throw new QueryException(
+ "SQL queries only support properties mapped to a single column - property [" + propertyName + "] is mapped to "
+ + columnAliases.Length + " columns.", originalQueryString);
+ }
+ aliasesFound++;
+ return columnAliases[0];
}
private string ResolveProperties(string aliasName, string propertyName)
Modified: trunk/nhibernate/src/NHibernate/Loader/GeneratedCollectionAliases.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/GeneratedCollectionAliases.cs 2009-01-02 18:52:54 UTC (rev 3973)
+++ trunk/nhibernate/src/NHibernate/Loader/GeneratedCollectionAliases.cs 2009-01-03 17:26:30 UTC (rev 3974)
@@ -18,7 +18,7 @@
private readonly IDictionary<string, string[]> userProvidedAliases;
public GeneratedCollectionAliases(IDictionary<string, string[]> userProvidedAliases, ICollectionPersister persister,
- string suffix)
+ string suffix)
{
this.suffix = suffix;
this.userProvidedAliases = userProvidedAliases;
@@ -27,7 +27,11 @@
indexAliases = GetUserProvidedAliases("index", persister.GetIndexColumnAliases(suffix));
- elementAliases = GetUserProvidedAliases("element", persister.GetElementColumnAliases(suffix));
+ // NH-1612: Add aliases for all composite element properties to support access
+ // to individual composite element properties in <return-property> elements.
+ elementAliases = persister.ElementType.IsComponentType
+ ? GetUserProvidedCompositeElementAliases(persister.GetElementColumnAliases(suffix))
+ : GetUserProvidedAliases("element", persister.GetElementColumnAliases(suffix));
identifierAlias = GetUserProvidedAlias("id", persister.GetIdentifierColumnAlias(suffix));
}
@@ -35,6 +39,20 @@
public GeneratedCollectionAliases(ICollectionPersister persister, string str)
: this(new CollectionHelper.EmptyMapClass<string, string[]>(), persister, str) {}
+ private string[] GetUserProvidedCompositeElementAliases(string[] defaultAliases)
+ {
+ var aliases = new List<string>();
+ foreach (KeyValuePair<string, string[]> userProvidedAlias in userProvidedAliases)
+ {
+ if (userProvidedAlias.Key.StartsWith("element."))
+ {
+ aliases.AddRange(userProvidedAlias.Value);
+ }
+ }
+
+ return aliases.Count > 0 ? aliases.ToArray() : defaultAliases;
+ }
+
/// <summary>
/// Returns the suffixed result-set column-aliases for columns making up the key for this collection (i.e., its FK to
/// its owner).
Modified: trunk/nhibernate/src/NHibernate/Loader/Loader.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2009-01-02 18:52:54 UTC (rev 3973)
+++ trunk/nhibernate/src/NHibernate/Loader/Loader.cs 2009-01-03 17:26:30 UTC (rev 3974)
@@ -392,11 +392,11 @@
int entitySpan = EntityPersisters.Length;
List<object> hydratedObjects = entitySpan == 0 ? null : new List<object>(entitySpan * 10);
-
+
IDbCommand st = PrepareQueryCommand(queryParameters, false, session);
- IDataReader rs =
- GetResultSet(st, queryParameters.HasAutoDiscoverScalarTypes, queryParameters.Callable, selection, session);
+ IDataReader rs = GetResultSet(st, queryParameters.HasAutoDiscoverScalarTypes, queryParameters.Callable, selection,
+ session);
// would be great to move all this below here into another method that could also be used
// from the new scrolling stuff.
@@ -428,9 +428,8 @@
log.Debug("result set row: " + count);
}
- object result =
- GetRowFromResultSet(rs, session, queryParameters, lockModeArray, optionalObjectKey, hydratedObjects, keys,
- returnProxies);
+ object result = GetRowFromResultSet(rs, session, queryParameters, lockModeArray, optionalObjectKey, hydratedObjects,
+ keys, returnProxies);
results.Add(result);
if (createSubselects)
@@ -445,11 +444,11 @@
log.Debug(string.Format("done processing result set ({0} rows)", count));
}
}
- catch(Exception e)
- {
- e.Data["actual-sql-query"] = st.CommandText;
- throw;
- }
+ catch (Exception e)
+ {
+ e.Data["actual-sql-query"] = st.CommandText;
+ throw;
+ }
finally
{
session.Batcher.CloseCommand(st, rs);
Modified: trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-01-02 18:52:54 UTC (rev 3973)
+++ trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-01-03 17:26:30 UTC (rev 3974)
@@ -1386,8 +1386,7 @@
public string[] GetCollectionPropertyColumnAliases(string propertyName, string suffix)
{
object aliases;
- collectionPropertyColumnAliases.TryGetValue(propertyName, out aliases);
- if (aliases == null)
+ if (!collectionPropertyColumnAliases.TryGetValue(propertyName, out aliases))
{
return null;
}
@@ -1425,13 +1424,29 @@
if (type.IsComponentType)
{
- IAbstractComponentType ct = (IAbstractComponentType) type;
+ // NH-1612: Recursively add column aliases for nested components to support the selection
+ // of individual component properties in native SQL queries. This also seems to provide
+ // a more complete solution to HHH-1019 (http://opensource.atlassian.com/projects/hibernate/browse/HHH-1019)
+ // because it works for <load-collection> and <return-join>.
+ int columnIndex = 0;
+
+ var ct = (IAbstractComponentType) type;
string[] propertyNames = ct.PropertyNames;
- for (int i = 0; i < propertyNames.Length; i++)
+ for (int propertyIndex = 0; propertyIndex < propertyNames.Length; propertyIndex++)
{
- string name = propertyNames[i];
- collectionPropertyColumnAliases[aliasName + "." + name] = columnAliases[i];
- collectionPropertyColumnNames[aliasName + "." + name] = columnNames[i];
+ string name = propertyNames[propertyIndex];
+ IType propertyType = ct.Subtypes[propertyIndex];
+ int propertyColSpan = propertyType.IsComponentType
+ ? ((IAbstractComponentType) propertyType).PropertyNames.Length
+ : 1;
+
+ var propertyColumnAliases = new string[propertyColSpan];
+ var propertyColumnNames = new string[propertyColSpan];
+ System.Array.Copy(columnAliases, columnIndex, propertyColumnAliases, 0, propertyColSpan);
+ System.Array.Copy(columnNames, columnIndex, propertyColumnNames, 0, propertyColSpan);
+ InitCollectionPropertyMap(aliasName + "." + name, propertyType, propertyColumnAliases, propertyColumnNames);
+
+ columnIndex += propertyColSpan;
}
}
}
Modified: trunk/nhibernate/src/NHibernate.Test/App.config
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/App.config 2009-01-02 18:52:54 UTC (rev 3973)
+++ trunk/nhibernate/src/NHibernate.Test/App.config 2009-01-03 17:26:30 UTC (rev 3974)
@@ -123,7 +123,7 @@
</logger>
<logger name="NHibernate.SQL">
- <level value="OFF" />
+ <level value="DEBUG" />
</logger>
<logger name="NHibernate.Tool.hbm2ddl.SchemaExport">
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Mappings.hbm.xml 2009-01-02 18:52:54 UTC (rev 3973)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Mappings.hbm.xml 2009-01-03 17:26:30 UTC (rev 3974)
@@ -75,7 +75,7 @@
<sql-query name="AreaStatisticsLoader" xml:space="preserve">
<load-collection role="Area.Statistics" alias="s">
- <return-property name="key" column="code" />
+ <return-property name="key" column="area_code" />
<return-property name="index" column="year" />
<return-property name="element.CitizenCount" column="citizen_count" />
<return-property name="element.GDP">
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/NativeSqlCollectionLoaderFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/NativeSqlCollectionLoaderFixture.cs 2009-01-02 18:52:54 UTC (rev 3973)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/NativeSqlCollectionLoaderFixture.cs 2009-01-03 17:26:30 UTC (rev 3974)
@@ -5,7 +5,7 @@
namespace NHibernate.Test.NHSpecificTest.NH1612
{
- [TestFixture, Ignore("Not fixed yet.")]
+ [TestFixture]
public class NativeSqlCollectionLoaderFixture : BugTestCase
{
#region Tests - <return-join>
@@ -18,16 +18,8 @@
Assert.That(country, Is.Not.Null);
Assert.That(country.Routes, Is.EquivalentTo(routes));
-
- // cleanup
- using (ISession session = OpenSession())
- {
- using (ITransaction tx = session.BeginTransaction())
- {
- session.Delete(country);
- tx.Commit();
- }
- }
+
+ Cleanup();
}
[Test]
@@ -37,15 +29,7 @@
Country country = LoadCountryWithNativeSQL(CreateCountry(routes), "LoadCountryRoutesWithCustomAliases");
Assert.That(country, Is.Not.Null);
Assert.That(country.Routes, Is.EquivalentTo(routes));
- // cleanup
- using (ISession session = OpenSession())
- {
- using (ITransaction tx = session.BeginTransaction())
- {
- session.Delete(country);
- tx.Commit();
- }
- }
+ Cleanup();
}
[Test]
@@ -57,15 +41,7 @@
Assert.That(country, Is.Not.Null);
Assert.That((ICollection) country.Statistics.Keys, Is.EquivalentTo((ICollection) stats.Keys), "Keys");
Assert.That((ICollection) country.Statistics.Values, Is.EquivalentTo((ICollection) stats.Values), "Elements");
- // cleanup
- using (ISession session = OpenSession())
- {
- using (ITransaction tx = session.BeginTransaction())
- {
- session.Delete(country);
- tx.Commit();
- }
- }
+ CleanupWithPersons();
}
[Test]
@@ -77,6 +53,7 @@
Assert.That(country, Is.Not.Null);
Assert.That((ICollection) country.Statistics.Keys, Is.EquivalentTo((ICollection) stats.Keys), "Keys");
Assert.That((ICollection) country.Statistics.Values, Is.EquivalentTo((ICollection) stats.Values), "Elements");
+ CleanupWithPersons();
}
[Test]
@@ -88,40 +65,81 @@
Assert.That(country, Is.Not.Null);
Assert.That((ICollection) country.Statistics.Keys, Is.EquivalentTo((ICollection) stats.Keys), "Keys");
Assert.That((ICollection) country.Statistics.Values, Is.EquivalentTo((ICollection) stats.Values), "Elements");
+
+ CleanupWithPersons();
}
[Test]
public void LoadEntitiesWithWithSimpleHbmAliasInjection()
{
City[] cities = CreateCities();
- Country country = LoadCountryWithNativeSQL(CreateCountry(cities), "LoadCountryCitiesWithSimpleHbmAliasInjection");
- Assert.That(country, Is.Not.Null);
- Assert.That(country.Cities, Is.EquivalentTo(cities));
+ Country country = CreateCountry(cities);
+ Save(country);
+ using (ISession session = OpenSession())
+ {
+ var c =
+ session.GetNamedQuery("LoadCountryCitiesWithSimpleHbmAliasInjection").SetString("country_code", country.Code).
+ UniqueResult<Country>();
+ Assert.That(c, Is.Not.Null);
+ Assert.That(c.Cities, Is.EquivalentTo(cities));
+ }
+ CleanupWithCities();
}
[Test]
public void LoadEntitiesWithComplexHbmAliasInjection()
{
City[] cities = CreateCities();
- Country country = LoadCountryWithNativeSQL(CreateCountry(cities), "LoadCountryCitiesWithComplexHbmAliasInjection");
- Assert.That(country, Is.Not.Null);
- Assert.That(country.Cities, Is.EquivalentTo(cities));
+ Country country = CreateCountry(cities);
+ Save(country);
+ using (ISession session = OpenSession())
+ {
+ var c =
+ session.GetNamedQuery("LoadCountryCitiesWithComplexHbmAliasInjection").SetString("country_code", country.Code).
+ UniqueResult<Country>();
+ Assert.That(c, Is.Not.Null);
+ Assert.That(c.Cities, Is.EquivalentTo(cities));
+ }
+ CleanupWithCities();
}
[Test]
public void LoadEntitiesWithExplicitColumnMappings()
{
City[] cities = CreateCities();
- Country country = LoadCountryWithNativeSQL(CreateCountry(cities), "LoadCountryCitiesWithCustomAliases");
- Assert.That(country, Is.Not.Null);
- Assert.That(country.Cities, Is.EquivalentTo(cities));
+ Country country = CreateCountry(cities);
+ Save(country);
+ using (ISession session = OpenSession())
+ {
+ var c =
+ session.GetNamedQuery("LoadCountryCitiesWithCustomAliases").SetString("country_code", country.Code).
+ UniqueResult<Country>();
+ Assert.That(c, Is.Not.Null);
+ Assert.That(c.Cities, Is.EquivalentTo(cities));
+ }
+
+ // cleanup
+ CleanupWithCities();
}
- [Test, ExpectedException(typeof (QueryException))]
+ [Test]
public void NativeQueryWithUnresolvedHbmAliasInjection()
{
IDictionary<int, AreaStatistics> stats = CreateStatistics();
- LoadCountryWithNativeSQL(CreateCountry(stats), "LoadAreaStatisticsWithFaultyHbmAliasInjection");
+ try
+ {
+ LoadCountryWithNativeSQL(CreateCountry(stats), "LoadAreaStatisticsWithFaultyHbmAliasInjection");
+ Assert.Fail("Expected exception");
+ }
+ catch(QueryException)
+ {
+ // ok
+ }
+ finally
+ {
+ // cleanup
+ CleanupWithPersons();
+ }
}
private Country LoadCountryWithNativeSQL(Country country, string queryName)
@@ -151,10 +169,14 @@
{
string[] routes = CreateRoutes();
Country country = CreateCountry(routes);
- Country c = SaveAndReload(country);
- Assert.That(c, Is.Not.Null, "country");
- Assert.That(c.Routes, Is.EquivalentTo(routes), "country.Routes");
-
+ Save(country);
+ using (ISession session = OpenSession())
+ {
+ var c = session.Get<Country>(country.Code);
+ Assert.That(c, Is.Not.Null, "country");
+ Assert.That(c.Routes, Is.EquivalentTo(routes), "country.Routes");
+ }
+ Cleanup();
}
[Test]
@@ -162,10 +184,15 @@
{
IDictionary<int, AreaStatistics> stats = CreateStatistics();
Country country = CreateCountry(stats);
- Area a = SaveAndReload(country);
- Assert.That(a, Is.Not.Null, "area");
- Assert.That((ICollection)a.Statistics.Keys, Is.EquivalentTo((ICollection)stats.Keys), "area.Keys");
- Assert.That((ICollection)a.Statistics.Values, Is.EquivalentTo((ICollection)stats.Values), "area.Elements");
+ Save(country);
+ using (ISession session = OpenSession())
+ {
+ var a = session.Get<Area>(country.Code);
+ Assert.That(a, Is.Not.Null, "area");
+ Assert.That((ICollection) a.Statistics.Keys, Is.EquivalentTo((ICollection) stats.Keys), "area.Keys");
+ Assert.That((ICollection) a.Statistics.Values, Is.EquivalentTo((ICollection) stats.Values), "area.Elements");
+ }
+ CleanupWithPersons();
}
[Test]
@@ -173,15 +200,19 @@
{
City[] cities = CreateCities();
Country country = CreateCountry(cities);
- Country c = SaveAndReload(country);
- Assert.That(c, Is.Not.Null, "country");
- Assert.That(c.Cities, Is.EquivalentTo(cities), "country.Cities");
+ Save(country);
+ using (ISession session = OpenSession())
+ {
+ var c = session.Get<Country>(country.Code);
+
+ Assert.That(c, Is.Not.Null, "country");
+ Assert.That(c.Cities, Is.EquivalentTo(cities), "country.Cities");
+ }
+ CleanupWithCities();
}
- private TArea SaveAndReload<TArea>(TArea area) where TArea : Area
+ private void Save<TArea>(TArea area) where TArea : Area
{
- //Ensure country is saved and session cache is empty to force from now on the reload of all
- //persistence objects from the database.
using (ISession session = OpenSession())
{
using (ITransaction tx = session.BeginTransaction())
@@ -189,12 +220,7 @@
session.Save(area);
tx.Commit();
}
-
}
- using (ISession session = OpenSession())
- {
- return session.Get<TArea>(area.Code);
- }
}
#endregion
@@ -261,6 +287,48 @@
#endregion
+ #region cleanup
+
+ private void Cleanup()
+ {
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.Delete("from Country");
+ tx.Commit();
+ }
+ }
+ }
+
+ private void CleanupWithPersons()
+ {
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.Delete("from Person");
+ session.Delete("from Country");
+ tx.Commit();
+ }
+ }
+ }
+
+ private void CleanupWithCities()
+ {
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.Delete("from City");
+ session.Delete("from Country");
+ tx.Commit();
+ }
+ }
+ }
+
+ #endregion
+
#region Factory methods
private static Country CreateCountry()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2009-01-05 00:13:17
|
Revision: 3975
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3975&view=rev
Author: tehlike
Date: 2009-01-05 00:13:13 +0000 (Mon, 05 Jan 2009)
Log Message:
-----------
Fix for NH-1575 by Ryan Scott
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs
trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlStringFixture.cs
Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs 2009-01-03 17:26:30 UTC (rev 3974)
+++ trunk/nhibernate/src/NHibernate/SqlCommand/SqlString.cs 2009-01-05 00:13:13 UTC (rev 3975)
@@ -24,7 +24,11 @@
private readonly object[] sqlParts;
public static readonly SqlString Empty = new SqlString(new object[0]);
- public static readonly SqlString Parameter = new SqlString(SqlCommand.Parameter.Placeholder);
+
+ public static SqlString Parameter
+ {
+ get { return new SqlString(SqlCommand.Parameter.Placeholder); }
+ }
public SqlString(string sqlPart)
{
Modified: trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlStringFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlStringFixture.cs 2009-01-03 17:26:30 UTC (rev 3974)
+++ trunk/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlStringFixture.cs 2009-01-05 00:13:13 UTC (rev 3975)
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using NHibernate.SqlCommand;
using NUnit.Framework;
@@ -359,5 +360,23 @@
Assert.AreEqual(" from table where (col = test) and id in (select id from foo order by bar)", sql.GetSubselectString().ToString());
}
+ [Test]
+ public void ParameterPropertyShouldReturnNewInstances()
+ {
+ Parameter[] parameters1 = new Parameter[1];
+ Parameter[] parameters2 = new Parameter[1];
+
+ SqlString parameterString1 = SqlString.Parameter;
+ parameterString1.Parts.CopyTo(parameters1, 0);
+
+ SqlString parameterString2 = SqlString.Parameter;
+ parameterString2.Parts.CopyTo(parameters2, 0);
+
+ Assert.AreEqual(parameterString1, parameterString2);
+ Assert.AreNotSame(parameterString1, parameterString2);
+
+ parameters1[0].OriginalPositionInQuery = 231;
+ Assert.IsNull(parameters2[0].OriginalPositionInQuery);
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aye...@us...> - 2009-01-05 10:54:09
|
Revision: 3976
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3976&view=rev
Author: ayenderahien
Date: 2009-01-05 10:54:05 +0000 (Mon, 05 Jan 2009)
Log Message:
-----------
Adding more information about caching to debug log
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cache/StandardQueryCache.cs
trunk/nhibernate/src/NHibernate/Event/Default/DefaultInitializeCollectionEventListener.cs
trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs
Modified: trunk/nhibernate/src/NHibernate/Cache/StandardQueryCache.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cache/StandardQueryCache.cs 2009-01-05 00:13:13 UTC (rev 3975)
+++ trunk/nhibernate/src/NHibernate/Cache/StandardQueryCache.cs 2009-01-05 10:54:05 UTC (rev 3976)
@@ -70,7 +70,7 @@
if (log.IsDebugEnabled)
{
- log.Debug("caching query results in region: " + regionName);
+ log.DebugFormat("caching query results in region: '{0}'; {1}", regionName, key);
}
IList cacheable = new List<object>(result.Count + 1);
@@ -95,23 +95,23 @@
{
if (log.IsDebugEnabled)
{
- log.Debug("checking cached query results in region: " + regionName);
+ log.DebugFormat("checking cached query results in region: '{0}'; {1}", regionName, key);
}
IList cacheable = (IList)queryCache.Get(key);
if (cacheable == null)
{
- log.Debug("query results were not found in cache");
+ log.DebugFormat("query results were not found in cache: {0}", key);
return null;
}
long timestamp = (long)cacheable[0];
- log.Debug("Checking query spaces for up-to-dateness [" + spaces + "]");
+ log.DebugFormat("Checking query spaces for up-to-dateness [{0}]", spaces);
if (!isNaturalKeyLookup && !IsUpToDate(spaces, timestamp))
{
- log.Debug("cached query results were not up to date");
+ log.DebugFormat("cached query results were not up to date for: {0}", key);
return null;
}
- log.Debug("returning cached query results");
+ log.DebugFormat("returning cached query results for: {0}", key);
for (int i = 1; i < cacheable.Count; i++)
{
if (returnTypes.Length == 1)
Modified: trunk/nhibernate/src/NHibernate/Event/Default/DefaultInitializeCollectionEventListener.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Event/Default/DefaultInitializeCollectionEventListener.cs 2009-01-05 00:13:13 UTC (rev 3975)
+++ trunk/nhibernate/src/NHibernate/Event/Default/DefaultInitializeCollectionEventListener.cs 2009-01-05 10:54:05 UTC (rev 3976)
@@ -88,10 +88,12 @@
if (ce == null)
{
factory.StatisticsImplementor.SecondLevelCacheMiss(persister.Cache.RegionName);
+ log.DebugFormat("Collection cache miss: {0}", ck);
}
else
{
factory.StatisticsImplementor.SecondLevelCacheHit(persister.Cache.RegionName);
+ log.DebugFormat("Collection cache hit: {0}", ck);
}
}
Modified: trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs 2009-01-05 00:13:13 UTC (rev 3975)
+++ trunk/nhibernate/src/NHibernate/Event/Default/DefaultLoadEventListener.cs 2009-01-05 10:54:05 UTC (rev 3976)
@@ -415,9 +415,15 @@
if (factory.Statistics.IsStatisticsEnabled)
{
if (ce == null)
+ {
factory.StatisticsImplementor.SecondLevelCacheMiss(persister.Cache.RegionName);
+ log.DebugFormat("Entity cache miss: {0}", ck);
+ }
else
+ {
factory.StatisticsImplementor.SecondLevelCacheHit(persister.Cache.RegionName);
+ log.DebugFormat("Entity cache hit: {0}", ck);
+ }
}
if (ce != null)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aye...@us...> - 2009-01-05 12:57:56
|
Revision: 3977
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3977&view=rev
Author: ayenderahien
Date: 2009-01-05 12:57:44 +0000 (Mon, 05 Jan 2009)
Log Message:
-----------
Fixing NH-1632 and NH-754
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/AdoNet/ConnectionManager.cs
trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs
trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs
trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Model.cs
Modified: trunk/nhibernate/src/NHibernate/AdoNet/ConnectionManager.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/AdoNet/ConnectionManager.cs 2009-01-05 10:54:05 UTC (rev 3976)
+++ trunk/nhibernate/src/NHibernate/AdoNet/ConnectionManager.cs 2009-01-05 12:57:44 UTC (rev 3977)
@@ -44,6 +44,8 @@
[NonSerialized]
private bool isFlushing;
+ private bool flushingFromDtcTransaction;
+
public ConnectionManager(
ISessionImplementor session,
IDbConnection suppliedConnection,
@@ -256,7 +258,7 @@
private void AggressiveRelease()
{
- if (ownConnection)
+ if (ownConnection && flushingFromDtcTransaction == false)
{
log.Debug("aggressively releasing database connection");
if (connection != null)
@@ -388,5 +390,29 @@
{
get { return batcher; }
}
+
+ public IDisposable FlushingFromDtcTransaction
+ {
+ get
+ {
+ flushingFromDtcTransaction = true;
+ return new StopFlushingFromDtcTransaction(this);
+ }
+ }
+
+ private class StopFlushingFromDtcTransaction : IDisposable
+ {
+ private readonly ConnectionManager manager;
+
+ public StopFlushingFromDtcTransaction(ConnectionManager manager)
+ {
+ this.manager = manager;
+ }
+
+ public void Dispose()
+ {
+ manager.flushingFromDtcTransaction = false;
+ }
+ }
}
}
Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-01-05 10:54:05 UTC (rev 3976)
+++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-01-05 12:57:44 UTC (rev 3977)
@@ -26,7 +26,16 @@
private bool closed = false;
private System.Transactions.Transaction ambientTransation;
private bool isAlreadyDisposed;
+ protected bool shouldCloseSessionOnDtcTransactionCompleted;
+ protected bool TakingPartInDtcTransaction
+ {
+ get
+ {
+ return ambientTransation != null;
+ }
+ }
+
internal AbstractSessionImpl() { }
protected internal AbstractSessionImpl(ISessionFactoryImplementor factory)
@@ -246,7 +255,8 @@
BeforeTransactionCompletion(null);
if (FlushMode != FlushMode.Never)
{
- Flush();
+ using (ConnectionManager.FlushingFromDtcTransaction)
+ Flush();
}
preparingEnlistment.Prepared();
}
@@ -282,10 +292,14 @@
{
bool wasSuccessful = e.Transaction.TransactionInformation.Status == TransactionStatus.Committed;
AfterTransactionCompletion(wasSuccessful, null);
+ if (shouldCloseSessionOnDtcTransactionCompleted)
+ Dispose(true);
};
ambientTransation.EnlistVolatile(this, EnlistmentOptions.None);
}
+ protected abstract void Dispose(bool disposing);
+
#endregion
}
}
Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-01-05 10:54:05 UTC (rev 3976)
+++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-01-05 12:57:44 UTC (rev 3977)
@@ -1363,6 +1363,11 @@
public void Dispose()
{
log.Debug("running ISession.Dispose()");
+ if (TakingPartInDtcTransaction)
+ {
+ shouldCloseSessionOnDtcTransactionCompleted = true;
+ return;
+ }
Dispose(true);
}
@@ -1375,7 +1380,7 @@
/// If this Session is being Finalized (<c>isDisposing==false</c>) then make sure not
/// to call any methods that could potentially bring this Session back to life.
/// </remarks>
- private void Dispose(bool isDisposing)
+ protected override void Dispose(bool isDisposing)
{
if (IsAlreadyDisposed)
{
Modified: trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-01-05 10:54:05 UTC (rev 3976)
+++ trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-01-05 12:57:44 UTC (rev 3977)
@@ -731,10 +731,15 @@
public void Dispose()
{
log.Debug("running IStatelessSession.Dispose()");
+ if(TakingPartInDtcTransaction)
+ {
+ shouldCloseSessionOnDtcTransactionCompleted = true;
+ return;
+ }
Dispose(true);
}
- private void Dispose(bool isDisposing)
+ protected override void Dispose(bool isDisposing)
{
if (_isAlreadyDisposed)
{
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs (from rev 3965, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Fixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs 2009-01-05 12:57:44 UTC (rev 3977)
@@ -0,0 +1,148 @@
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.NHSpecificTest.NH1632
+{
+ using System.Transactions;
+
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ public override string BugNumber
+ {
+ get { return "NH1632"; }
+ }
+
+ [Test]
+ public void Dispose_session_inside_transaction_scope()
+ {
+ ISession s;
+
+ using (var tx = new TransactionScope())
+ {
+ using (s = sessions.OpenSession())
+ {
+
+ }
+ tx.Complete();
+ }
+
+ Assert.IsFalse(s.IsOpen);
+ }
+
+ [Test]
+ public void When_committing_transaction_scope_will_commit_transaction()
+ {
+ object id;
+ using (var tx = new TransactionScope())
+ {
+ using (ISession s = sessions.OpenSession())
+ {
+ id = s.Save(new Nums { NumA = 1, NumB = 2, ID = 5 });
+ }
+ tx.Complete();
+ }
+
+ using (ISession s = sessions.OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ Nums nums = s.Get<Nums>(id);
+ Assert.IsNotNull(nums);
+ s.Delete(nums);
+
+ tx.Commit();
+ }
+ }
+
+ [Test]
+ public void Will_not_save_when_flush_mode_is_never()
+ {
+ object id;
+ using (var tx = new TransactionScope())
+ {
+ using (ISession s = sessions.OpenSession())
+ {
+ s.FlushMode = FlushMode.Never;
+ id = s.Save(new Nums { NumA = 1, NumB = 2, ID = 5 });
+ }
+ tx.Complete();
+ }
+
+ using (ISession s = sessions.OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ Nums nums = s.Get<Nums>(id);
+ Assert.IsNull(nums);
+ tx.Commit();
+ }
+ }
+
+ [Test]
+ public void When_using_two_sessions_with_explicit_flush()
+ {
+ object id1, id2;
+ using (var tx = new TransactionScope())
+ {
+ using (ISession s1 = sessions.OpenSession())
+ using (ISession s2 = sessions.OpenSession())
+ {
+
+ id1 = s1.Save(new Nums { NumA = 1, NumB = 2, ID = 5 });
+ s1.Flush();
+
+ id2 = s2.Save(new Nums { NumA = 1, NumB = 2, ID = 6 });
+ s2.Flush();
+
+ tx.Complete();
+ }
+ }
+
+ using (ISession s = sessions.OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ Nums nums = s.Get<Nums>(id1);
+ Assert.IsNotNull(nums);
+ s.Delete(nums);
+
+ nums = s.Get<Nums>(id2);
+ Assert.IsNotNull(nums);
+ s.Delete(nums);
+
+ tx.Commit();
+ }
+ }
+
+ [Test]
+ public void When_using_two_sessions()
+ {
+ object id1, id2;
+ using (var tx = new TransactionScope())
+ {
+ using (ISession s1 = sessions.OpenSession())
+ using (ISession s2 = sessions.OpenSession())
+ {
+
+ id1 = s1.Save(new Nums { NumA = 1, NumB = 2, ID = 5 });
+
+ id2 = s2.Save(new Nums { NumA = 1, NumB = 2, ID = 6 });
+
+ tx.Complete();
+ }
+ }
+
+ using (ISession s = sessions.OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ Nums nums = s.Get<Nums>(id1);
+ Assert.IsNotNull(nums);
+ s.Delete(nums);
+
+ nums = s.Get<Nums>(id2);
+ Assert.IsNotNull(nums);
+ s.Delete(nums);
+
+ tx.Commit();
+ }
+ }
+ }
+}
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Mappings.hbm.xml (from rev 3965, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Mappings.hbm.xml 2009-01-05 12:57:44 UTC (rev 3977)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1632"
+ assembly="NHibernate.Test"
+>
+ <class name="Nums" table="nums">
+ <id name="ID">
+ <generator class="assigned"/>
+ </id>
+ <property name="NumA"/>
+ <property name="NumB"/>
+ <property name="Sum" access="readonly"/>
+ </class>
+</hibernate-mapping>
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Mappings.hbm.xml
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Model.cs (from rev 3965, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Model.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Model.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Model.cs 2009-01-05 12:57:44 UTC (rev 3977)
@@ -0,0 +1,17 @@
+namespace NHibernate.Test.NHSpecificTest.NH1632
+{
+ public class Nums
+ {
+ public virtual int ID { get; set; }
+
+ public virtual int NumA { get; set; }
+ public virtual int NumB { get; set; }
+ public virtual int Sum
+ {
+ get
+ {
+ return NumA + NumB;
+ }
+ }
+ }
+}
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Model.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-05 10:54:05 UTC (rev 3976)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-05 12:57:44 UTC (rev 3977)
@@ -567,6 +567,8 @@
<Compile Include="NHSpecificTest\NH1612\Person.cs" />
<Compile Include="NHSpecificTest\NH1621\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1621\Model.cs" />
+ <Compile Include="NHSpecificTest\NH1632\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1632\Model.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -1588,6 +1590,11 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1632\Mappings.hbm.xml" />
+
+
+
+
<EmbeddedResource Include="NHSpecificTest\NH1612\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1549\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1521\AclassWithSpecific.hbm.xml" />
@@ -1699,4 +1706,4 @@
if exist "$(ProjectDir)hibernate.cfg.xml" (copy "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml")
copy /y "..\..\..\NHibernate.DomainModel\ABC.hbm.xml" "ABC.hbm.xml"</PostBuildEvent>
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aye...@us...> - 2009-01-05 23:22:39
|
Revision: 3979
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3979&view=rev
Author: ayenderahien
Date: 2009-01-05 23:22:36 +0000 (Mon, 05 Jan 2009)
Log Message:
-----------
log output is more easily parsable
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Util/CollectionPrinter.cs
trunk/nhibernate/src/NHibernate.Test/QueryTest/MultipleQueriesFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Util/CollectionPrinter.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/CollectionPrinter.cs 2009-01-05 14:13:16 UTC (rev 3978)
+++ trunk/nhibernate/src/NHibernate/Util/CollectionPrinter.cs 2009-01-05 23:22:36 UTC (rev 3979)
@@ -24,7 +24,10 @@
}
else
{
- builder.Append(value);
+ builder
+ .Append("'")
+ .Append(value)
+ .Append("'");
}
}
Modified: trunk/nhibernate/src/NHibernate.Test/QueryTest/MultipleQueriesFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/QueryTest/MultipleQueriesFixture.cs 2009-01-05 14:13:16 UTC (rev 3978)
+++ trunk/nhibernate/src/NHibernate.Test/QueryTest/MultipleQueriesFixture.cs 2009-01-05 23:22:36 UTC (rev 3979)
@@ -50,7 +50,7 @@
}
[Test]
- [ExpectedException(typeof(QueryException), ExpectedMessage = "Not all named parameters have been set: [ids] [from Item i where i.Id in (:ids)]")]
+ [ExpectedException(typeof(QueryException), ExpectedMessage = "Not all named parameters have been set: ['ids'] [from Item i where i.Id in (:ids)]")]
public void NH_1085_WillGiveReasonableErrorIfBadParameterName()
{
using (ISession s = sessions.OpenSession())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aye...@us...> - 2009-01-10 02:25:10
|
Revision: 3984
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3984&view=rev
Author: ayenderahien
Date: 2009-01-10 02:25:05 +0000 (Sat, 10 Jan 2009)
Log Message:
-----------
TableHiLoGenerator - now can safely create hilo ids inside DTC transactions.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Id/TableGenerator.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Model.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Modified: trunk/nhibernate/src/NHibernate/Id/TableGenerator.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Id/TableGenerator.cs 2009-01-09 23:31:13 UTC (rev 3983)
+++ trunk/nhibernate/src/NHibernate/Id/TableGenerator.cs 2009-01-10 02:25:05 UTC (rev 3984)
@@ -13,6 +13,8 @@
namespace NHibernate.Id
{
+ using System.Transactions;
+
/// <summary>
/// An <see cref="IIdentifierGenerator" /> that uses a database table to store the last
/// generated value.
@@ -158,21 +160,27 @@
bool isSQLite = session.Factory.Dialect is SQLiteDialect;
IDbConnection conn;
+ TransactionScope dtcTrans = null;
if (isSQLite)
{
conn = session.Connection;
}
else
{
+ // existing dtc transaction, creating a new one
+ // to override the ambient one
+ if (Transaction.Current != null)
+ dtcTrans = new TransactionScope(TransactionScopeOption.RequiresNew);
conn = session.Factory.ConnectionProvider.GetConnection();
}
+ IDbTransaction trans = null;
try
{
- IDbTransaction trans = null;
if (!isSQLite)
{
- trans = conn.BeginTransaction();
+ if(dtcTrans==null)
+ trans = conn.BeginTransaction();
}
long result;
@@ -239,7 +247,10 @@
if (!isSQLite)
{
- trans.Commit();
+ if (dtcTrans != null)
+ dtcTrans.Complete();
+ else
+ trans.Commit();
}
return result;
@@ -249,6 +260,8 @@
{
if (!isSQLite)
{
+ if(dtcTrans!=null)
+ dtcTrans.Dispose();
session.Factory.ConnectionProvider.CloseConnection(conn);
}
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs 2009-01-09 23:31:13 UTC (rev 3983)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs 2009-01-10 02:25:05 UTC (rev 3984)
@@ -6,6 +6,8 @@
using System.Transactions;
using Cache;
using Cfg;
+ using Engine;
+ using Id;
[TestFixture]
public class Fixture : BugTestCase
@@ -23,6 +25,42 @@
}
[Test]
+ public void When_using_DTC_HiLo_knows_to_create_isolated_DTC_transaction()
+ {
+ object scalar1, scalar2;
+
+ using (var session = sessions.OpenSession())
+ using (var command = session.Connection.CreateCommand())
+ {
+ command.CommandText = "select next_hi from hibernate_unique_key with (updlock, rowlock)";
+ scalar1 = command.ExecuteScalar();
+ }
+
+ using (var tx = new TransactionScope())
+ {
+ var generator = sessions.GetIdentifierGenerator(typeof(Person).FullName);
+ Assert.IsInstanceOfType(typeof(TableHiLoGenerator), generator);
+
+ using(var session = sessions.OpenSession())
+ {
+ var id = generator.Generate((ISessionImplementor) session, new Person());
+ }
+
+ // intentionally dispose without committing
+ tx.Dispose();
+ }
+
+ using (var session = sessions.OpenSession())
+ using (var command = session.Connection.CreateCommand())
+ {
+ command.CommandText = "select next_hi from hibernate_unique_key with (updlock, rowlock)";
+ scalar2 = command.ExecuteScalar();
+ }
+
+ Assert.AreNotEqual(scalar1, scalar2,"HiLo must run with in its own transaction");
+ }
+
+ [Test]
public void Dispose_session_inside_transaction_scope()
{
ISession s;
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Mappings.hbm.xml 2009-01-09 23:31:13 UTC (rev 3983)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Mappings.hbm.xml 2009-01-10 02:25:05 UTC (rev 3984)
@@ -14,4 +14,14 @@
<property name="NumB"/>
<property name="Sum" access="readonly"/>
</class>
+
+ <class name="Person">
+ <cache usage="read-write" />
+
+ <id name="Id">
+ <generator class="hilo"/>
+ </id>
+
+ <property name="Name"/>
+ </class>
</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Model.cs 2009-01-09 23:31:13 UTC (rev 3983)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1632/Model.cs 2009-01-10 02:25:05 UTC (rev 3984)
@@ -14,4 +14,10 @@
}
}
}
+
+ public class Person
+ {
+ public virtual int Id { get; set; }
+ public virtual string Name { get; set; }
+ }
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-09 23:31:13 UTC (rev 3983)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-10 02:25:05 UTC (rev 3984)
@@ -1591,10 +1591,6 @@
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
<EmbeddedResource Include="NHSpecificTest\NH1632\Mappings.hbm.xml" />
-
-
-
-
<EmbeddedResource Include="NHSpecificTest\NH1612\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1549\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1521\AclassWithSpecific.hbm.xml" />
@@ -1706,4 +1702,4 @@
if exist "$(ProjectDir)hibernate.cfg.xml" (copy "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml")
copy /y "..\..\..\NHibernate.DomainModel\ABC.hbm.xml" "ABC.hbm.xml"</PostBuildEvent>
</PropertyGroup>
-</Project>
+</Project>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|