• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate Column in where clause is ambiguous

 
Angel J Gama
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm new to Hibernate. I'm working on a store app where I register ticket info (Ticket Object), ticket's purchased items (Item Object) and the user which made that purchase (User Object).
I can store, read info, etc, no problem in mapping files, as far as I know, everything works ok... but I'm getting an error when I try to query all items purchased within last 24 hours from a specific user. Since all my tables (Objects) have a column named "CREATION_TIME" (timestamp type) whenever I do the following query I get the horrible error:


The query is as follows:




Furthermore, when I use Item's alias I get the error:

Code is:


Does anyone knows what do I'm doing wrong?? what do I'm missing?
I'll appreciate your help.
 
Angel J Gama
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind... I understood that I should write "the alias" within a sqlRestriction [ex: sqlRestriction("{itm}.CREATION_TIME")] but I should have wrote the "alias" word within a sqlRestriction.

The following works:



Any occurrences of {alias} will be replaced by the table alias, in this case it'll be replace by "itm".
Thanks anyway
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!