-->
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: Selecting the correct dialect for mySql database
PostPosted: Wed Oct 27, 2004 3:18 pm 
Newbie

Joined: Wed Jan 14, 2004 11:29 am
Posts: 19
Hibernate version: 2.1.6
Name and version of the database you are using: MySql 4.0.17

I've just discovered the really useful features: setMaxResults() & setFirstResult() in hibernate, but i've ran into a problem! When I call list() on a Query with maxResults set I get the following error:

java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '5 advert0_.id as id, advert0_.expiryDate as expiryDate, advert0

I've diagnosed this problem as being due to the SQL that is generated:

Hibernate: select top ? advert0_.id as id, advert0_.expiryDate as expiryDate, advert0_.property_id as property3_, advert0_.isSuspended as isSuspen4_, advert0_.timeStamp as timeStamp, advert0_.user_id as user_id, advert0_.image_id as image_id from advert advert0_ where (advert0_.isSuspended='0' )

The very first part specifies select top ? but this isn't valid syntax for a SQL query when using mySql. Looking around on google this is MSSQL syntax. My first thought was the dialect being use was incorrect, but a little research concluded the following is correct (which I am using):

hibernate.dialect net.sf.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class = com.mysql.jdbc.Driver

So i'm a little stumped! Can you use these function when using hibernate with a mySql database?

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 05, 2004 12:24 pm 
Newbie

Joined: Wed Jan 14, 2004 11:29 am
Posts: 19
Had anyone any ideas to this problem? I've still not found a solution.......

Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 06, 2004 8:26 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Be sure (through the logs) this is the actual dialect used

_________________
Emmanuel


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.