Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion What's the recommended approach when an Aggregate Root changes?

Received: by 10.42.89.20 with SMTP id e20mr12762146icm.3.1335262677208;
        Tue, 24 Apr 2012 03:17:57 -0700 (PDT)
X-BeenThere: ravendb@googlegroups.com
Received: by 10.231.80.134 with SMTP id t6ls10415126ibk.8.gmail; Tue, 24 Apr
 2012 03:17:54 -0700 (PDT)
Received: by 10.42.151.132 with SMTP id e4mr7300164icw.2.1335262674710;
        Tue, 24 Apr 2012 03:17:54 -0700 (PDT)
Received: by 10.42.151.132 with SMTP id e4mr7300163icw.2.1335262674698;
        Tue, 24 Apr 2012 03:17:54 -0700 (PDT)
Return-Path: <ryan.q.he...@gmail.com>
Received: from mail-iy0-f178.google.com (mail-iy0-f178.google.com [209.85.210.178])
        by gmr-mx.google.com with ESMTPS id dd7si6620224igc.0.2012.04.24.03.17.54
        (version=TLSv1/SSLv3 cipher=OTHER);
        Tue, 24 Apr 2012 03:17:54 -0700 (PDT)
Received-SPF: pass (google.com: domain of ryan.q.he...@gmail.com designates 209.85.210.178 as permitted sender) client-ip=209.85.210.178;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ryan.q.he...@gmail.com designates 209.85.210.178 as permitted sender) smtp.mail=ryan.q.he...@gmail.com; dkim=pass header...@gmail.com
Received: by iakl21 with SMTP id l21so886515iak.9
        for <ravendb@googlegroups.com>; Tue, 24 Apr 2012 03:17:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :content-type:content-transfer-encoding;
        bh=hh6zyrB8Igv7V6R8E2L0u8FFRqqFst06YGUabuo03OI=;
        b=FDYuNAFGEdfQa1bJKN8L5M2cTZ/r+yMFiYBa0aZs/LxHKRJy/OvyAxbxWTtk7+vGdL
         RtaLt0RG0qDbAdIZ0N+MBRRrZQARYRATIkyL2U5lAlAsKoMx3rRvyjpj7FTOA93s7ybk
         TGmrZrYgHpx5YDBVRhrw4jLn2f3axkfvTVTgIaUDzc1giE1rxx24HnX2K+Vgk+or1B0q
         V4FuydV5oMgE2Nb/8aTJqyUJiue1OWFTGjgAPRRndGr/rcnFmO2jm0Xcw0kvK/anKEIz
         HD3jvJqcAHv/CuL2WSYXa+5gvyarEFBbTYmkQdX7pgz9HKI7qylRrccDP5RVPwKBR9rw
         /cCw==
MIME-Version: 1.0
Received: by 10.50.179.104 with SMTP id df8mr9323791igc.11.1335262674484; Tue,
 24 Apr 2012 03:17:54 -0700 (PDT)
Received: by 10.231.162.21 with HTTP; Tue, 24 Apr 2012 03:17:54 -0700 (PDT)
In-Reply-To: <CAF0G-Zhx4BvbXhzgV-yKwXNrkWzzvrDTu7ZartiJ4ePm_xP...@mail.gmail.com>
References: <19040409.15.1335212785398.JavaMail.geo-discussion-forums@ynbh26>
	<CALfNUtXjSU=9CovE0URTGMNoiuCK6dkwPtX0hGYAf_wTLzk...@mail.gmail.com>
	<9070261.83.1335219345391.JavaMail.geo-discussion-forums@vbmi19>
	<CABcSOXhTcrSaWV9kb9gcJ2rh7W6YjcDFB_Z8TSLSPPmS_=X...@mail.gmail.com>
	<CAF0G-ZgCU=70gLcgmukRS3RQR73qm69cbsRxSWV+KnGoMN7...@mail.gmail.com>
	<CABcSOXimovHnAbLHhVOtDELyJiof+RgWXSwzgWWUmZ4DFpC...@mail.gmail.com>
	<CAF0G-Zg131xHtSZCEFZY9Qkcgy0rnewFsqxN6k3g_6ukzLu...@mail.gmail.com>
	<CABcSOXhpGLK2NBFZeGd85jOUr-i1ygSoRHZijC9gmYtHo8v...@mail.gmail.com>
	<CAF0G-Zhx4BvbXhzgV-yKwXNrkWzzvrDTu7ZartiJ4ePm_xP...@mail.gmail.com>
Date: Tue, 24 Apr 2012 12:17:54 +0200
Message-ID: <CABcSOXiA_HuMQ4YR+Hn7OtdMG0+ueonNMuvd+zRO=GWDZ7u...@mail.gmail.com>
Subject: Re: [RavenDB] What's the recommended approach when an Aggregate Root changes?
From: Ryan Heath <ryan.q.he...@gmail.com>
To: ravendb@googlegroups.com
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Ah, learning something new each day :)
I was pretty sure serialization was not calling the ctor, but I did
not think about the other serialization types.

It feels troublesome they don't behave alike ...

// Ryan

On Tue, Apr 24, 2012 at 11:54 AM, Oren Eini (Ayende Rahien)
<aye...@ayende.com> wrote:
> That is because you are using binary serialization. Json serialization an=
d
> just about anything else calls the ctor.
>
>
> On Tue, Apr 24, 2012 at 12:44 PM, Ryan Heath <ryan.q.he...@gmail.com> wro=
te:
>>
>> Hmm,
>>
>> This test fails:
>>
>> [Serializable]
>> =A0 =A0public class Class1
>> =A0 =A0{
>> =A0 =A0 =A0 =A0[NonSerialized]
>> =A0 =A0 =A0 =A0public int nonSerialized;
>>
>> =A0 =A0 =A0 =A0public Class1()
>> =A0 =A0 =A0 =A0{
>> =A0 =A0 =A0 =A0 =A0 =A0nonSerialized =3D 42;
>> =A0 =A0 =A0 =A0}
>> =A0 =A0}
>>
>> =A0 =A0[TestFixture]
>> =A0 =A0public class Test
>> =A0 =A0{
>> =A0 =A0 =A0 =A0[Test]
>> =A0 =A0 =A0 =A0public void TestCtor()
>> =A0 =A0 =A0 =A0{
>> =A0 =A0 =A0 =A0 =A0 =A0var myObject =3D new Class1();
>> =A0 =A0 =A0 =A0 =A0 =A0var formatter =3D new BinaryFormatter();
>>
>> =A0 =A0 =A0 =A0 =A0 =A0var mem =3D new MemoryStream();
>> =A0 =A0 =A0 =A0 =A0 =A0formatter.Serialize(mem, myObject);
>> =A0 =A0 =A0 =A0 =A0 =A0mem.Position =3D 0;
>> =A0 =A0 =A0 =A0 =A0 =A0var newObject =3D (Class1)formatter.Deserialize(m=
em);
>>
>> =A0 =A0 =A0 =A0 =A0 =A0Assert.That(newObject.nonSerialized, Is.EqualTo(4=
2));
>> =A0 =A0 =A0 =A0}
>> =A0 =A0}
>>
>> Which serialization do you use?
>>
>> // Ryan
>>
>> On Tue, Apr 24, 2012 at 11:34 AM, Oren Eini (Ayende Rahien)
>> <aye...@ayende.com> wrote:
>> > Yes, it does.
>> > Unless you call UnsafeCreateObject ( or something like that)
>> >
>> >
>> > On Tue, Apr 24, 2012 at 12:30 PM, Ryan Heath <ryan.q.he...@gmail.com>
>> > wrote:
>> >>
>> >> Do you (Raven) call it yourself? The .net infrastructure does not.
>> >>
>> >> // Ryan
>> >>
>> >> On Tue, Apr 24, 2012 at 11:28 AM, Oren Eini (Ayende Rahien)
>> >> <aye...@ayende.com> wrote:
>> >> > Actually, the ctor IS invoked
>> >> >
>> >> >
>> >> > On Tue, Apr 24, 2012 at 12:27 PM, Ryan Heath <ryan.q.he...@gmail.co=
m>
>> >> > wrote:
>> >> >>
>> >> >> What you see here, is that c'tors are not invoked during
>> >> >> deserializing.
>> >> >> Your enum property was just initialized with value 0, which is the
>> >> >> value or your first enum value.
>> >> >>
>> >> >> // Ryan
>> >> >>
>> >> >> On Tue, Apr 24, 2012 at 12:15 AM, Stijn Volders (ONE75)
>> >> >> <stijn.vold...@gmail.com> wrote:
>> >> >> > thanks. That would work I guess.
>> >> >> >
>> >> >> > Normally, I would add a parameter "priority" to the ctor and
>> >> >> > assign
>> >> >> > the
>> >> >> > value of the parameter to my property, so I don't need the
>> >> >> > "default"
>> >> >> > value
>> >> >> > in my code. Only the current documents in the database violate m=
y
>> >> >> > invariant.
>> >> >> >
>> >> >> > I just did some tests. Apparently the values of my ctor paramete=
rs
>> >> >> > are
>> >> >> > defaulted when the document is deserialized. I've tried it with =
an
>> >> >> > enum
>> >> >> > and
>> >> >> > the first value of my enum was used if there is nothing in my
>> >> >> > document
>> >> >> > (not
>> >> >> > a null value, the property itself is also not in the document)
>> >> >> >
>> >> >> > that's kind of tricky behavior, no?
>> >> >> >
>> >> >> >
>> >> >> > On Monday, April 23, 2012 10:27:45 PM UTC+2, Itamar Syn-Hershko
>> >> >> > wrote:
>> >> >> >>
>> >> >> >> You just add the property and set the default value in the obje=
ct
>> >> >> >> ctor,
>> >> >> >> like you will normally do
>> >> >> >>
>> >> >> >> It will just work from there.
>> >> >> >>
>> >> >> >> On Mon, Apr 23, 2012 at 11:26 PM, Stijn Volders (ONE75)
>> >> >> >> <stijn.vold...@gmail.com> wrote:
>> >> >> >>>
>> >> >> >>> Hi,
>> >> >> >>>
>> >> >> >>> Let's say I want to add a property to my "BacklogItem" class:
>> >> >> >>>
>> >> >> >>> public Priority Priority {get;set;}
>> >> >> >>>
>> >> >> >>> with a default value "Priority.High" (as always...)
>> >> >> >>>
>> >> >> >>> When dealing with a RDMS, I would create the column with a
>> >> >> >>> default
>> >> >> >>> value
>> >> >> >>> and i'm ready to go. How do I update the documents in my
>> >> >> >>> database
>> >> >> >>> with
>> >> >> >>> RavenDB? I couldn't find info on the site about that, but mayb=
e
>> >> >> >>> I'm
>> >> >> >>> looking
>> >> >> >>> with the wrong keywords (document change or migration yielded
>> >> >> >>> other
>> >> >> >>> results)
>> >> >> >>>
>> >> >> >>> Thanks
>> >> >> >>>
>> >> >> >>> Stijn
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >
>> >> >
>> >
>> >
>
>