?

Tuna Toksöz schrieb:
> Hibernate has this as xml config, why don't we have it as config, instead of
> ISchemaXXXX
> 
> On Fri, Nov 14, 2008 at 12:16 PM, Steve Wagner <[EMAIL PROTECTED]> wrote:
> 
>> So now it is in jira :-)
>>
>> http://jira.nhibernate.org/browse/NH-1568
>>
>> Dose you have an issue for the SchemaVerify? Should i create one?
>>
>> Fabio Maulo schrieb:
>>> Steve... My friend...Which is the right place for features request and
>> patch
>>> ?    ;)
>>>
>>> 2008/11/13 Steve Wagner <[EMAIL PROTECTED]>
>>>
>>>> Hi Fabio, here is a patch which adds 3 tests where one is currently
>>>> failing. Add the failing test i added a short description.
>>>>
>>>> Steve Wagner schrieb:
>>>>> Ok i will try it.
>>>>>
>>>>> If both SchemaVerify and this are work, i think the following workflow
>>>>> could prevent the ghosting.
>>>>>
>>>>> * I create a Test which runs SchemaVerify.
>>>>> * SchemaVerify tells me that i could run into ghosting with the current
>>>>> mapping.
>>>>> * I change the mapping with the property
>>>>> * SchemaVerify passes
>>>>>
>>>>> Fabio Maulo schrieb:
>>>>>> 2008/11/13 Steve Wagner <[EMAIL PROTECTED]>
>>>>>>
>>>>>>>  Wouldn't it here a good suggestion to add an per property option
>> which
>>>>>>> forces nhibernate to eval DBNull.Value==default(T) if it dose a dirty
>>>>>>> check?
>>>>>>>
>>>>>> I think we have it working. In meta-data we having DefaultValue
>> exactly
>>>> for
>>>>>> that.mmm wait ... sometimes you are talking about a new feature for
>>>> existing
>>>>>> data where you don't want to change the existing record even if you
>> have
>>>> a
>>>>>> value in the entity and a null in the DB.
>>>>>> Do you can create a failing test for the new feature ?
>>>>>>
>>>> Index: nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
>>>> ===================================================================
>>>> --- nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
>> (Revision
>>>> 3887)
>>>> +++ nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
>>>> (Arbeitskopie)
>>>> @@ -375,6 +375,10 @@
>>>>     <Compile Include="NHSpecificTest\CollectionFixture.cs" />
>>>>     <Compile Include="NHSpecificTest\CriteriaFromHql\Fixture.cs" />
>>>>     <Compile Include="NHSpecificTest\CriteriaFromHql\Person.cs" />
>>>> +    <Compile Include="NHSpecificTest\Ghosting\Fixture.cs" />
>>>> +    <Compile Include="NHSpecificTest\Ghosting\Person.cs" />
>>>> +    <Compile Include="NHSpecificTest\Ghosting\PersonPreventGhost.cs" />
>>>> +    <Compile Include="NHSpecificTest\Ghosting\PersonWithGhost.cs" />
>>>>     <Compile Include="NHSpecificTest\NH1033\Animal.cs" />
>>>>     <Compile Include="NHSpecificTest\NH1033\Fixture.cs" />
>>>>     <Compile Include="NHSpecificTest\NH1033\Reptile.cs" />
>>>> @@ -1515,6 +1519,7 @@
>>>>     <EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
>>>>     <EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
>>>>     <Content Include="DynamicEntity\package.html" />
>>>> +    <EmbeddedResource
>> Include="NHSpecificTest\Ghosting\Mappings.hbm.xml"
>>>> />
>>>>     <EmbeddedResource Include="NHSpecificTest\NH1478\Mappings.hbm.xml"
>> />
>>>>     <EmbeddedResource Include="NHSpecificTest\NH1447\Mappings.hbm.xml"
>> />
>>>>     <EmbeddedResource Include="TypesTest\EnumCharClass.hbm.xml" />
>>>>
>>>> Eigenschaftsänderungen:
>>>> nhibernate\src\NHibernate.Test\NHSpecificTest\Ghosting
>>>> ___________________________________________________________________
>>>> Hinzugefügt: bugtraq:url
>>>>   + http://jira.nhibernate.org/browse/%BUGID%
>>>> Hinzugefügt: bugtraq:logregex
>>>>   + NH-\d+
>>>>
>>>>
>>>> Index: nhibernate/src/NHibernate.Test/NHSpecificTest/Ghosting/Fixture.cs
>>>> ===================================================================
>>>> --- nhibernate/src/NHibernate.Test/NHSpecificTest/Ghosting/Fixture.cs
>>>> (Revision 0)
>>>> +++ nhibernate/src/NHibernate.Test/NHSpecificTest/Ghosting/Fixture.cs
>>>> (Revision 0)
>>>> @@ -0,0 +1,88 @@
>>>> +using NUnit.Framework;
>>>> +
>>>> +namespace NHibernate.Test.NHSpecificTest.Ghosting
>>>> +{
>>>> +    [TestFixture]
>>>> +    public class Fixture : BugTestCase
>>>> +    {
>>>> +        protected override void OnSetUp()
>>>> +        {
>>>> +            Person person = new Person();
>>>> +            person.Number = null;
>>>> +
>>>> +            using (ISession session = OpenSession())
>>>> +            using (ITransaction tx = session.BeginTransaction())
>>>> +            {
>>>> +                session.Save( person );
>>>> +
>>>> +                tx.Commit();
>>>> +            }
>>>> +        }
>>>> +
>>>> +        protected override void OnTearDown()
>>>> +        {
>>>> +            using (ISession session = OpenSession())
>>>> +            using (ITransaction tx = session.BeginTransaction())
>>>> +            {
>>>> +                session.Delete( "from Person" );
>>>> +                session.Delete( "from PersonWithGhost" );
>>>> +                tx.Commit();
>>>> +            }
>>>> +        }
>>>> +
>>>> +        [Test]
>>>> +        public void PersonWasPersistedCorrectlyAndGeneratesNoGhost()
>>>> +        {
>>>> +            using (ISession session = OpenSession())
>>>> +            using (ITransaction tx = session.BeginTransaction())
>>>> +            {
>>>> +                var person = session.CreateCriteria( typeof( Person ) )
>>>> +                    .SetMaxResults( 1 )
>>>> +                    .UniqueResult<Person>();
>>>> +
>>>> +                Assert.IsNotNull( person );
>>>> +                Assert.IsNull( person.Number );
>>>> +                Assert.IsFalse( session.IsDirty() );
>>>> +            }
>>>> +        }
>>>> +
>>>> +        [Test]
>>>> +        public void PersonGeneratesAGhost()
>>>> +        {
>>>> +            using( ISession session = OpenSession() )
>>>> +            using( ITransaction tx = session.BeginTransaction() )
>>>> +            {
>>>> +                var person = session.CreateCriteria( typeof(
>>>> PersonWithGhost ) )
>>>> +                    .SetMaxResults( 1 )
>>>> +                    .UniqueResult<PersonWithGhost>();
>>>> +
>>>> +                Assert.IsNotNull( person );
>>>> +                Assert.AreEqual( default( int ), person.Number );
>>>> +                Assert.IsTrue( session.IsDirty() );
>>>> +            }
>>>> +        }
>>>> +
>>>> +        [Test]
>>>> +        public void OptionToPreventTheGenerationOfAGhost()
>>>> +        {
>>>> +            using( ISession session = OpenSession() )
>>>> +            using( ITransaction tx = session.BeginTransaction() )
>>>> +            {
>>>> +                var person = session.CreateCriteria( typeof(
>>>> PersonPreventGhost ) )
>>>> +                    .SetMaxResults( 1 )
>>>> +                    .UniqueResult<PersonPreventGhost>();
>>>> +
>>>> +                Assert.IsNotNull( person );
>>>> +                Assert.AreEqual( default( int ), person.Number );
>>>> +                Assert.IsFalse( session.IsDirty() );
>>>> +
>>>> +                /// @Fabio:
>>>> +                /// In this object the Number property should have set
>>>> +                /// an special flag which forces NHibernate to
>>>> +                /// evaluates default(int) == DBNull.Value
>>>> +                /// when it dose the IsDirty check of the Number
>>>> +                /// property.
>>>> +            }
>>>> +        }
>>>> +    }
>>>> +}
>>>> \ No newline at end of file
>>>> Index:
>>>> nhibernate/src/NHibernate.Test/NHSpecificTest/Ghosting/Mappings.hbm.xml
>>>> ===================================================================
>>>> ---
>> nhibernate/src/NHibernate.Test/NHSpecificTest/Ghosting/Mappings.hbm.xml
>>>>     (Revision 0)
>>>> +++
>> nhibernate/src/NHibernate.Test/NHSpecificTest/Ghosting/Mappings.hbm.xml
>>>>     (Revision 0)
>>>> @@ -0,0 +1,24 @@
>>>> +<?xml version="1.0" encoding="utf-8" ?>
>>>> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
>>>> +
>>>>  namespace="NHibernate.Test.NHSpecificTest.Ghosting"
>>>> +                                  assembly="NHibernate.Test">
>>>> +
>>>> +  <class name="Person">
>>>> +    <id name="Id">
>>>> +      <generator class="native" />
>>>> +    </id>
>>>> +    <property name="Number" />
>>>> +  </class>
>>>> +  <class name="PersonWithGhost" table="Person">
>>>> +    <id name="Id">
>>>> +      <generator class="native" />
>>>> +    </id>
>>>> +    <property name="Number"  />
>>>> +  </class>
>>>> +  <class name="PersonPreventGhost" table="Person">
>>>> +    <id name="Id">
>>>> +      <generator class="native" />
>>>> +    </id>
>>>> +    <property name="Number" />
>>>> +  </class>
>>>> +</hibernate-mapping>
>>>> Index: nhibernate/src/NHibernate.Test/NHSpecificTest/Ghosting/Person.cs
>>>> ===================================================================
>>>> --- nhibernate/src/NHibernate.Test/NHSpecificTest/Ghosting/Person.cs
>>>>  (Revision 0)
>>>> +++ nhibernate/src/NHibernate.Test/NHSpecificTest/Ghosting/Person.cs
>>>>  (Revision 0)
>>>> @@ -0,0 +1,22 @@
>>>> +using System.Collections.Generic;
>>>> +
>>>> +namespace NHibernate.Test.NHSpecificTest.Ghosting
>>>> +{
>>>> +    public class Person
>>>> +    {
>>>> +        private int id;
>>>> +        private int? _number;
>>>> +
>>>> +        public virtual int Id
>>>> +        {
>>>> +            get { return id; }
>>>> +            set { id = value; }
>>>> +        }
>>>> +
>>>> +        public virtual int? Number
>>>> +        {
>>>> +            get { return _number; }
>>>> +            set{ _number = value; }
>>>> +        }
>>>> +    }
>>>> +}
>>>> \ No newline at end of file
>>>> Index:
>>>>
>> nhibernate/src/NHibernate.Test/NHSpecificTest/Ghosting/PersonPreventGhost.cs
>>>> ===================================================================
>>>> ---
>>>>
>> nhibernate/src/NHibernate.Test/NHSpecificTest/Ghosting/PersonPreventGhost.cs
>>>>        (Revision 0)
>>>> +++
>>>>
>> nhibernate/src/NHibernate.Test/NHSpecificTest/Ghosting/PersonPreventGhost.cs
>>>>        (Revision 0)
>>>> @@ -0,0 +1,20 @@
>>>> +namespace NHibernate.Test.NHSpecificTest.Ghosting
>>>> +{
>>>> +    public class PersonPreventGhost
>>>> +    {
>>>> +        private int id;
>>>> +        private int _number;
>>>> +
>>>> +        public virtual int Id
>>>> +        {
>>>> +            get { return id; }
>>>> +            set { id = value; }
>>>> +        }
>>>> +
>>>> +        public virtual int Number
>>>> +        {
>>>> +            get { return _number; }
>>>> +            set { _number = value; }
>>>> +        }
>>>> +    }
>>>> +}
>>>> \ No newline at end of file
>>>> Index:
>>>>
>> nhibernate/src/NHibernate.Test/NHSpecificTest/Ghosting/PersonWithGhost.cs
>>>> ===================================================================
>>>> ---
>>>>
>> nhibernate/src/NHibernate.Test/NHSpecificTest/Ghosting/PersonWithGhost.cs
>>>> (Revision 0)
>>>> +++
>>>>
>> nhibernate/src/NHibernate.Test/NHSpecificTest/Ghosting/PersonWithGhost.cs
>>>> (Revision 0)
>>>> @@ -0,0 +1,20 @@
>>>> +namespace NHibernate.Test.NHSpecificTest.Ghosting
>>>> +{
>>>> +    public class PersonWithGhost
>>>> +    {
>>>> +        private int id;
>>>> +        private int _number;
>>>> +
>>>> +        public virtual int Id
>>>> +        {
>>>> +            get { return id; }
>>>> +            set { id = value; }
>>>> +        }
>>>> +
>>>> +        public virtual int Number
>>>> +        {
>>>> +            get { return _number; }
>>>> +            set { _number = value; }
>>>> +        }
>>>> +    }
>>>> +}
>>>> \ No newline at end of file
>>>>
>>>>
>>>
> 
> 
> 

Reply via email to