X-CGP-ClamAV-Result: CLEAN X-VirusScanner: Niversoft's CGPClamav Helper v1.22.2a (ClamAV engine v0.102.2) X-Junk-Score: 0 [] X-KAS-Score: 0 [] From: "Walter Lo Nigro" Received: from smtpcmd10101.aruba.it ([62.149.156.101] verified) by post.selbstdenker.com (CommuniGate Pro SMTP 6.3.3) with ESMTP id 26116733 for webobjects-dev@wocommunity.org; Tue, 06 Jul 2021 15:38:16 +0200 Received-SPF: none receiver=post.selbstdenker.com; client-ip=62.149.156.101; envelope-from=walter@lonigro.net Received: from mbp-di-walter.homenet.telecomitalia.it ([79.30.239.47]) by Aruba Outgoing Smtp with ESMTPA id 0lGsmX3fRfNGH0lGtmcfww; Tue, 06 Jul 2021 15:37:56 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1625578676; bh=8I+WzkdgPNqpMvv+a26uJgcu4a6Hsrs3yj8g2SbSqeA=; h=From:Content-Type:Mime-Version:Subject:Date:To; b=ZlLKNt9YC51gfnBR+TTOmuIU755nk63w3J+sqez86ln/NmfyQVEQlHb0coyKNvyfc vt9PKSOy8VLohUWnSK2xna7MdScZohZQ/VEo7WtvIhIUB4/fIY+CYjdHLxFnWh91Cd cz8sKUqS7uElPc3XEj7pESIbslL7mN7+URqKB3fc/Cy/a7IefV/kxVfosEKKR8ErGr 0hFJk/+TImVU1JaSZkqUhn4/lcnO3VBytvduf2jPHrhVIZmml4su5PVoTo3BMPnQGL hnfLtNKOOMCM9vP+zCIF/IKHzbGyL6TEs2CvzvwsusvOLaYdGccavxlI2kJgDi5dvc 1p3A8lOIlGWuQ== Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.7\)) Subject: Very stupid question re: One-to-many, single table inheritance in D2W ERModernLook Message-Id: Date: Tue, 6 Jul 2021 15:37:54 +0200 To: WebObjects & WOnder Development X-Mailer: Apple Mail (2.3445.9.7) X-CMAE-Envelope: MS4wfDDPkNhWpG2ZxBwNCbN6Qp+u+aw/XNLZLPGxSoBzItOQkfiic59fDYe3NPi3jX3PHjsE88+Q8yQOSoNUYOiY7SuMxICn/cp9x79OeDcZSHRXK5H1lAn7 vCYhyiDIZz3rQtUbJJNAfzE+lW03G/S3yn1rAhRY7kMpI3BGDMgilbgCAC6JeLprhEt0gceNnF448Ua88ZC/RxMhJtw46JAEPMc= Hi everybody, I just resolved to write to the list, obviouly risking any sort of = ominously nefast/sarcastic comments=E2=80=A6 (please be kind). I am struggling with a very simple situation, and I=E2=80=99m sure I=E2=80= =99m missing something basic. I apologize for that. I have a generic entity =E2=80=98Utente=E2=80=99, and another one = =E2=80=98Studente=E2=80=99 which inherits from the first one via = single-table inheritance.=20 I set up a further entity =E2=80=98Qualifica=E2=80=99 with just one = column =E2=80=99tipo', and I populate it with some values (just = =E2=80=9Cstudente=E2=80=9D for a start), and use it merely as a lookup = table for Utente and Studente via a One-to-many relationship: Utente.qualifica.tipo << - > Qualifica.tipo Utente has also a key =E2=80=98tipo=E2=80=99 which is the flattened = relationship between Utente and Qualifica. Obviously same for Studente, which also have a qualifier: tipo =3D = =E2=80=9Cstudente=E2=80=9D. For Studente I have added something to preset value of tipo =3D = =E2=80=9Cstudente=E2=80=9D, here is the extended class definition (which = inherits from _Studente, which of course inherits from _Utente base = class): public class Studente extends _Studente { @SuppressWarnings("unused") private static final Logger log =3D = LoggerFactory.getLogger(Studente.class); public void awakeFromInsertion(EOEditingContext eo) { super.awakeFromInsertion(eo); Qualifica qual =3D new Qualifica(); eo.insertObject(qual); qual.setTipo("studente"); this.setQualifica(qual); this.setTipo(qual.tipo()); } public static Studente createStudente(EOEditingContext = editingContext, String nome, your.app.model.Qualifica qualifica) { Studente eo =3D (Studente) = EOUtilities.createAndInsertInstance(editingContext, = _Studente.ENTITY_NAME); eo.setNome(nome); // (n.b. the only other attribute in = Utente/Studente) eo.setQualificaRelationship(qualifica); return eo; } } Everything seems ok but, when I try and create a new Studente object = (having already inserted a =E2=80=9Cstudente=E2=80=9D row into = Qualifica), I get the following error: com.webobjects.eoaccess.EOGeneralAdaptorException: EvaluateExpression = failed: : Next exception:SQL State:23505 -- error = code: 0 -- msg: ERROR: duplicate key value violates unique constraint = "qualifica_pk" Dettaglio: Key (id)=3D(4) already exists. In Properties I have: # EOF er.extensions.ERXEC.safeLocking=3Dtrue er.extensions.ERXEC.useSharedEditingContext=3Dfalse = er.extensions.ERXEnterpriseObject.applyRestrictingQualifierOnInsert=3Dfals= e er.extensions.ERXEnterpriseObject.updateInverseRelationships=3Dfalse Which is the best method to avoid the database server trying to update = BOTH sides of relationship? I am using Postgresql. Please help (and have mercy on me). Thank you. *** Walter Lo Nigro, Trieste, Italy - http://www.wln.it *** *** Choral Activities, "G. Tartini" Conservatory, Trieste *** *** Freelance conductor, RiscOS/ROOL registered developer ***