All is in the question. How to map a Map with Hibernate using annotations ?
And what’s the associated database structure ?
All is in the question. How to map a Map with Hibernate using annotations
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You are probably looking for a generic key-value database structure where values can have multiple types. This is typically resolved by having some sort of abstract
Valueclass with key attribute and several subclasses, each for every desired type:Now you use:
Of course this approach has many disadvantages, correctly choosing inheritance strategy being one of them (it depends on how many different types you want to store). But at least it is perfectly type-safe.
I don’t have any experience with NHibernate, but with Hibernate (see: How do you map a "Map" in hibernate using annotations?) you can map
Mapdirectly.