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 7A60C200BC3 for ; Fri, 18 Nov 2016 16:55:57 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 78D43160B04; Fri, 18 Nov 2016 15:55:57 +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 C07CF160B03 for ; Fri, 18 Nov 2016 16:55:56 +0100 (CET) Received: (qmail 64314 invoked by uid 500); 18 Nov 2016 15:55:52 -0000 Mailing-List: contact dev-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list dev@cayenne.apache.org Received: (qmail 62792 invoked by uid 99); 18 Nov 2016 15:55:51 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Nov 2016 15:55:51 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id F370B1A032E for ; Fri, 18 Nov 2016 15:55:50 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.379 X-Spam-Level: ** X-Spam-Status: No, score=2.379 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-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 (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id Yo4GVj6veuNA for ; Fri, 18 Nov 2016 15:55:48 +0000 (UTC) Received: from mail-qk0-f181.google.com (mail-qk0-f181.google.com [209.85.220.181]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 914BC5FACE for ; Fri, 18 Nov 2016 15:55:48 +0000 (UTC) Received: by mail-qk0-f181.google.com with SMTP id q130so268564023qke.1 for ; Fri, 18 Nov 2016 07:55:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=J+J42aW9kEVwbvukWw9uDCecaQYr1xlKuhF/B79uVeU=; b=nFhm7z8fC5x/svBnQFJHMCmrh3J1YGeFnbXwhvCoYEERgHsshtj5t7Pzaf5rAgql/Q CYA4lV/gsx1AAk4kgA2oih/xODjgOvmPOdVVXPzBmulaFys9Sl6b64DqWNrVyqiQ06+z HT+wlXfj0VGHp4v2ZLz/J21oEAtV5NqpukWlBMPwpaTHrRrOfzxWjEfAM6K3+HI06BbL 6duVG1/RznDBHFmNMordljnQZURs0Oqf+FRReaVCaf4lEEg6QX/mLXzrZxU2yuUzuzgq s14HXc8xVQ5Q6viM/H9m9TDlqrgg7WEjXFRiR6oO954LvD6bvosf1RLx0H+9cJaFdaYh ErQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=J+J42aW9kEVwbvukWw9uDCecaQYr1xlKuhF/B79uVeU=; b=BOutRykJXex6IwKANh0P3iCJtS26/TfJZ+5jTw8jzXuWYfMecdT9o+3OfhnBozpy/2 LNLY8zhZCwnNWDUom/TH5bITFgrbss1lmn7urLhLFrMYZCoIDY/elT7Jc/JIcXifHu6P HOfG2JTU/baR47fta9Yav5ksNKXMq51Rnd01ZE9Mi3bAJq0aFQAjw/vUnJ5pagT5zZBY OnVrPl0YxbDkpKdfuVrVZU6euxyje/fvRjqzeQEgEU4AANC3YjzoWOOCAeep+iMvaUfm 5zK7tUk/fFuhwgqhY1IWJE+LuGj0WZHCN8TXWs9wEDfYn16WngHGkIoeayq7H364giVv tH8Q== X-Gm-Message-State: AKaTC00XurTpVXPR5WzjeBJ5ZGdr24S3hOcK9h1iJJiZev15z3LuCtiJAjOKP2z8zeA5GUGXlE3oWvcLlzQ+Nw== X-Received: by 10.233.223.196 with SMTP id t187mr479460qkf.135.1479484547060; Fri, 18 Nov 2016 07:55:47 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: John Huss Date: Fri, 18 Nov 2016 15:55:36 +0000 Message-ID: Subject: Re: Switch DbEntity schema at runtime To: dev@cayenne.apache.org Content-Type: multipart/alternative; boundary=94eb2c043ebae0d9e505419556af archived-at: Fri, 18 Nov 2016 15:55:57 -0000 --94eb2c043ebae0d9e505419556af Content-Type: text/plain; charset=UTF-8 The DataMap (model) is shared by the contexts. To make them different you need to create two different ServerRuntimes. On Fri, Nov 18, 2016 at 3:44 AM Markus Reich wrote: > Hi, > > I have a very special requirement :-) > We need to change the schema after logon (it's a JSF Tomcat WebApp) > > I tried the following > > After login > > final String SESSION_CONTEXT_KEY = > SessionContextRequestHandler.class.getName() + ".SESSION_CONTEXT"; > ObjectContext context = (ObjectContext) > session.getAttribute(SESSION_CONTEXT_KEY); > for (DbEntity dbEntity : context.getEntityResolver().getDbEntities()) { > if (dbEntity.getSchema().endsWith("crm")) { > if(Helper.getCrm()!=null) dbEntity.setSchema(Helper.getCrm()); > } else if (dbEntity.getSchema().startsWith("simpleinv_")) { > if(Helper.getEupar()!=null) dbEntity.setSchema("simpleinv_" + > Helper.getEupar()); > } > } > session.setAttribute(SESSION_CONTEXT_KEY, context); > > The switching works, until a second session is opened! The first session > loses the schema and get the one from the second? > > When I debug I have two different instances of the ObjectContext that's > perfect, but the DbEntities are the same :-/ > > regards > Meex > --94eb2c043ebae0d9e505419556af--