我想检索许多具有一个共同“角色”的“访问”。
这是命名查询:
SELECT access
FROM Access AS access
WHERE :role MEMBER OF access.listRole
访问实体_
public class Access implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
private String name;
private String libelle;
@ManyToOne
private Module oneModule;
@ManyToMany
private List<Role> listRole;
/* Setter & Getter */
}
角色实体_
public class Role implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
private String name;
private String description;
@Enumerated(EnumType.STRING)
private Flag oneFlag;
@Transient
private int lengthAccess;
@OneToMany(mappedBy="oneRole")
private List<UserAccount> listUserAccount;
@ManyToMany
private List<Access> listAccess;
/* Geter & Setter */
}
但是我没有做到正确的 EJB-QL !
配置:
- EJB 3
- MySQL (InnoDB)
- 老板
- 扑通扑通
谢谢。