|
From: <fab...@us...> - 2009-03-18 15:54:49
|
Revision: 4146
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4146&view=rev
Author: fabiomaulo
Date: 2009-03-18 15:54:41 +0000 (Wed, 18 Mar 2009)
Log Message:
-----------
Fix NH-1706
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Engine/EntityKey.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1706/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1706/Domain.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1706/KeyPropertyRefFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1706/Mappings.hbm.xml
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityKeyFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Engine/EntityKey.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/EntityKey.cs 2009-03-18 13:41:14 UTC (rev 4145)
+++ trunk/nhibernate/src/NHibernate/Engine/EntityKey.cs 2009-03-18 15:54:41 UTC (rev 4146)
@@ -41,14 +41,6 @@
if (identifier == null)
throw new AssertionFailure("null identifier");
- System.Type expected = identifier.GetType();
- System.Type found = identifierType.ReturnedClass;
- if (!found.IsAssignableFrom(expected))
- {
- throw new ArgumentException(string.Format("Identifier type mismatch; Found:<{0}> Expected:<{1}>", found, expected),
- "identifier");
- }
-
this.identifier = identifier;
this.rootEntityName = rootEntityName;
this.entityName = entityName;
@@ -76,7 +68,7 @@
public override bool Equals(object other)
{
- EntityKey otherKey = other as EntityKey;
+ var otherKey = other as EntityKey;
if(otherKey==null) return false;
return
@@ -108,10 +100,10 @@
/// <summary>
/// To use in deserialization callback
/// </summary>
- /// <param name="factory"></param>
- internal void SetSessionFactory(ISessionFactoryImplementor factory)
+ /// <param name="sessionFactory"></param>
+ internal void SetSessionFactory(ISessionFactoryImplementor sessionFactory)
{
- this.factory = factory;
+ factory = sessionFactory;
hashCode = GetHashCode();
}
}
Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityKeyFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityKeyFixture.cs 2009-03-18 13:41:14 UTC (rev 4145)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/EntityKeyFixture.cs 2009-03-18 15:54:41 UTC (rev 4146)
@@ -1,499 +0,0 @@
-using System;
-using System.Collections;
-using NHibernate.Cache;
-using NHibernate.Cache.Entry;
-using NHibernate.Engine;
-using NHibernate.Id;
-using NHibernate.Metadata;
-using NHibernate.Persister.Entity;
-using NHibernate.Tuple.Entity;
-using NHibernate.Type;
-using NUnit.Framework;
-
-namespace NHibernate.Test.NHSpecificTest
-{
-
- public class TestingClassPersister : IEntityPersister
- {
- public IType IdentifierType
- {
- get { return NHibernateUtil.Int32; }
- }
-
- // NOTE:
- // IdentifierType is what we need for this test.
- // other properties with a sort of implementation are :
- // RootEntityName, EntityName, IsBatchLoadable, Factory
-
- #region IEntityPersister Members
-
- public ISessionFactoryImplementor Factory
- {
- get { return null; }
- }
-
- public string RootEntityName
- {
- get { return null; }
- }
-
- public string EntityName
- {
- get { return null; }
- }
-
- public EntityMetamodel EntityMetamodel
- {
- get { throw new NotImplementedException(); }
- }
-
- public string[] PropertySpaces
- {
- get { throw new NotImplementedException(); }
- }
-
- public string[] QuerySpaces
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool IsMutable
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool IsInherited
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool IsIdentifierAssignedByInsert
- {
- get { throw new NotImplementedException(); }
- }
-
- #region IOptimisticCacheSource Members
-
- public bool IsVersioned
- {
- get { throw new NotImplementedException(); }
- }
-
- bool IEntityPersister.IsVersioned
- {
- get { throw new NotImplementedException(); }
- }
-
- public IVersionType VersionType
- {
- get { throw new NotImplementedException(); }
- }
-
- public int VersionProperty
- {
- get { throw new NotImplementedException(); }
- }
-
- public int[] NaturalIdentifierProperties
- {
- get { throw new NotImplementedException(); }
- }
-
- public IIdentifierGenerator IdentifierGenerator
- {
- get { throw new NotImplementedException(); }
- }
-
- public IType[] PropertyTypes
- {
- get { throw new NotImplementedException(); }
- }
-
- public string[] PropertyNames
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool[] PropertyInsertability
- {
- get { throw new NotImplementedException(); }
- }
-
- public ValueInclusion[] PropertyInsertGenerationInclusions
- {
- get { throw new NotImplementedException(); }
- }
-
- public ValueInclusion[] PropertyUpdateGenerationInclusions
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool[] PropertyCheckability
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool[] PropertyNullability
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool[] PropertyVersionability
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool[] PropertyLaziness
- {
- get { throw new NotImplementedException(); }
- }
-
- public CascadeStyle[] PropertyCascadeStyles
- {
- get { throw new NotImplementedException(); }
- }
-
- public string IdentifierPropertyName
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool IsCacheInvalidationRequired
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool IsLazyPropertiesCacheable
- {
- get { throw new NotImplementedException(); }
- }
-
- public ICacheConcurrencyStrategy Cache
- {
- get { throw new NotImplementedException(); }
- }
-
- public ICacheEntryStructure CacheEntryStructure
- {
- get { throw new NotImplementedException(); }
- }
-
- public IClassMetadata ClassMetadata
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool IsBatchLoadable
- {
- get { return false; }
- }
-
- public bool IsSelectBeforeUpdateRequired
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool IsVersionPropertyGenerated
- {
- get { throw new NotImplementedException(); }
- }
-
- public void PostInstantiate()
- {
- throw new NotImplementedException();
- }
-
- public bool IsSubclassEntityName(string entityName)
- {
- throw new NotImplementedException();
- }
-
- public bool HasProxy
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool HasCollections
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool HasMutableProperties
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool HasSubselectLoadableCollections
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool HasCascades
- {
- get { throw new NotImplementedException(); }
- }
-
- public IType GetPropertyType(string propertyName)
- {
- throw new NotImplementedException();
- }
-
- public int[] FindDirty(object[] currentState, object[] previousState, object entity, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public int[] FindModified(object[] old, object[] current, object entity, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public bool HasIdentifierProperty
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool CanExtractIdOutOfEntity
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool HasNaturalIdentifier
- {
- get { throw new NotImplementedException(); }
- }
-
- public object[] GetNaturalIdentifierSnapshot(object id, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public bool HasLazyProperties
- {
- get { throw new NotImplementedException(); }
- }
-
- public object Load(object id, object optionalObject, LockMode lockMode, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public void Lock(object id, object version, object obj, LockMode lockMode, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public void Insert(object id, object[] fields, object obj, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public object Insert(object[] fields, object obj, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public void Delete(object id, object version, object obj, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public void Update(object id, object[] fields, int[] dirtyFields, bool hasDirtyCollection, object[] oldFields,
- object oldVersion, object obj, object rowId, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public bool[] PropertyUpdateability
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool HasCache
- {
- get { throw new NotImplementedException(); }
- }
-
- public object[] GetDatabaseSnapshot(object id, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public object GetCurrentVersion(object id, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public object ForceVersionIncrement(object id, object currentVersion, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public EntityMode? GuessEntityMode(object obj)
- {
- throw new NotImplementedException();
- }
-
- public bool IsInstrumented(EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public bool HasInsertGeneratedProperties
- {
- get { throw new NotImplementedException(); }
- }
-
- public bool HasUpdateGeneratedProperties
- {
- get { throw new NotImplementedException(); }
- }
-
- public void AfterInitialize(object entity, bool lazyPropertiesAreUnfetched, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public void AfterReassociate(object entity, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public object CreateProxy(object id, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public bool? IsTransient(object obj, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public object[] GetPropertyValuesToInsert(object obj, IDictionary mergeMap, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public void ProcessInsertGeneratedProperties(object id, object entity, object[] state, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public void ProcessUpdateGeneratedProperties(object id, object entity, object[] state, ISessionImplementor session)
- {
- throw new NotImplementedException();
- }
-
- public System.Type GetMappedClass(EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public bool ImplementsLifecycle(EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public bool ImplementsValidatable(EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public System.Type GetConcreteProxyClass(EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public void SetPropertyValues(object obj, object[] values, EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public void SetPropertyValue(object obj, int i, object value, EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public object[] GetPropertyValues(object obj, EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public object GetPropertyValue(object obj, int i, EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public object GetPropertyValue(object obj, string name, EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public object GetIdentifier(object obj, EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public void SetIdentifier(object obj, object id, EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public object GetVersion(object obj, EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public object Instantiate(object id, EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public bool IsInstance(object entity, EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public bool HasUninitializedLazyProperties(object obj, EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public void ResetIdentifier(object entity, object currentId, object currentVersion, EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public IEntityPersister GetSubclassEntityPersister(object instance, ISessionFactoryImplementor factory,
- EntityMode entityMode)
- {
- throw new NotImplementedException();
- }
-
- public bool? IsUnsavedVersion(object version)
- {
- throw new NotImplementedException();
- }
-
- #endregion
-
- public IComparer VersionComparator
- {
- get { throw new NotImplementedException(); }
- }
-
- #endregion
- }
-
- [TestFixture]
- public class EntityKeyFixture
- {
- [Test, ExpectedException(typeof(ArgumentException))]
- public void CreateWithWrongTypeOfId()
- {
- IEntityPersister persister = new TestingClassPersister();
- EntityKey key = new EntityKey(1L, persister, EntityMode.Poco);
- }
- }
-}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1706/Domain.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1706/Domain.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1706/Domain.cs 2009-03-18 15:54:41 UTC (rev 4146)
@@ -0,0 +1,28 @@
+using Iesi.Collections;
+
+namespace NHibernate.Test.NHSpecificTest.NH1706
+{
+ public class A
+ {
+ public A()
+ {
+ Items = new HashedSet();
+ }
+ public int Id { get; set; }
+
+ public string ExtraIdA { get; set; }
+
+ public string Name { get; set; }
+
+ public virtual ISet Items { get; set; }
+ }
+
+ public class B
+ {
+ public virtual int Id { get; set; }
+
+ public virtual string Name { get; set; }
+
+ public virtual string ExtraIdB { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1706/KeyPropertyRefFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1706/KeyPropertyRefFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1706/KeyPropertyRefFixture.cs 2009-03-18 15:54:41 UTC (rev 4146)
@@ -0,0 +1,42 @@
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1706
+{
+ [TestFixture]
+ public class KeyPropertyRefFixture : BugTestCase
+ {
+ [Test]
+ public void PropertyRefUsesOtherColumn()
+ {
+ const string ExtraId = "extra";
+
+ var a = new A { Name = "First", ExtraIdA = ExtraId };
+
+ var b = new B { Name = "Second", ExtraIdB = ExtraId };
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Save(a);
+ s.Save(b);
+ tx.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ {
+ var newA = s.Get<A>(a.Id);
+
+ Assert.AreEqual(1, newA.Items.Count);
+ }
+
+ // cleanup
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Delete("from B");
+ s.Delete("from A");
+ tx.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1706/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1706/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1706/Mappings.hbm.xml 2009-03-18 15:54:41 UTC (rev 4146)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1706">
+
+ <class name="A" lazy="false">
+ <id name="Id">
+ <generator class="native" />
+ </id>
+ <property name="Name"/>
+ <property name="ExtraIdA"/>
+ <set name="Items" lazy="true">
+ <key column="ExtraIdb" property-ref="ExtraIdA" />
+ <one-to-many class="B" />
+ </set>
+ </class>
+
+ <class name="B">
+ <id name="Id">
+ <generator class="native" />
+ </id>
+ <property name="Name"/>
+ <property name="ExtraIdB"/>
+ </class>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-18 13:41:14 UTC (rev 4145)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-18 15:54:41 UTC (rev 4146)
@@ -292,6 +292,8 @@
<Compile Include="GenericTest\SetGeneric\SetGenericFixture.cs" />
<Compile Include="HQL\Animal.cs" />
<Compile Include="HQL\BaseFunctionFixture.cs" />
+ <Compile Include="NHSpecificTest\NH1706\Domain.cs" />
+ <Compile Include="NHSpecificTest\NH1706\KeyPropertyRefFixture.cs" />
<Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" />
<Compile Include="HQL\HQLFunctions.cs" />
<Compile Include="HQL\Human.cs" />
@@ -668,7 +670,6 @@
<Compile Include="NHSpecificTest\Docs\ExampleParentChild\UpdateFixture.cs" />
<Compile Include="NHSpecificTest\Docs\PersistentClasses\Cat.cs" />
<Compile Include="NHSpecificTest\EmptyMappingsFixture.cs" />
- <Compile Include="NHSpecificTest\EntityKeyFixture.cs" />
<Compile Include="NHSpecificTest\GetSetHelperFixture.cs" />
<Compile Include="NHSpecificTest\GetTest.cs" />
<Compile Include="NHSpecificTest\LazyLoadBugTest.cs" />
@@ -1683,6 +1684,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1706\Mappings.hbm.xml" />
<EmbeddedResource Include="Stateless\Naturalness.hbm.xml" />
<EmbeddedResource Include="TransformTests\Simple.hbm.xml" />
<EmbeddedResource Include="VersionTest\Db\MsSQL\ComplexVersioned.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|