Here's some notes on how we have used the 'any' mapping:
We have a "note" table that is meant to hold a note for any item in any of the other tables in the schema. In the note table we have a column called table_name and table_id. table_name tells which other table this note is for, and table_id says which item in that table this note is for. We used an any mapping in hibernate for this like this (in the hibernate XML for my note class):
<any meta-type="com.incogen.hibernate.NameToDataHibernateMapper" name="item" id-type="long" cascade="none">
<column name="table_name" />
<column name="table_id" />
</any>
item is a member of my note class that is of type NoteRelated, which is extended by all classes that can have notes attached to them. NameToDataHibernateMapper is a child class of net.sf.hibernate.UserType which I learned more about from
http://www.hibernate.org/122.html - it maps the table_name's to the proper java class (and vice-versa).
I am still trying to find the best way to reverse that any mapping so that the NoteRelated items can more easily find their notes, for now we are generating code to allow that.