Hello all,
I am very new to Hibernate, so this has been stumping me for the past few days. Suppose you have a person, that has dogs, who have toys:
Code:
Person A
Dog 1
Toy - Red
Toy - Green
Dog 2
Toy - Red
Toy - Green
Person B
Dog 1
Toy - Blue
Toy - Green
Dog 2
Toy - Blue
Toy - Green
I want to retrieve
only the People that have dogs that have RED toys. I also only want to retrieve the RED toys, so the result would be:
Code:
Person A
Dog 1
Toy - Red
Dog 2
Toy - Red
I have no idea how to do this. I need to send it a list of colors. I have tried:
Code:
Criteria criteria = this.getSession().createCriteria( Person.class ).createCriteria("dogs")
.createCriteria("toys").add( Expression.in(toy_color, colors) ); //where colors is a List of colors
and also many other combos that I can't remember. I'm like a chicken with my head cut off here, and I honestly don't know how to get the specific grandchildren, just those grandchildren, and their parent and grandparent. All tutorials are for only one level of children.
Does anyone know how to do this, or at least know of a relevant tutorial?
Thanks so much!