-->
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.  [ 2 posts ] 
Author Message
 Post subject: Errors with generated SQL after moving from 3.2.1 to 3.5.2
PostPosted: Tue Oct 26, 2010 7:02 am 
Newbie

Joined: Fri Feb 27, 2009 8:02 am
Posts: 10
Location: Woking, England
Hi,

We have upgraded Hibernate from 3.2.1 to 3.5.2.

We have a few tables on our legacy database with columns named "end"
We have a criteria that generates a select statement from multiple tables and we don't specify the "end" column directly in the criteria anywhere.

The generated sql since moving to 3.5.2 doesn't prefix the column with the alias like it did in 3.2.1...


NB. The order of the tables and columns is different between 3.2.1 and 3.5.2 but this isn't a problem and in both cases the where clause generated has the required prefix:

Generated SQL fragment from Hibernate 3.2.1:
Code:
...
        currentele18_.oper as oper54_12_,
        currentele18_.stream as stream54_12_,
        currentele18_.end as end54_12_,
        currentele18_.route as route54_12_,
        currentele18_.service_op as service14_54_12_,
...
            and (
                currentele18_.mtype = 3
                and currentele18_.start <= 'today'
                and currentele18_."end" >= 'today'
            ) 


Generated SQL fragment from Hibernate 3.5.2:
Code:
...
        currentele13_.region as region54_7_,
        currentele13_.despatch_to as despatch6_54_7_,
       
    end as end54_7_,
    currentele13_.optype as optype54_7_,
    currentele13_.oper as oper54_7_,
...
and (
    currentele13_.mtype = 3
    and currentele13_.start <= 'today'
    and currentele13_."end" >= 'today'



As you can see, the "end" column is lacking the alias prefix (this is also the case for the other tables in the same query that have an "end" column).

This apparent bug is causing the following error: java.sql.SQLException: Ambiguous column (end).

Renaming the columns is not an option.

Help please!

_________________
Thanks in advance for any helpful replies :O)


Top
 Profile  
 
 Post subject: Re: Errors with generated SQL after moving from 3.2.1 to 3.5.2
PostPosted: Thu Nov 04, 2010 11:45 am 
Newbie

Joined: Fri Feb 27, 2009 8:02 am
Posts: 10
Location: Woking, England
I'm surprised no-one was able to help with this.

I found the answer myself in the end. You now need to put back ticks or brackets around the lower case column name: "`end`" or "[end]".

This wasn't necessary in Hibernate 3.2.1 but is in 3.5.2

_________________
Thanks in advance for any helpful replies :O)


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