-->
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.  [ 12 posts ] 
Author Message
 Post subject: Exception with config, but i don't know why !
PostPosted: Mon Mar 21, 2005 4:01 pm 
Newbie

Joined: Mon Mar 21, 2005 3:49 pm
Posts: 5
i've read about the automatic generation of class and map files and i've tried it with
eclipse. but i got and error and i don't know why.

when i start the artifact generation i get the follow:

>>> org.hibernate.cfg.JDBCBinderException: Foreign key name mapped to different tables! <<<

my database is the following:

create sequence users_index_seq minvalue 1 cycle;

create table users (
userid INTEGER NOT NULL DEFAULT
NEXTVAL('users_index_seq'),
dw VARCHAR(4) NOT NULL,
pin VARCHAR(10) NOT NULL,
name VARCHAR(30) NOT NULL,
pic BYTEA NOT NULL,
stateindex INT8 NOT NULL DEFAULT(0),
lastaction TIMESTAMP NOT NULL DEFAULT
now(),
date TIMESTAMP NOT NULL DEFAULT
now(),
PRIMARY KEY (userid)
);

create table logged (
index INT8 NOT NULL,
userid INTEGER NOT NULL,
state INTEGER NOT NULL DEFAULT(1),
came TIMESTAMP NOT NULL,
gone TIMESTAMP,
exported BOOLEAN NOT NULL DEFAULT('false'),
inworktab BOOLEAN NOT NULL DEFAULT('false'),

PRIMARY KEY (index, userid),
FOREIGN KEY (userid) REFERENCES users(userid)
);


create table workLogs (
index INT8 NOT NULL,
loggedid INT8 NOT NULL,
userid INTEGER NOT NULL,
state INTEGER NOT NULL DEFAULT(1),
came TIMESTAMP NOT NULL,
gone TIMESTAMP,
typ INTEGER NOT NULL DEFAULT(1),
comment TEXT NOT NULL DEFAULT(''),

PRIMARY KEY (index, userid),
FOREIGN KEY (userid) REFERENCES users(userid),
FOREIGN KEY (typ) REFERENCES typ(index)
);




the error only comes when i create the workLogs table with the foreign-key to the users table.

here my question: Why may i not have two foreign keys to on table !?!?!?!?!?




Hibernate version: 3 rc1

Mapping documents:

Full stack trace of any exception that occurs:

Name and version of the database you are using: postgres 7.4.2

The generated SQL (show_sql=true): no sql output

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 21, 2005 5:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you dont show any mapping generated so that would help ,)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 21, 2005 6:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
oh sorry misread you posting.

sounds like a bug yes. please post it in jira with DDL and db/driver name.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 6:38 am 
Newbie

Joined: Mon Mar 21, 2005 3:49 pm
Posts: 5
my ddl:

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.url">jdbc:postgresql://pc54/edzeit</property>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.connection.username">ml</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<mapping resource="Worklogs.hbm.xml"/>
<mapping resource="Typ.hbm.xml"/>
<mapping resource="Logged.hbm.xml"/>
<mapping resource="Users.hbm.xml"/>
</session-factory>
</hibernate-configuration>


the ddl is autogenerated by eclipse by a hibernate tool plugin too.



i've tried it with two versions of the postgres jdbc driver:
pg74.215.jdbc3.jar and pg80jdbc3.jar

the same error with both drivers.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 6:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
that is not DDL / that is your hibernate.cfg.xml.

i would like if you could put the SQL DDL into a jira issue and write what you do to get to the error - including a full stack trace.

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 6:52 am 
Newbie

Joined: Mon Mar 21, 2005 3:49 pm
Posts: 5
max wrote:
that is not DDL / that is your hibernate.cfg.xml.

i would like if you could put the SQL DDL into a jira issue and write what you do to get to the error - including a full stack trace.
/max



sorry, but i'm a new user of hibernate.
so, could you explain what you mean with "sql ddl" and where can i find the jira - forum


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 7:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
DDL = Data Definition Language.

The language you use when you write "create table ..." etc.

Jira is available from our frontpage: http://www.hibernate.org/217.html

...and please next time try to use google or any other search engine that could answer these two questions faster than me ,)

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Same problem here
PostPosted: Thu Mar 02, 2006 12:24 am 
Regular
Regular

Joined: Sat Jan 07, 2006 8:30 pm
Posts: 68
I'm using the latest hibernate tools, hibernate 3.1, postgresql 8.0.3 and latest driver pg74.214.jdbc3.jar if not mistaken and get the classes and mapping files generate but the relationship from fk are not there. The warning in eclipse console is

WARN Worker-5 org.hibernate.cfg.JDBCBinder - Exception while reading foreign keys for org.hibernate.mapping.Table(public.category) [org.hibernate.exception.GenericJDBCException: Error while reading exported keys meta data for public.category]

The exception is
org.hibernate.exception.GenericJDBCException: Error while reading exported keys meta data for public.category
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
at org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect$5.handleSQLException(JDBCMetaDataDialect.java:282)
at org.hibernate.cfg.reveng.dialect.ResultSetIterator.next(ResultSetIterator.java:50)
at org.hibernate.cfg.reveng.JDBCReader.processForeignKeys(JDBCReader.java:114)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:80)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:691)
at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:113)
at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:85)
at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:40)
at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate$2.execute(CodeGenerationLaunchDelegate.java:244)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:35)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:68)
at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.buildConfiguration(CodeGenerationLaunchDelegate.java:241)
at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.doFinish(CodeGenerationLaunchDelegate.java:125)
at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.launch(CodeGenerationLaunchDelegate.java:66)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:590)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:515)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:733)
at org.eclipse.debug.internal.ui.DebugUIPlugin$6.run(DebugUIPlugin.java:931)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)
Caused by: org.postgresql.util.PSQLException: The column name FKTABLE_CAT not found.
at org.postgresql.jdbc1.AbstractJdbc1ResultSet.findColumn(AbstractJdbc1ResultSet.java:673)
at org.postgresql.jdbc1.AbstractJdbc1ResultSet.getString(AbstractJdbc1ResultSet.java:475)
at org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect$5.convertRow(JDBCMetaDataDialect.java:272)
at org.hibernate.cfg.reveng.dialect.ResultSetIterator.next(ResultSetIterator.java:47)
... 17 more


If I change to the 8.1 driver error doesn't changes

WARN Worker-25 org.hibernate.cfg.JDBCBinder - Exception while reading foreign keys for org.hibernate.mapping.Table(public.category) [org.hibernate.exception.GenericJDBCException: Error while reading exported keys meta data for public.category

The DDL for category and file

CREATE TABLE file
(
id serial NOT NULL,

CONSTRAINT id_pk PRIMARY KEY (id),
CONSTRAINT file_category_id_fkey FOREIGN KEY (category_id)
REFERENCES category (id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT
)


CREATE TABLE category
(
id int4 NOT NULL DEFAULT nextval('public.category_id_seq'::text),
parent_id int4 DEFAULT 0,

CONSTRAINT category_pkey PRIMARY KEY (id)
)

Q


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 4:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
postgres has known bugs in their metadata handling, especially using wrong column names. Use a more uptodate driver.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: No luck even with the latest - it's even worst...
PostPosted: Thu Mar 02, 2006 9:00 pm 
Regular
Regular

Joined: Sat Jan 07, 2006 8:30 pm
Posts: 68
When I'm using the latest driver postgresql-8.2dev-501.jdbc3.jar
I get much less warnings but it's a show stoper, nothing get's generated

There's an error, it comes in a popup...

org.hibernate.cfg.JDBCBinderException: Foreign key name (file_id) mapped to different tables! previous: org.hibernate.mapping.Table(public.webfolio_file_keyword) current:org.hibernate.mapping.Table(public.webfolio_payment)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 3:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
how does your foreign key definition look like for file_id ? These names should be globally unique normally.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: reverse engineering and code generation
PostPosted: Thu Mar 09, 2006 9:38 am 
Newbie

Joined: Thu Mar 09, 2006 8:16 am
Posts: 13
I was doing reverse engineering in eclipse with hibernate tools, and I have followed steps stated in the

http://www.hibernate.org/hib_docs/tools/reference/en/html/

all was going alright, in the hibernate configuration window I can see my database , tables ,objects but when I click code generation the strange message appears :

org.hibernate.cfg.JDBCBinderException: Foreign key name ($1) mapped to different tables!

I use PostgreSQL 7.4.7 and jdbc driver pg74.216.jdbc3.jar
and here is the code of my database:

create table car_owner(id serial primary key,name varchar(20),
surname varchar(20),jmbg integer);
create table reg_plate(id serial primary key,plate_signature char(2),
plate_number integer unique,id_car_owner integer references car_owner);
create table address(id serial primary key,street varchar(20),
city varchar(20),country varchar(20),id_car_owner integer references car_owner);


I would be gratefull if some could help me.

_________________
nikola_croatia


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 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.