I am a bit confused about aliases to be honest so I am hoping someone can help me understand them better. In order to explain what I am missing I will use examples.
Lets say that I have:
Criteria criteria = session.createCriteria(Car.class)
criteria.createAlias("doors", "doors");
That means that now I can use some Restrcitions to find a door that is on left side of the Car
or something along those lines.
Now my question is if I where to add multiple alias:
criteria.createAlias("doors", "doors").createAlias("doors.keytype", "keytype");
and
criteria.createAlias("tier".tier);
What does this mean? That my criteria
object has all of those aliases? In which case what will getAlias()
method return?
From the API:
Get the alias of the entity encapsulated by this criteria instance.
I was under the impression that all of the alias are encapsulated by this instance? Am I wrong? Did I somehow lost my first alias?
Also if I do something like:
Criteria criteri2 = criteria.createAlias("tier".tier);
Does this mean that both criteria
and criteria2
point are the same Criteria
or diff and which one points to what alias?
Furthermore given that each createAlias
returns a Criteria
should I assign that to the original criteria
or to the new one?
Well I hope you can see my confusion.