Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1E7D3200C6E for ; Mon, 8 May 2017 16:35:23 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1D00E160BA5; Mon, 8 May 2017 14:35:23 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3C9D3160B99 for ; Mon, 8 May 2017 16:35:22 +0200 (CEST) Received: (qmail 84207 invoked by uid 500); 8 May 2017 14:35:21 -0000 Mailing-List: contact dev-help@polygene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@polygene.apache.org Delivered-To: mailing list dev@polygene.apache.org Received: (qmail 84194 invoked by uid 99); 8 May 2017 14:35:21 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 May 2017 14:35:21 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id C76B1180535 for ; Mon, 8 May 2017 14:35:20 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.296 X-Spam-Level: X-Spam-Status: No, score=-0.296 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-2.796, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id A_jZW37-CH2K for ; Mon, 8 May 2017 14:35:18 +0000 (UTC) Received: from mail-wr0-f178.google.com (mail-wr0-f178.google.com [209.85.128.178]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 56DC15FBBB for ; Mon, 8 May 2017 14:35:18 +0000 (UTC) Received: by mail-wr0-f178.google.com with SMTP id w50so45794206wrc.0 for ; Mon, 08 May 2017 07:35:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to; bh=kcRI8sTtet21DRav1vgT2VyVqm1M/0sTZl5KBIAhvYg=; b=jUowxiCoGPY6vet6J879MhRxYQZf4v+4M/b8JAKuNf9atLq7FOvCCn5vTfurCe1Rc4 xEJhIqySJPtsJtQIvU16twilWWRj/XJhPb9mnNt4uw+UJfhoGA67SAtHYRnIlBYIRIiC 8EUnRK7ticR6IFLbiU4DO3aHvXppG7H8tMesrd70O5lbZPQI1ymG5wq9Pudl/kx1dQL7 IV7xKxc3LdFzY2ldDl4lihTQJvTVA4gwL1KKrafOElRj6w7W1yBsj7O6giyNX7Hcg8M1 o79D/N2NDfd/P9YG7GkK+LEBkVxPzfCRV+fa6IrDSl8YmSdr9VCbAhJLo5YQiLxPYr5q A0IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to; bh=kcRI8sTtet21DRav1vgT2VyVqm1M/0sTZl5KBIAhvYg=; b=e5+wtafV3sGVgQaqFW6jLbhci3PVaKjv0Hj03xJ2z4BVjSY2W0KHvj+ABoXCWYkKre 5Jp1BA8S88dAwFic14AAUj0QVhT2rvlEuRv643ianPLnWnPWTIoxDGdmuKEpERX+pFxe HgujEBp6zmgTw1V8uwOb+PfRn59eBYqJpdOcMBrJui+IiHAnZA5yS9NjSJ5X/uJn+si6 IPjw6HUVt4WaiDkRk+0Ad/JrPu0aFtknvd0ubikW2knJZZtQzfpcHfS/E6iCGA0a0YDa xiiTCU7W2BPpA3+WK7m3EAIP8ZDwYOXP+YSu6moRdI0SJ+OcSF0uHxBFUKALiwEfUjlP YwHA== X-Gm-Message-State: AODbwcBKsOZVwBpxJ4uUEwqaX1RIF1KL6T9kR4GQjX/XanaUE/yOGQiS x+ys7jRvGfHKn8zlbntOPIqukCH6Ng== X-Received: by 10.46.32.154 with SMTP id g26mr6382620lji.51.1494254110431; Mon, 08 May 2017 07:35:10 -0700 (PDT) MIME-Version: 1.0 Sender: hedhman@gmail.com Received: by 10.46.83.28 with HTTP; Mon, 8 May 2017 07:34:50 -0700 (PDT) In-Reply-To: <59104647.1010206@apache.org> References: <59104647.1010206@apache.org> From: Niclas Hedhman Date: Mon, 8 May 2017 22:34:50 +0800 X-Google-Sender-Auth: 8AUmGUDuVbq4MwAyEyStKQNKkcM Message-ID: Subject: Re: SPI issue? To: dev@polygene.apache.org Content-Type: multipart/alternative; boundary=001a1143062a74e24a054f04251d archived-at: Mon, 08 May 2017 14:35:23 -0000 --001a1143062a74e24a054f04251d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Yeah, you kind of got to the same conclusion as I did... i.e. not sure what to do. If we add the EntityDescriptor, there should be some semantics on what it means, not arbitrarily from ES to ES. I think we just keep it as it is. On Mon, May 8, 2017 at 6:19 PM, Paul Merlin wrote: > Hey Niclas, > > Niclas Hedhman a =C3=A9crit : > > Peddling with this JOOQ ES (or whatever it ends up being called), I fou= nd > > an inconsistency in the EntityStore SPI. > > > > > > public interface EntityStoreUnitOfWork > > { > > EntityState newEntityState( EntityReference anIdentity, > > EntityDescriptor entityDescriptor ) > > throws EntityStoreException; > > > > EntityState entityStateOf( ModuleDescriptor module, > > EntityReference anIdentity ) > > throws EntityStoreException, EntityNotFoundException; > > > > String versionOf( EntityReference anIdentity ) throws > EntityStoreException; > > > > } > > > > > > It is not consistent to pass the EntityDescriptor in newEntityState() b= ut > > not in entityStateOf(). In the latter case, it is expected that the > > EntityStore have saved away the type, and able to look it up from the > > Module, when the caller already have the EntityDescriptor readily > available. > > > > Can anyone think of a case where it is not better to pass the > > EntityDescriptor from the caller? > > > > It might be related to looking up via a super type, and if then saving, > > then there is a chance that the "old fields" are no long present. And t= o > > avoid that, push the whole "what is the lowest subclass of this identit= y" > > to the entitystore. > > > > I think my question is, what is the proper semantics around entity > > subclasses? Is it really the "saved type" that is the deserialized type= , > or > > is it the "requested type" that should be the deserialized type? > > > > I am not sure either way, and would like to hear more arguments one way > or > > the other. > > Yeah, agreed that it doesn't feel consistent at first sight. > > BUT, > When creating an entity we don't have anything else than its > EntityDescriptor. > When saving the entity its `type` is set to the main type of its > EntityDescriptor. > Then, when fetching an entity the ES will load the whole state and use > the stored `type` to lookup the corresponding EntityDescriptor, and fail > with a NoSuchEntityTypeException if not found. > > As you wrote, this means that you can fetch an Entity using a super > type, the loaded state will however contain all the data described by > the EntityDescriptor used on creation. API-wise you'll only be able to > mutate the entity using the "requested type" but under the hood, the > whole state is kept. > > I think it makes sense. Especially when thinking about key/value backed > EntityStores where the whole state is a "blob". > > If we change that SPI so that `entityStateOf(..)` takes an > EntityDescriptor then it would mean that EntityStores could have the > opportunity to only load a "view" of the entity and have to handle > supplementary fields non destructively. As I see it adds a feature to > the SPI and a new responsibility for EntityStores. > > Key/Value stores could then still do as they do today, possibly > validating that the saved EntityDescriptor types include all of the > requested EntityDescriptor types. Or some sort of validation. It's an > extra responsibility for the EntityStores. > > More evolved EntityStores could then only load "views" of entities, not > the whole saved state. But they also should be able to update state non > destructively. > > I'd say it's a tradeoff between capabilities and implicit > responsibilities for implementations. I'm not against adding the feature > to the SPI but then we should at least properly document it so > asumptions are crystal clear. > > Does that help? > > Cheers > > /Paul > > > --=20 Niclas Hedhman, Software Developer http://polygene.apache.org - New Energy for Java --001a1143062a74e24a054f04251d--