Can anyone please tell my why foreign keys are interpreted as plain properties when reverse-engineering with Hibernate Tools? I've found similar problem here->
https://forums.hibernate.org/viewtopic.php?f=6&t=986227 which is exactly my case, but solution posted there - including
hibernate.default_catalog in hibernate.cfg.xml doesn't work for me. I've tried all possible options of this property, the problem remains, no matter if I use custom strategy or not.
I use HT 3.2.4.GA eclipse plugin with PostgreSQL 8.3 and driver postgresql-8.3-603.jdbc4.jar. I paste my configuration files below:
hibernate.cfg.xml:
Code:
<hibernate-configuration>
<session-factory name="xx">
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.password">somepass</property>
<property name="hibernate.connection.url">jdbc:postgresql:somedb</property>
<property name="hibernate.connection.username">someuser</property>
<property name="hibernate.default_schema">main</property>
<property name="hibernate.default_catalog">pg_catalog</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<mapping class="org.Indicator" />
</session-factory>
</hibernate-configuration>
hibernate.reveng.xml:
Code:
<hibernate-reverse-engineering>
<table-filter match-name="indicator_contexts" />
<table name="indicator_contexts" >
<foreign-key constraint-name="iindicator" >
<many-to-one />
</foreign-key>
</table>
</hibernate-reverse-engineering>
and the tables:
Code:
CREATE TABLE main.iindicators
(
unique_id bigint NOT NULL,
CONSTRAINT iindicators_pkey PRIMARY KEY (unique_id)
)
WITH (OIDS=FALSE);
ALTER TABLE main.iindicators OWNER TO someuser;
Code:
CREATE TABLE main.indicator_contexts
(
unique_id bigint NOT NULL,
iindicator bigint NOT NULL,
CONSTRAINT indicator_contexts_pkey PRIMARY KEY (unique_id),
CONSTRAINT indicator_contexts_indicator_fkey FOREIGN KEY (iindicator)
REFERENCES main.iindicators (unique_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (OIDS=FALSE);
ALTER TABLE main.indicator_contexts OWNER TO someuser;