DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Thomas has posted 33 posts at DZone. View Full User Profile

Hibernate Mapping Of A Map Having An Enum Key

12.08.2011
| 3035 views |
  • submit to reddit
        
@CollectionOfElements
@JoinTable(
 name = "TRACE_PROPERTY",
  joinColumns = { @JoinColumn(name = "TRACE_ID") },
  uniqueConstraints = { @UniqueConstraint(columnNames = {"TRACE_ID", "NAME", "VALUE" }) })
@org.hibernate.annotations.MapKey(
  columns = @Column(name = "NAME", nullable = false, length = 100),
  type = @Type(
    type = "org.hibernate.type.EnumType",
    parameters = {
      @Parameter(name = "enumClass", value = "x.y.z.ExternalPropertyName"),
      @Parameter(name = "type", value = "12")}))
@Column(name = "VALUE", nullable = false, length = 255)
private Map<ExternalPropertyName, String> properties = new HashMap<ExternalPropertyName, String>();
    

Comments

Snippets Manager replied on Mon, 2012/04/02 - 11:37pm

This code is too good love it .Link building service uk