1 package com.jl.module.test.bean;
2
3 import java.util.HashMap;
4 import java.util.Map;
5 import javax.persistence.Column;
6 import javax.persistence.Entity;
7 import javax.persistence.GeneratedValue;
8 import javax.persistence.Id;
9 import javax.persistence.JoinColumn;
10 import javax.persistence.JoinTable;
11 @Entity
12 public class Content {
13 @Id
14 @GeneratedValue
15 private int id;
16 @org.hibernate.annotations.CollectionOfElements
17 @JoinTable(name = "content_attr", joinColumns = @JoinColumn(name = "content_id"))
18 @org.hibernate.annotations.MapKey(columns = @Column(name = "attr_value"))
19 private Map<String, String> attr = new HashMap<String, String>();
20
21 public int getId() {
22 return id;
23 }
24
25 public void setId(int id) {
26 this.id = id;
27 }
28
29 public Map<String, String> getAttr() {
30 return attr;
31 }
32
33 public void setAttr(Map<String, String> attr) {
34 this.attr = attr;
35 }
36
37 }
此时的content_attr表不含有主键。