|
From: <aye...@us...> - 2009-01-12 19:05:15
|
Revision: 3996
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3996&view=rev
Author: ayenderahien
Date: 2009-01-12 19:05:10 +0000 (Mon, 12 Jan 2009)
Log Message:
-----------
NH-1643 - Allowing to use more than just ISet<T> for <set>
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate/Type/GenericSetType.cs
trunk/nhibernate/src/NHibernate.Test/App.config
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Department.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Employee.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-10 21:34:06 UTC (rev 3995)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-01-12 19:05:10 UTC (rev 3996)
@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
+ <ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -1121,13 +1121,15 @@
<Compile Include="Util\XmlHelper.cs" />
<Compile Include="Properties\XmlAccessor.cs" />
<EmbeddedResource Include="nhibernate-configuration.xsd">
- <SubType>Designer</SubType>
+ <SubType>
+ </SubType>
</EmbeddedResource>
<None Include="nhibernate-configuration.xsx">
<DependentUpon>nhibernate-configuration.xsd</DependentUpon>
</None>
<EmbeddedResource Include="nhibernate-mapping.xsd">
- <SubType>Designer</SubType>
+ <SubType>
+ </SubType>
</EmbeddedResource>
<None Include="nhibernate-mapping.xsx">
<DependentUpon>nhibernate-mapping.xsd</DependentUpon>
Modified: trunk/nhibernate/src/NHibernate/Type/GenericSetType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/GenericSetType.cs 2009-01-10 21:34:06 UTC (rev 3995)
+++ trunk/nhibernate/src/NHibernate/Type/GenericSetType.cs 2009-01-12 19:05:10 UTC (rev 3996)
@@ -48,14 +48,22 @@
/// <param name="session">The <see cref="ISessionImplementor"/> for the collection to be a part of.</param>
/// <param name="collection">The unwrapped <see cref="IList{T}"/>.</param>
/// <returns>
- /// An <see cref="PersistentGenericSet<T>"/> that wraps the non NHibernate <see cref="IList<T>"/>.
+ /// An <see cref="PersistentGenericSet<T>"/> that wraps the non NHibernate <see cref="IList{T}"/>.
/// </returns>
public override IPersistentCollection Wrap(ISessionImplementor session, object collection)
{
- return new PersistentGenericSet<T>(session, (ISet<T>) collection);
+ var set = collection as ISet<T>;
+ if(set==null)
+ {
+ var stronglyTypedCollection = collection as ICollection<T>;
+ if(stronglyTypedCollection==null)
+ throw new HibernateException(Role + " must be an implementation of ISet<T> or ICollection<T>");
+ set = new HashedSet<T>(stronglyTypedCollection);
+ }
+ return new PersistentGenericSet<T>(session, set);
}
- public override object Instantiate(int anticipatedSize)
+ public override object Instantiate(int anticipatedSize)
{
return new HashedSet<T>();
}
Modified: trunk/nhibernate/src/NHibernate.Test/App.config
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/App.config 2009-01-10 21:34:06 UTC (rev 3995)
+++ trunk/nhibernate/src/NHibernate.Test/App.config 2009-01-12 19:05:10 UTC (rev 3996)
@@ -58,7 +58,7 @@
<!-- This is the System.Data.dll provider for MSSQL Server -->
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">
- Server=(local);initial catalog=nhibernate;Integrated Security=SSPI
+ Server=(local)\sqlexpress;initial catalog=nhibernate;Integrated Security=SSPI
</property>
<property name="show_sql">false</property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643
___________________________________________________________________
Added: bugtraq:url
+ http://jira.nhibernate.org/browse/%BUGID%
Added: bugtraq:logregex
+ NH-\d+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Department.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Department.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Department.cs 2009-01-12 19:05:10 UTC (rev 3996)
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1643
+{
+ public class Department
+ {
+ public virtual int Id { get; set; }
+
+ public virtual string Name { get; set; }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Employee.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Employee.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Employee.cs 2009-01-12 19:05:10 UTC (rev 3996)
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1643
+{
+ public class Employee
+ {
+ public virtual int Id { get; set; }
+
+ public virtual string FirstName { get; set; }
+
+ public virtual string LastName { get; set; }
+
+ private ICollection<Department> department = new List<Department>();
+
+ public virtual ICollection<Department> Departments
+ {
+ get { return department; }
+ set { department = value; }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Fixture.cs 2009-01-12 19:05:10 UTC (rev 3996)
@@ -0,0 +1,61 @@
+using NHibernate.Cfg;
+using NUnit.Framework;
+using NHibernate.Stat;
+
+namespace NHibernate.Test.NHSpecificTest.NH1643
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ public override string BugNumber
+ {
+ get { return "NH1643"; }
+ }
+
+ [Test]
+ public void Test()
+ {
+ int employeeId;
+ using (ISession sess = OpenSession())
+ using (ITransaction tx = sess.BeginTransaction())
+ {
+ Department dept = new Department();
+ dept.Id = 11;
+ dept.Name = "Animal Testing";
+
+ sess.Save(dept);
+
+ Employee emp = new Employee();
+ emp.Id = 1;
+ emp.FirstName = "John";
+ emp.LastName = "Doe";
+ emp.Departments.Add(dept);
+
+ sess.Save(emp);
+
+ tx.Commit();
+
+ employeeId = emp.Id;
+ }
+
+ using (ISession sess = OpenSession())
+ using (ITransaction tx = sess.BeginTransaction())
+ {
+ var load = sess.Load<Employee>(employeeId);
+ Assert.AreEqual(1, load.Departments.Count);
+
+ tx.Commit();
+ }
+
+
+
+ using (ISession sess = OpenSession())
+ using (ITransaction tx = sess.BeginTransaction())
+ {
+ sess.Delete("from Employee");
+ sess.Delete("from Department");
+ tx.Commit();
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1643/Mappings.hbm.xml 2009-01-12 19:05:10 UTC (rev 3996)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1643"
+ assembly="NHibernate.Test">
+
+ <class name="Department" table="DEPARTMENTS">
+ <id name="Id" column="DEPARTMENT_ID" type="Int32">
+ <generator class="assigned" />
+ </id>
+ <property name="Name" column="DEPARTMENT_NAME" type="String" />
+ </class>
+
+ <class name="Employee" table="EMPLOYEES" >
+ <id name="Id" column="EMPLOYEE_ID" type="Int32">
+ <generator class="assigned" />
+ </id>
+
+ <property name="FirstName" column="FIRST_NAME" type="String" />
+ <property name="LastName" column="LAST_NAME" type="String" />
+
+ <set name="Departments">
+ <key column="Employee"/>
+ <one-to-many class="Department"/>
+ </set>
+ </class>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-10 21:34:06 UTC (rev 3995)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-12 19:05:10 UTC (rev 3996)
@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
+ <ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7AEE5B37-C552-4E59-9B6F-88755BCB5070}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -578,6 +578,9 @@
<Compile Include="NHSpecificTest\NH1632\Model.cs" />
<Compile Include="NHSpecificTest\NH1640\Entity.cs" />
<Compile Include="NHSpecificTest\NH1640\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1643\Department.cs" />
+ <Compile Include="NHSpecificTest\NH1643\Employee.cs" />
+ <Compile Include="NHSpecificTest\NH1643\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -1599,6 +1602,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1643\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1640\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1584\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1632\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|