-->
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: Mysql query: syntax error
PostPosted: Tue Jan 15, 2008 11:35 am 
Newbie

Joined: Mon Mar 05, 2007 4:38 am
Posts: 17
Hi all,

we are trying to convert our hibernate project from MSSQL to MySQL but found a problem with the query generation.

Hibernate for instance logs this query:
Code:
    update
        CustomerEnvironments
    set
        Environment=?,
        Release=?,
        Patch=?
    where
        ID=?


This results in a syntax error. When I fill in my values, that indeed fails and appears to be the problem of the "Release" column. Trying this (with quoting around "release" does work:

Code:
    update
        CustomerEnvironments
    set
        Environment='TEST',
        `Release`=null,
        Patch=null
    where
        ID=224


Is there a way I can make hibernate add these backquotes by configuration or is this actually a bug?

btw... I have set the dialect to MySQLInnoDBDialect since I am only using InnoDB tables in MySQL 5.0.41

Thank you for your help,
Steven


Top
 Profile  
 
 Post subject: Re: Mysql query: syntax error
PostPosted: Tue Jan 15, 2008 2:43 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
tomba wrote:
Is there a way I can make hibernate add these backquotes by configuration or is this actually a bug?


Steven, I do think you can name a column in almost anyway you want. I didn't try back quotes but I tried MSSQL brackets and it worked. Give it a try.


Code:
<key column="[PERSIONID]"/>





Farzad-


Top
 Profile  
 
 Post subject: Re: Mysql query: syntax error
PostPosted: Wed Jan 16, 2008 11:48 am 
Regular
Regular

Joined: Fri May 12, 2006 4:05 am
Posts: 106
tomba wrote:
Is there a way I can make hibernate add these backquotes by configuration or is this actually a bug?

There is...
Just include the backquotes in your mapping-file like this:
Code:
column="`Release`"

the good thing about this is: hibernate will automatically use the appropriate quotes for your SQL-Dialect, so for mssql this would result in the column-name being enclosed in brackets, for mySql it should be enclosed in backquotes.

Greets

piet


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.