-->
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: Problem with table alias in Hibernate 3.6.0Final
PostPosted: Thu Feb 24, 2011 5:27 am 
Newbie

Joined: Mon Mar 29, 2010 6:56 am
Posts: 3
Hi every one,

I have a problem with table alias in subquery. I think that it's a bug in Hibernate 3.6.0 Final. This is my HQL query:

Code:
insert into Item_Tag(itemId, tagId) select item.id, tag.id from Item item, Tag tag where item.identifier like :identifier0 and tag.id in (:tagIds) and not exists (from Item_Tag where itemId = item.id and tagId = tag.id)


And Hibernate translates to native query like this:
Code:
Hibernate:
    insert
    into
        item_tag_map
        ( id_item_tag_map, id_item, id_tag ) select
            nextval ('hibernate_sequence'),
            item0_.id_item as col_0_0_,
            tag1_.id_tag as col_1_0_
        from
            item_list item0_ cross
        join
            tag_list tag1_
        where
            (
                item0_.identifier like ?
            )
            and (
                tag1_.id_tag in (
                    ?
                )
            )
            and  not (exists (select
                item_tag2_.id_item_tag_map
            from
                item_tag_map item_tag2_
            where
                item_tag2_.id_item=item_list.id_item
                and item_tag2_.id_tag=tag_list.id_tag))


As you see, in the subquery, the alias "item" and "tag" are replaced by their raw names: "item_list" and "tag_list". So an exception org.hibernate.util.JDBCExceptionReporter is thrown to indicate that the alias "item0_" and then "tag1_" should be used in this case.
Is there anyone who knows if it's a bug or how to solve this error? Thanks very much.


Top
 Profile  
 
 Post subject: Re: Problem with table alias in Hibernate 3.6.0Final
PostPosted: Tue Oct 23, 2012 3:25 am 
Newbie

Joined: Wed Oct 17, 2012 3:39 am
Posts: 1
Anybody ever resolved this error? Maybe figured out the cause for this behaviour?

I'm facing the same problem with Hibernate 4.1.5 (also with an insert HQL statement) - and am actually not amused by this behaviour (still investigating for a solution).


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.