Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate Version 3.0.5
Hi Everyone,
I am unable to find the correct HQL syntax for selecting all records based on a given collection of composite keys.
My mapping files all seem to be fine, i believe the problem is with my HQL query. Would any of you please give it a more experience view.
Setup:
Class Record {
//fields
RecordKey key;
}
Class RecordKey {
String unitId;
String companyId;
String tranId;
}
Record class is mapped with a composite Key mapping in *.hbm.xml file.
Current HQL.
<![CDATA[
FROM Record rec
WHERE
rec.key.companyId ='1' AND
(rec.key) in elements(keys) ]]>
This currently throws a null pointer when trying to create a hibernate session since it seems to preparse all the named query files.
'keys' is a array/collection of RecordKey class. It wont like me use ':keys'
I set this using query.setParameter("keys",keys); in my code.
I've overridden equals + hashcode incase it needed to compare keys.
I've tried every combination of different field checks and syntax i can think of and searched Google for the last 2 days but cannot find what i'm looking for.
Thank you kindly for your help.
Jake