From user-return-12402-archive-asf-public=cust-asf.ponee.io@cayenne.apache.org Wed May 29 22:22:13 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 3B741180791 for ; Thu, 30 May 2019 00:22:13 +0200 (CEST) Received: (qmail 35666 invoked by uid 500); 29 May 2019 22:22:06 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 35386 invoked by uid 99); 29 May 2019 22:22:05 -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; Wed, 29 May 2019 22:22:05 +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 1B9BF1805E5 for ; Wed, 29 May 2019 22:22:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.303 X-Spam-Level: X-Spam-Status: No, score=0.303 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id KSIgT6wIFaGP for ; Wed, 29 May 2019 22:22:01 +0000 (UTC) Received: from mail-03.1984.is (mail-03.1984.is [93.95.224.70]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 7C28F60F0A for ; Wed, 29 May 2019 22:16:56 +0000 (UTC) Received: from localhost by mail-03.1984.is with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hW6sQ-0005bh-Tl for user@cayenne.apache.org; Wed, 29 May 2019 22:16:54 +0000 From: Hugi Thordarson Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: Deleting a bunch of interrelated objects Date: Wed, 29 May 2019 22:16:54 +0000 References: To: user@cayenne.apache.org In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3445.102.3) Yeah, I'll probably end up doing something like that. Although the = column name isn't always the same (data "owned" by a Customer can go = Customer ->> Invoice ->> InvoiceLine ->> InvoiceLineSums ->> etc) plain = SQL is probably the way to go here. I'll just write out them damn joins = like our ancestors did. Thanks, - hugi > On 29 May 2019, at 15:26, John Huss wrote: >=20 > If the column name is the same in all the tables it would be pretty = easy to > loop over all your entities and execute the same delete statement (via = raw > SQLExec). Put all the the entities with that column in a Set and loop = over > them, removing one when it succeeds until the set is empty. >=20 > On Wed, May 29, 2019 at 7:35 AM Hugi Thordarson = wrote: >=20 >> Hi all. >>=20 >> I have a pretty large model where every to-many relationship's delete = rule >> is "Deny" (I like being explicit about the data I delete, especially = since >> the DB in question still doesn't have well specified FKs). >>=20 >> Almost every table in this DB is somehow related to a "Customer" = table >> (sometimes through a chain of tables) that "owns" data. >> I'm now implementing an operation to nuke a Customer (as in "delete >> everything related to that customer")=E2=80=94but the data "owned" = by the customer >> is hugely interrelated, even often creating circular relations. >>=20 >> Do I have any nice options, given a set of DataObjects, to just tell >> Cayenne to nuke that darn data without any consideration for normal = delete >> rules? As in "usually I wouldn't allow this and Ashwood is very angry = at >> you=E2=80=94but since you really, really want it=E2=80=A6". >>=20 >> Note that the whole operation results in a consistent database (even = if >> there are temporary in-memory inconsistencies due to the circular >> relationships) since the interrelated data is all deleted within the >> operation. >>=20 >> Cheers, >> - Hugi