I am trying to use <any> this way:
<class name='AuditRecord' table='AUD_RECORD'>
<id name='id' column='ID' type='long' unsaved-value='0'>
<generator class='native'/></id>
<!-- some properties -->
<any name='subject' id-type='long' meta-type='AuditTypeMapper'>
<column name='TYPE'/>
<column name='SUBJECT_ID'/>
</any>
</class>
AuditTypeMapper follows the Custom UserType pattern and returns integer
The following code is used for query:
session.find ( "FROM " + AuditRecord.class.getName() + " rec WHERE rec.subject=?", subject,
Hibernate.any(Hibernate.custom (AuditTypeMapper.class), Hibernate.LONG));
Is this correct? When I test it, it complains "path expression ends in a composite value".
What's the proper way to use Hibernate.any()? Is it necessary for I to use rec.subject.class=? AND rec.subject.id=? instead of rec.subject?
Thanks.
Albert
|