It may seem that I do not answer your question... but... There is a feature like you are requesting:
- but it is not supported by annotations - just
xml
mapping
- but it is not about
List<>
- but Map
non-generic
Firstly, why just xml? because it is a dynamic component not related to class, see:
In the Component class, there is an attribute called dynamic which allows for support of the dynamic-component property type in xml configuration. Annotations do not currently have support for dynamic-components...
Which leads us to what we are talking about:
9.5. Dynamic components <dynamic-component>
Let's summarize the doc:
You can also map a property of type Map:
<dynamic-component name="userAttributes">
<property name="foo" column="FOO" type="string"/>
<property name="bar" column="BAR" type="integer"/>
<many-to-one name="baz" class="Baz" column="BAZ_ID"/>
</dynamic-component>
The semantics of a <dynamic-component>
mapping are identical to <component>
. The advantage of this kind of mapping is the ability to determine the actual properties of the bean at deployment time just by editing the mapping document. Runtime manipulation of the mapping document is also possible, using a DOM parser. You can also access, and change, Hibernate's configuration-time metamodel via the Configuration object.
As described in the documentation, this way we can work with some dictionary of keys representing columns and values representing the content.
Maybe, check also this (NHibernate but the essential meaning is the same)
Finally: I am using this feature a lot - for Additional fields - driven by business users. These do need just some metadata management and udpated xml
mapping to work. Nothing else. And what's more important, because these are columns (not dynamic rows) we can order by them as well...