From: Egon W. <ego...@gm...> - 2009-07-03 06:34:21
|
Hi Steffen, sorry, missed this email... almost back to zero in my inbox, and still discovering new emails :) On Fri, Jun 12, 2009 at 10:35 PM, Steffen Neumann<sne...@ip...> wrote: > we currently have the problem > that the recently introduced foreign key constraints > cause SQL exceptions if you try to save a Bean which > as no / a non-existing reference: Yes, I noted this too by now, with that in memory database... > org.postgresql.util.PSQLException: > ERROR: insert or update on table "metchar_putative_metabolites_identities" > violates foreign key constraint "metchar_putative_metabolites_identitie_metobserv_output_id_fkey" > Detail: Key (metobserv_output_id)=(67) is not present in table "metobserv_output". Yeah, the 'problem' is that explicit foreign keys requires all beans to be constructed... that is, you cannot do a partial construct of a data structure, and have to give beans for all links you make... actually, this would not be so bad... > I currently see two alternative solutions: > > 1) Revert the foreign key constraints, such that > (possibly inconsistent) data can enter the DB, > hoping that some following INSERTs fix that. Yes, that's sort of the current behavior... > 2) Enforce the correct ordering of Beans, > and either catch the SQLException, > or verify via our exists() that the referenced entity is there. This equals fixing the unit tests? What do you mean with 'correct ordering of Beans' ? Egon -- Post-doc @ Uppsala University http://chem-bla-ics.blogspot.com/ |