-->
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.  [ 5 posts ] 
Author Message
 Post subject: MySQLDialect.getTableComment() Bug
PostPosted: Wed Aug 17, 2005 6:20 pm 
Newbie

Joined: Wed Aug 17, 2005 6:08 pm
Posts: 2
I'm new to Hibernate and this board but I'm pretty sure I found a bug that hasn't been reported (at least I couldn't find it).

Problem
: Creating table with MySQLDialect fails when the table includes comments (<comment>...)

Found
: Trying to run the "eg" example that comes with Hibernate 3.0.: "ant eg"

OS: Win2000
Hibernate: 3.0.5
MySQL: Ver 12.22 Distrib 4.0.18, for Win95/Win98 (i32)
Java: 1.5

Solution
: The problem occurs because of the SQL syntax MySQLDialect returns for the method getTableComment(). It currently returns the string:

public String getTableComment(String comment) {
return " comment '" + comment + "'";
}

According to MySQL syntax, it should return the string:

public String getTableComment(String comment) {
return " comment = '" + comment + "'";
}

Changing this and recompiling the source allowed the example "ant eg" to work.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 17, 2005 6:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This has been reported several times.

Actually it works with latest MySQL releases.

It also works in 3.1 beta releases.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 17, 2005 6:38 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
For a column it is:
Code:
COMMENT 'string'


For a table it is:
Code:
COMMENT = 'string'


See:
http://dev.mysql.com/doc/mysql/en/create-table.html

Gavin, I believe you when stating that it works with the latest version of MySQL, but I cannot find any hints about that in their documentation. Though I haven't tested it myself.

Best regards
Sven

_________________
Please don't forget to give credit, if this posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 17, 2005 6:41 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Well, I think I misunderstood you.

I just had a look at MySQLDialect.java:
Code:
public String getTableComment(String comment) {
   return " comment='" + comment + "'";
}

public String getColumnComment(String comment) {
   return " comment '" + comment + "'";
}


It is corrected with regard to the MySQL docs in HB 3.1 beta and will work very well. :)

Sven

_________________
Please don't forget to give credit, if this posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 17, 2005 7:12 pm 
Newbie

Joined: Wed Aug 17, 2005 6:08 pm
Posts: 2
Cool, just trying to help. I searched on MySQLDialect and getTableComment on the forum and Google before posting but found nothing. Thought it might be a windows/mysql specific problem that didn't show up for most people.


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