日期:2014-05-20 浏览次数:20808 次
@Entity @Table(name = "QBMS_BANK") public class QuestionBank extends BaseEntity { private static final long serialVersionUID = 8276628395037978969L; @Column(name = "NAME", unique = true) @Size(max = 100) @NotNull private String name; @OneToMany(mappedBy = "bank", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) @MapKey(name = "user") private Map<User, QuestionBankUserPermission> userPermissions; public String getName() { return name; } public Map<User, QuestionBankUserPermission> getUserPermissions() { return userPermissions; } public void setName(String name) { this.name = name; } public void setUserPermissions( Map<User, QuestionBankUserPermission> userPermissions) { this.userPermissions = userPermissions; } }
QuestionBankUserPermission userPermission = bank .getUserPermissions().get(user); System.err.println("userPermission->" + userPermission);
if(bank.getUserPermissions().containsKey(user)){ System.err.println("yes"); }
for (Map.Entry<User, QuestionBankUserPermission> entry : bank .getUserPermissions().entrySet()) { if (entry.getKey().equals(user)) { System.err.println("existed the same key"); } }