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.  [ 6 posts ] 
Author Message
 Post subject: Aliases for joined tables don't work
PostPosted: Wed Dec 24, 2003 1:17 pm 
Newbie

Joined: Wed Dec 24, 2003 12:40 pm
Posts: 2
Location: Moscow, Russia
Hello,

I've got a problem with Hibernate 2.1.1

HQL that works:

Quote:
select count(ce) from CategoryEntry as ce +
inner join ce.category as с +
where ce.category.id = ?


The generated SQL is as follows:

Quote:
select count(categoryen0_.ID) as x0_0_ from Category_Entry categoryen0_ inner join Category category1_ on categoryen0_.category_id=category1_.ID where (category1_.ID=? )


Now if I try to use alias c, like this:

Quote:
select count(ce) from CategoryEntry as ce +
inner join ce.category as с +
where c.id = ?


The generated SQL becomes:

Quote:
select count(categoryen0_.ID) as x0_0_ from Category_Entry categoryen0_ inner join Category category1_ on categoryen0_.category_id=category1_.ID where (c.id=? )


Obviously this SQL won't work. So what I am doing wrong?

HBMs:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="ru.extram.customerpublishing.infobag.dal.Category" table="Category">
<id column="ID" name="id" type="java.lang.Long">
<generator class="native"/>
</id>
<property column="name" length="100" name="name" type="java.lang.String"/>
<property column="description" length="500" name="description" type="java.lang.String"/>
<property column="is_leaf" length="1" name="isLeaf" type="java.lang.Boolean"/>
<property column="order_number" length="10" name="orderNumber" type="java.lang.Integer"/>
<property column="xml_name" length="100" name="xmlName" type="java.lang.String"/>
<property column="alias_category_id" length="10" name="aliasCategoryId" type="java.lang.Integer"/>
<property column="parent_category_id" length="10" name="parentCategoryId" type="java.lang.Integer"/>
<property column="category_type_id" length="10" name="categoryTypeId" type="java.lang.Integer"/>
</class>
</hibernate-mapping>


Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="ru.extram.customerpublishing.infobag.dal.CategoryEntry" table="Category_Entry">
<id column="ID" name="id" type="java.lang.Long">
<generator class="native"/>
</id>
<property column="category_id" insert="false" update="false" length="10" name="categoryId" not-null="true" type="java.lang.Integer"/>
<property column="entry_id" insert="false" update="false" length="10" name="entryId" not-null="true" type="java.lang.Integer"/>
<property column="int_value" length="10" name="intValue" type="java.lang.Integer"/>
<property column="FloatValue" length="53" name="floatvalue" type="java.lang.Float"/>
<property column="DateValue" length="23" name="datevalue" type="java.util.Date"/>
<property column="MoneyValue" length="19" name="moneyvalue" type="java.lang.Double"/>
<property column="image_id" length="10" name="imageId" type="java.lang.Integer"/>
    <many-to-one name="category" class="ru.extram.customerpublishing.infobag.dal.Category" column="category_id" not-null="true"/>
    <many-to-one name="entry" class="ru.extram.customerpublishing.infobag.dal.Entry" column="entry_id" not-null="true"/>
    <set name="stringValues" lazy="true" cascade="all">
        <key column="category_entry_id"/>
        <one-to-many class="ru.extram.customerpublishing.infobag.dal.StringValue"/>
    </set>
</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 25, 2003 4:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I don't really believe this.

I think you need to re-check your workings.


If you can reproduce it in an incredibly simple test case (ie. two classes with two or three properties, running in a main method), submit it to JIRA and I will take a look.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 25, 2003 1:08 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
mitek,
make sure you didn't put cyrillic "c" into your query. I bet one of c's is latin and second one is cyrilic


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 25, 2003 1:11 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Heh. No need to check. I know for sure one of c's i cyrillic - look at the page source:

inner join ce.category as с +


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 25, 2003 1:13 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Hm.... It was

inner join ce.category as & #1089;


Ppl, your forum does not escape ampersand!


Top
 Profile  
 
 Post subject: Thanx!
PostPosted: Thu Dec 25, 2003 2:29 pm 
Newbie

Joined: Wed Dec 24, 2003 12:40 pm
Posts: 2
Location: Moscow, Russia
This is classics :-)


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