0

我在 User 和 Context 类之间有一个 ManyToMany 关系,中间表中有一个额外的列。

用户.java

@Entity
@Table(name = "USERS")
public class Users {
    private Long user_id;
    private Long niu;
    private String nom;
    private String mail;
    private Set<UserContext> userContexts  = new HashSet<UserContext>(0);

上下文.java

@Entity
@Table(name = "CONTEXT")
public class Context {
    private Long id;
    private String name;
    private Area area;
    private String code;
    private Set<UserContext> userContexts = new HashSet<UserContext>(0);

用户上下文.java

@Entity
@Table(name = "USER_CTX")
@AssociationOverrides({
        @AssociationOverride(name = "pk.user",
            joinColumns = @JoinColumn(name = "USER_ID")),
        @AssociationOverride(name = "pk.context",
            joinColumns = @JoinColumn(name = "CTXT_ID")) })
public class UserContext implements Serializable{

    private static final long serialVersionUID = 1L;
    private UserContextID pk = new UserContextID();
    private String admin;

用户上下文ID.java

@Embeddable
public class UserContextID implements Serializable {

    private static final long serialVersionUID = -9120607274421816301L;
    private Users user;
    private Context context;

我有一张使用 JPAContainer 填充的表格,

private JPAContainer<Users> persons =
    JPAContainerFactory.make(Users.class, PERSISTENCE_UNIT);

实际上它显示了所有用户(没有按上下文过滤),我想要的是使用这种多对多关系按具体上下文 id 过滤,知道吗?我曾尝试使用 JoinFilters 但我无法得到它,请帮助我!

提前致谢!

4

1 回答 1

0

您可以使用过滤器,使用点符号选择正确的子属性,例如

entityContainer.addContainerFilter(new Like("listOfAnotherEntity.type", "TYPE1"));
于 2014-10-31T15:51:04.017 回答