-->
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.  [ 11 posts ] 
Author Message
 Post subject: MySQL schema update problem solved
PostPosted: Sat Nov 15, 2003 7:15 pm 
Newbie

Joined: Tue Oct 07, 2003 2:56 pm
Posts: 13
I have seen alot of people posted questions about schemaUpdate for mysql not working correctly. I myself have posted the same question to no avail. After digging aournd in hte source a little i came upon the problem. In net.sf.hibernate.tool.hbm2dll.DatabaseMetaData it queries the database metadata like so

Code:
   public TableMetadata getTableMetadata(String name) throws HibernateException {
      TableMetadata table = null;
      
      if (name!=null) {
         
         table = (TableMetadata) tables.get( name.toUpperCase() );
         if (table==null) {
            String[] types = {"TABLE"};
            ResultSet rs = null;
      
            try {
               try {
                  rs = meta.getTables(null, "%", name.toUpperCase(), types);
            
                  while ( rs.next() ) {
                     if ( name.equalsIgnoreCase( rs.getString("TABLE_NAME") ) ) {
                        table = new TableMetadata(rs, meta);
                        tables.put( name.toUpperCase(), table );
                        break;
                     }
                  }
               }
               finally {
                  if (rs!=null) rs.close();
               }
            }
            catch(SQLException e) {
               throw new HibernateException(e);
            }
         }
      }
      
      return table;
   }


the name.toUpperCase() is the problem, or at least it was for me. I removed it and recompiled hibernate and things worked for me from then on.

Here is my configuration:
MySQL 4.0.16 Max with default table type InnoDB
MySQL connectorJ 3.0.9
Hibernate 2.0.3

I will file this as a bug, in the meantime, you can do the same and try it out.


Top
 Profile  
 
 Post subject: oops, already found on Oct 18
PostPosted: Sat Nov 15, 2003 7:21 pm 
Newbie

Joined: Tue Oct 07, 2003 2:56 pm
Posts: 13
bug #HB-409 already discoverd the problem and posted the fix, just found out.
[url]
http://opensource.atlassian.com/project ... key=HB-409
[/url]


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 15, 2003 9:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Note that the reason for this problem is inconsistency in the behaviour of different drivers.

I should note that SchemaUpdate works perfectly for me on all the popular platforms unless quoted identifiers come into the picture.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 15, 2003 9:55 pm 
Newbie

Joined: Tue Oct 07, 2003 2:56 pm
Posts: 13
What driver do you use for mysql? Also do you use InnoDB type tables?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 15, 2003 11:13 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
mysql-connector-java-3.0.9-stable-bin.jar

MyISAM tables


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 12:43 pm 
Beginner
Beginner

Joined: Sat Aug 30, 2003 1:36 am
Posts: 47
Location: Calgary, AB
Gavin,

How come it only works for you and nobody else?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 1:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
No idea. Someone mentions in another thread that MySQL handles case-sensitivity differently on Unix and Windows platforms. I am on windows.

Presumably it works for some other people, since I didn't write a single line of code in this tool.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 1:51 pm 
Newbie

Joined: Tue Oct 07, 2003 2:56 pm
Posts: 13
For starters, i want to say that i think that hibernate is a great tool. I woul dlike to extend my appriciatation for your development effort on it.

That being said, after doing some testing, i found that mysql on linux is case sensitive for its table names. illistrated as follows

Code:

mysql> create table foo (id integer);
Query OK, 0 rows affected (0.04 sec)
                                                                               
mysql> select * from foo;
Empty set (0.03 sec)
                                                                               
mysql> select * from FOO;
ERROR 1146: Table 'test.FOO' doesn't exist


either solution mentioned in the bug report referenced earlier seems to address this problem though. Is their any reason that it would create problems.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 2:14 pm 
Beginner
Beginner

Joined: Sat Aug 30, 2003 1:36 am
Posts: 47
Location: Calgary, AB
Is that fix implemented though?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 4:05 pm 
Newbie

Joined: Tue Oct 07, 2003 2:56 pm
Posts: 13
After giving it some more thought, the toUpperCase when reading in the xml would not be a good idea incase you were trying to map a pre-existing database into hibernate, and the schema names where case sensitive. I think the best solution is to remove the toUpperCase on the SchemaUpdate, or move it into the dialect to determine if it should or not.

Also, I'm not sure what you mean by "Is the fix implemented though?", if you mean fixed in CVS, i don't know. Its not in 2.0.3 nor 2.1.beta6


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 4:23 pm 
Beginner
Beginner

Joined: Sat Aug 30, 2003 1:36 am
Posts: 47
Location: Calgary, AB
wdemoss wrote:
Also, I'm not sure what you mean by "Is the fix implemented though?", if you mean fixed in CVS, i don't know. Its not in 2.0.3 nor 2.1.beta6


I mean the fix that you are referring to (toUpperCase). And you answered the question well enough, but now I guess it would be nice if it were planned to be implemented soon?


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