[geotk] Using metadata.sql
Martin Desruisseaux
martin.desruisseaux at geomatys.fr
Thu Apr 5 09:03:12 EDT 2012
Hello William
Le 05/04/12 10:15, William Temperley a écrit :
> I'm loading a file (see http://pastebin.com/FvpDw3Kt) into a
> DefaultMetadata object (which works great, thanks!) but when I attempt
> to persist it using MetadataWriter.add(defaultMetaData), I get the
> following error:
>
> org.postgresql.util.PSQLException: ERROR: insert or update on table
> "EX_Extent" violates foreign key constraint
> "EX_Extent_geographicElement_fkey"
> Detail: Key (geographicElement)=(FD10C2) is not present in table
This is caused by PostgreSQL not yet inheriting index in table inheritance.
MetadataWriter creates a "EX_GeographicBoundingBox" table which inherit
(extends) the "EX_GeographicExtent" table. The data are inserted into the
"EX_GeographicBoundingBox" table, then a foreigner key constraint is created
from an other table to "EX_GeographicExtent", which is the parent of the table
where we just inserted data. In a pure object-oriented model, the foreigner key
constraint would apply on the union of the parent table and all its children.
However this is not yet implemented in PostgreSQL 9.1 (see the "Caveats" section
at the bottom of http://www.postgresql.org/docs/9.1/static/ddl-inherit.html).
MetadataWriter was already designed to workaround this issue by omitting
foreigner key constraints when it detected table inheritance. However in this
particular case it failed to detect. I'm investigating why and should commit a
fix soon.
Of course, if someone could sponsor PostgreSQL developers, the ideal fix would
be to get index inheritance implemented in PostgreSQL :-).
Regards,
Martin
More information about the Geotoolkit
mailing list