-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Reverse engineering skips foreign keys for PostgreSQL
PostPosted: Thu Jul 30, 2009 6:57 am 
Newbie

Joined: Tue Oct 21, 2008 4:32 am
Posts: 3
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;


Top
 Profile  
 
 Post subject: Re: Reverse engineering skips foreign keys for PostgreSQL
PostPosted: Sat Aug 01, 2009 6:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
sounds like the jdbc driver is not reporting the right data back about foreign keys - tried a newer driver?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Reverse engineering skips foreign keys for PostgreSQL
PostPosted: Sun Aug 02, 2009 4:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I am not sure what is wrong with your settings as we use PostgreSQL as one of our primary databases and this issue has not come up for me. Are the values you are using valid?
Sometimes the hardest part is the JDBC driver settings.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.