Storing a Map Using Hibernate

As of right now I don’t believe this is supported in JPA, but it can be done in Hibernate. If you want to persist a Map, something like Map then you’ll need the following annotations:

@org.hibernate.annotations.MapKey(targetElement = String.class,columns = {@Column(name = "locale")})
@JoinTable(name = "organization_urls", joinColumns = @JoinColumn(name = "org_id"))
@CollectionOfElements(targetElement = String.class)
@Column(name="url")

Figured I would post this here since I had trouble locating it.

0 comments ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment

Spam protection by WP Captcha-Free