Take the 2-minute tour ×

I have the following Java Collection

List<Map<String, Object>>

I've written a custom converter class which can flatten this down to a List of MyEntity (where MyEntity is basically String, Value, Java type, parent collection) and re-assemble it back to a Map but I was wondering......

Is it possible to annotate the List such that Hibernate can persist a List of these Maps? I've had a brief look at the collectionOfElements annotation and I know there will be problems with the Object value due to Hibernate needed to convert to a valid database type.

Any ideas gratefully received :)

share|improve this question
Any reason why you don't want to create a mapping for MyEntity? –  dfb Apr 6 '11 at 16:25
Thanks for your reply. If I understand what you mean, MyEntity is mapped. I have a List<MyEntity> which is persisted. However, I have to do the conversion to and from this entity myself - i.e. I have transient methods which change the List<Map<String, Object>> to a List<MyEntity> on update and the other way on retrieve. I was hoping Hibernate could handle this conversion (much more reliably) for me. –  JoshSnow Apr 8 '11 at 10:33
I don't have a good answer, unfortunately. What I usually do is make additional getters/setters on the POJO to make the conversion for clients that need that representation, which sounds like exactly what you're doing. –  dfb Apr 8 '11 at 16:24
add comment


Your Answer



Browse other questions tagged or ask your own question.