-->
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: Getting current table alias in a filter
PostPosted: Wed Jun 01, 2005 3:39 pm 
Newbie

Joined: Fri Mar 25, 2005 1:16 pm
Posts: 13
Hibernate version: 3.0.5

Name and version of the database you are using:SQL Server 2000

I'm trying to use a subselect in a filter, but the problem I have is that the main table and a table in the subselect have a column with the same name. SQL Server uses the subselect table for that column, but I need the main table column used. That's easy enough using aliases, but within a filter I don't know the alias of the main table that Hibernate generates. Can this be made available with a placeholder, like ${this} or something? That way I could have a filter like this:

<filter name='x' condition="EXISTS (SELECT * FROM sub WHERE sub.name = ${this}.name)" />

Hibernate would just need to replace that with the alias generated for the main table. And no, SQL Server doesn't allow a full table name to be used when that table has an alias assigned.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 01, 2005 3:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Any unqualified identifiers are assumed to be identifiers from the outer query.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 01, 2005 4:16 pm 
Newbie

Joined: Fri Mar 25, 2005 1:16 pm
Posts: 13
I guess I wasn't expecting Hibernate to modify that part of it since the fragment is basically SQL, but I just tried it and it does append this_. in front the unqualified field. Sorry for not trying it first. Good foresight!


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.