-->
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: order from joined table with collection
PostPosted: Mon Jun 18, 2007 6:43 am 
Newbie

Joined: Mon Jun 18, 2007 6:33 am
Posts: 3
Hello,
I have a problem that is similar to what people have posted before. But I have a different setup so I couldnt find a way to apply the solution.

I have used myeclipse to generate the java code and the mappings. so here it is

Code:
class Animal
{
     private Set animalAttributes = new HashSet(0);
}

class Attribute
{
          private Type type;
}
class Type
{
       int order;
}


I have changed the mapping file to make hibernate use just one sql statement. That was the only way that I could find to have a sql statement like this:

Code:
select
        animalattr0_.animalId as animalId3_,
        animalattr0_.attributeId as attribut2_3_,
        animalattr0_.animalId as animalId1_2_,
        animalattr0_.attributeId as attribut2_1_2_,
        attribute1_.id as id0_0_,
        attribute1_.typeId as typeId0_0_,
        attribute1_.value as value0_0_,
        type2_.id as id4_1_,
        type2_.name as name4_1_,
        type2_.order as order4_1_
    from
        patix.Animal_Attribute animalattr0_
    inner join
        patix.Attribute attribute1_
            on animalattr0_.attributeId=attribute1_.id
    left outer join
        patix.Type type2_
            on attribute1_.typeId=type2_.id
    where
        animalattr0_.animalId in (
            select
                this_.id
            from
                patix.Animal this_
            where
                (
                    1=1
                )
        )


so with this, I could enter an animalId and get the attributes of that animal and it's type.

In the end what I want to achive is to order these attributes with type.order property.

How do I go this? I tried the alias approach but I kept getting animalAttributes doesnt have type property.


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.