私は次のクラスを持っています
@NamedQueries({
@NamedQuery(name = "User.FindByFilter", query = "SELECT NEW myPkg.SimpleUser(u.name , u.email, u.roles) FROM User u WHERE UPPER(u.name) LIKE :filter AND ORDER BY u.name")
})
@Entity
@Table(name = "Users")
public class User implements Serializable, UserDetails {
@Id
private String email;
@Basic
private String name;
@OneToMany(cascade = { CascadeType.REFRESH, CascadeType.PERSIST }, fetch = FetchType.EAGER)
private Set<Authority> roles;
...
}
と
@Entity
public class Authority implements GrantedAuthority {
//just @Id and @Basic here no specific mapping back to user
...
}
もちろん、私はこのクエリが
@NamedQuery(name = "User.FindByFilter", query = "SELECT NEW myPkg.SimpleUser(u.name , u.email, u.roles) FROM User u WHERE UPPER(u.name) LIKE :filter AND ORDER BY u.name")
間違ってu.roles
ますので@OneToMany
。
だから私の質問は、役割フィールドをconstに渡す正しい方法は何ですか?