Mailing List Message #230
From: Walter Lo Nigro <>
Subject: Very stupid question re: One-to-many, single table inheritance in D2W ERModernLook
Date: Tue, 6 Jul 2021 15:37:54 +0200
To: WebObjects & WOnder Development <>
Hi everybody,

I just resolved to write to the list, obviouly risking any sort of ominously nefast/sarcastic comments… (please be kind).

I am struggling with a very simple situation, and I’m sure I’m missing something basic. I apologize for that.

I have a generic entity ‘Utente’, and another one ‘Studente’ which inherits from the first one via single-table inheritance.
I set up a further entity ‘Qualifica’ with just one column ’tipo', and I populate it with some values (just “studente” 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 ‘tipo’ which is the flattened relationship between Utente and Qualifica.
Obviously same for Studente, which also have a qualifier: tipo = “studente”.

For Studente I have added something to preset value of tipo = “studente”, here is the extended class definition (which inherits from _Studente, which of course inherits from _Utente base class):

public class Studente extends _Studente {
private static final Logger log = LoggerFactory.getLogger(Studente.class);

public void awakeFromInsertion(EOEditingContext eo) {
Qualifica qual = new Qualifica();

public static Studente createStudente(EOEditingContext editingContext, String nome, qualifica) {
Studente eo = (Studente) EOUtilities.createAndInsertInstance(editingContext, _Studente.ENTITY_NAME);
eo.setNome(nome); // (n.b. the only other attribute in Utente/Studente)
return eo;

Everything seems ok but, when I try and create a new Studente object (having already inserted a “studente” row into Qualifica), I get the following error:

com.webobjects.eoaccess.EOGeneralAdaptorException: EvaluateExpression failed: <com.webobjects.jdbcadaptor.PostgresqlExpression: "INSERT INTO Qualifica(id, tipo) VALUES (?::int4, ?::varchar(50))" withBindings: 1:4(id), 2:"studente"(tipo)>: Next exception:SQL State:23505 -- error code: 0 -- msg: ERROR: duplicate key value violates unique constraint "qualifica_pk" Dettaglio: Key (id)=(4) already exists.

In Properties I have:

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  -  ***
***  Choral Activities, "G. Tartini" Conservatory, Trieste  ***
***  Freelance conductor, RiscOS/ROOL registered developer  ***

Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to Listmaster