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.