-->
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.  [ 1 post ] 
Author Message
 Post subject: database keyword as table name / alias in HQL
PostPosted: Fri Sep 22, 2006 11:27 pm 
Beginner
Beginner

Joined: Mon Apr 03, 2006 2:41 am
Posts: 25
Location: Mauritius
Hello,

I had a table with the name 'group' and I used this table in a HQL query.

I got the following error :

Code:
javax.ejb.EJBException: java.lang.ClassCastException: org.hibernate.hql.ast.tree.SqlNode


( It could be great to get a more specific exception in this case )

I have found out that we can define the @Table annotation with the backquote (`) in order to quote the tablename in the query.

Code:
@Entity
@Table(name = "`group`"....


it had quoted the tablename in the query but this hadn't fixed my problem.


My actual problem was that the alias to this table was 'group'.
Since I was doing join on this table, I have defined an alias with the name of the table.

Code:
left join questionnairegroups.group as group


I fixed the issue with a simple rename from 'group' to 'groupe'.

It works fine, I'm simply wondering if there is a way to use such database keyword for alias ?

I know that it's not recommended to use database keyword as table name, but the database need to match with the vocabulary of the domain so...

Thanks in advance for any feedback

Regards,
Christophe


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.