i have a table
Permission:
what i am doing right now
is to make a query that returns a permission object then put the values in the map programmatically
1- But i was wondering if it's possible to make an HQL (or native sql if not possible) to select the permission_id, permission_name and return them in a map.
2- is it possible to return map in one to many relationship instead of following list or set
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "perm_cat_map", joinColumns = { @JoinColumn(name = "perm_cat_id") }, inverseJoinColumns = { @JoinColumn(name = "permission_id") })
private List<Permission> permissions = new ArrayList<Permission>(0);
is it possible to have something like:
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "perm_cat_map", joinColumns = { @JoinColumn(name = "perm_cat_id") }, inverseJoinColumns = { @JoinColumn(name = "permission_id") })
private Map<String,String> permissions = new ArrayList<String,String>(0);
where the two strings are permission_id, permission_name.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…