Hibernate version:
2.1.6
My question is can I use the Criteria API to query on a class/table where the class uses a composite key identifier (seperate class)?
Ex:
Cat table uses a composite key made up of:
name
sex
hair
The composite key is in a seperate class.
I know the cat's name so I want to get all cats where Cat.comp_id.name = 'Fluffy'
How can I do this with Criteria API?
Something I have tried is this but it did not return the correct results:
Quote:
Criteria crit = session.createCriteria(Cat.class);
Cat cat = new Cat();
cat.setComp_id(new CatPK());
cat.getComp_id().setName('Fluffy');
crit.add(Example.create(cat));
crit.setMaxResults(300);
results = crit.list();
Thank you for any suggestions,
David