On 7 January 2014 11:44, <[email protected]> wrote:
>
> Please find below the legacy table schema definition:
>
> CREATE TABLE om_site
> (
> site_id character varying(80) NOT NULL,
> org_id character varying(18) NOT NULL,
> site_name character varying(45),
> site_desc character varying(60),
> site_type character varying(45) NOT NULL, -- Type of the site. Can be
> CAMPUS or BUILDING
> address_id character varying(10),
> location_id character varying(80),
> change_by character varying(60) NOT NULL DEFAULT
> 'System/Admin'::character varying,
> change_dt timestamp without time zone NOT NULL,
> CONSTRAINT om_site_pk PRIMARY KEY (site_id, org_id),
> CONSTRAINT om_site_address_id FOREIGN KEY (address_id, org_id)
> REFERENCES om_address (address_id, org_id) MATCH SIMPLE
> ON UPDATE NO ACTION ON DELETE NO ACTION,
> CONSTRAINT om_site_factility_org_fk FOREIGN KEY (location_id, org_id)
> REFERENCES om_geo_location (location_id, org_id) MATCH SIMPLE
> ON UPDATE NO ACTION ON DELETE NO ACTION
> )
> I have to get this schema in synch with JDO entity mapping.
>
>
> Note: The DDL is legacy one, so it could not be changed.
>
>
Just a side note on this... one option may be to create views over the top
of your legacy schema, and then map Isis/JDO to that instead. For example,
if the issue turns out that JDO really won't let you map org_id three times
(as a component of the PK and also as a component of the two FKs), then a
view on top of this could "export" org_id for the other maps
eg:
create view isis_om_site as
select *, org_id as addr_org_id, org_id as loc_org_id
from om_site
then map the Address FK to addr_org_id "column", and Location FK similarly
to loc_org_id
You can then use INSTEAD OF triggers to go the other way (assuming you are
using a half-decent database here).
In fact, I suggest that this is good practice for all tables whenever
integrating into any legacy database. (It might even be good practice for
every app, legacy schema or not. Having a view layer provides a useful
abstraction layer for systems where there is more than one client of the
database.
> This is a valid scenario at RDBMS side
>
> This kind of mapping works with JPA where in same column can be used as
> for the fields above. I tested its working fine(JPA/Hibernate out of ISIS
> environment)
>
>
>
Have you also tested it with JDO (outside of Isis environment)? It'd be
good to know if its JDO that can't handle this, or if it is Isis.
Dan