Hi all,
I'm using hbm2java task (ibernate-tools 4.0.0-CR1) to generate the java pojos from a postgres db.
Code:
DROP TABLE IF EXISTS CO_ASGMT_WRKR_EV CASCADE;
DROP TABLE IF EXISTS CO_EV_RTL_STR_LCN CASCADE;
DROP TABLE IF EXISTS CO_EV_SCH CASCADE;
DROP TABLE IF EXISTS PA_STR_RTL CASCADE;
CREATE TABLE CO_ASGMT_WRKR_EV
(
ID_STR_RTL CHAR(32) NOT NULL,
ID_EV INTEGER NOT NULL,
ID_WRKR INTEGER NOT NULL
);
ALTER TABLE CO_ASGMT_WRKR_EV
ADD PRIMARY KEY (ID_EV,ID_STR_RTL,ID_WRKR);
CREATE TABLE CO_EV_RTL_STR_LCN
(
ID_STR_RTL CHAR(32) NOT NULL,
ID_EV INTEGER NOT NULL
);
ALTER TABLE CO_EV_RTL_STR_LCN
ADD PRIMARY KEY (ID_EV,ID_STR_RTL);
CREATE TABLE CO_EV_SCH
(
ID_EV INTEGER NOT NULL,
TY_EV CHAR(4) NULL,
TS_EV_PL_EF TIMESTAMP NULL,
TS_EV_PL_EP TIMESTAMP NULL,
NM_EV VARCHAR(40) NULL,
DE_INSTR TEXT NULL,
CC_EV CHAR(2) NULL,
NM_EV_OWNR VARCHAR(40) NULL
);
ALTER TABLE CO_EV_SCH
ADD PRIMARY KEY (ID_EV);
CREATE TABLE PA_STR_RTL
(
ID_STR_RTL CHAR(32) NOT NULL,
DC_OPN_RT_STR TIMESTAMP NULL,
DC_CL_RT_STR TIMESTAMP NULL,
QU_SZ_STR DECIMAL(9,2) NOT NULL DEFAULT 0,
QU_SZ_AR_SL DECIMAL(9,2) NOT NULL DEFAULT 0
);
ALTER TABLE PA_STR_RTL
ADD PRIMARY KEY (ID_STR_RTL);
ALTER TABLE CO_ASGMT_WRKR_EV
ADD CONSTRAINT is_assigned_to_8 FOREIGN KEY (ID_EV, ID_STR_RTL) REFERENCES CO_EV_RTL_STR_LCN (ID_EV, ID_STR_RTL);
ALTER TABLE CO_EV_RTL_STR_LCN
ADD CONSTRAINT is_location_for FOREIGN KEY (ID_STR_RTL) REFERENCES PA_STR_RTL (ID_STR_RTL);
ALTER TABLE CO_EV_RTL_STR_LCN
ADD CONSTRAINT may_effect FOREIGN KEY (ID_EV) REFERENCES CO_EV_SCH (ID_EV);
But, I'm getting the following exception:
Code:
[hibernatetool] Executing Hibernate Tool with a JDBC Configuration (for reverse engineering)
[hibernatetool] 1. task: hbm2java (Generates a set of .java files)
[hibernatetool] An exception occurred while running exporter #2:hbm2java (Generates a set of .java files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.MappingException: An association from the table co_asgmt_wrkr_ev refers to an unmapped class: model.arts.v6_0_0.CoEvRtlStrLcn
I don't understand why if I remove from the sql one of the constraints for the table CO_EV_RTL_STR_LCN the hbm2java runs with no issues.
Code:
ALTER TABLE CO_EV_RTL_STR_LCN
ADD CONSTRAINT is_location_for FOREIGN KEY (ID_STR_RTL) REFERENCES PA_STR_RTL (ID_STR_RTL);
or
Code:
ALTER TABLE CO_EV_RTL_STR_LCN
ADD CONSTRAINT may_effect FOREIGN KEY (ID_EV) REFERENCES CO_EV_SCH (ID_EV);
Can somebody shed light on this? How to fix it?
Thanks and regards,
James