-->
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.  [ 10 posts ] 
Author Message
 Post subject: Code generator does not detect foreign keys
PostPosted: Mon Apr 14, 2008 4:04 pm 
Newbie

Joined: Fri Apr 11, 2008 1:38 pm
Posts: 9
I have a simple database set up in mysql 5.0 with a couple of foreign keys (i.e. one-to-many relationships). The code generation doesn't seem to be detecting these and it does not generate the appropriate one-to-many mappings. Any ideas?

Thanks,
Scot

edit: I am using mysql 5.0 with a 5.1.6 connector.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 1:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
1) check that you are using a MySQL storage model that actually supports and reports foreign keys, MyISAM does not - InnoDb does.

2) check that you really are using a jdbc driver that supports foreign keys

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 7:46 am 
Newbie

Joined: Fri Apr 11, 2008 1:38 pm
Posts: 9
Yes, using an Innodb engine. Just to check, I did a SHOW CREATE TABLE in mysql and can see all the foreign keys just fine.

I am also using the latest mysql connector, mysql-connector-java-5.1.6-bin.jar, which is supposed to be able to retrieve foreign key info.


Last edited by euchredog on Tue Apr 15, 2008 7:52 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 7:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I can only say it works perfectly for me and everyone else who said mysql did not reverse engineer properly and then verified they actually had the right driver and right db type.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 10:49 am 
Newbie

Joined: Fri Apr 11, 2008 1:38 pm
Posts: 9
The driver seems to be working fine. Using the same driver through an eclipse sql editor, I can see the foreign key constraints without any trouble at all.

What else can I do to verify that I am using the correct database and driver? All of my tables are built with engine=InnoDB explcitely defined and I am using a 5.0 driver from mysql-connector-java-5.0.8-bin.jar. I switched from the earlier 5.1 driver because I know someone who has a working configuration that was using that driver. Either one is very recent and should be good.

Any ideas? I'm really stumped here. If it's not the driver or the database, what else could be causing it to not see my foreign keys?

My database is version 5.0.51a


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 5:59 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if you can then submit the simplest SQL schema creation script that you cannot reverse engineer and tell me what you actually do in jira and ill look into it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 16, 2008 9:15 am 
Newbie

Joined: Fri Apr 11, 2008 1:38 pm
Posts: 9
Well, I figured out what was going on. I don't understand it. Perhaps you can explain. It all came down to this one property:

<property name="hibernate.connection.url">jdbc:mysql://localhost/custord</property>

If I put the database name in upper case, it will not detect my foreign keys. Like this:

<property name="hibernate.connection.url">jdbc:mysql://localhost/CUSTORD</property>

Something is wrong somewhere. I don't think MySQL is supposed to be case sensitve anymore.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 16, 2008 10:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well we just read what the database metadata is telling us.

So looks like mysql is case sensitive in the metadata look ups.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 16, 2008 10:26 am 
Newbie

Joined: Fri Apr 11, 2008 1:38 pm
Posts: 9
My guess is it's related to this bug which has been open for almost 2 years now.

http://bugs.mysql.com/bug.php?id=21317


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 19, 2008 3:21 pm 
Newbie

Joined: Fri Sep 19, 2008 3:06 pm
Posts: 1
I can confirm that there si a problem with the case of the database name.
I had a database named SeamDB and the tools didnĀ“t work with the foreign keys. After renaming the database to seamdb everything worked fine.


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