java—如何否定几个 predicate

mgdq6dx1  于 2021-06-30  发布在  Java
关注(0)|答案(0)|浏览(193)

我有两个实体

@Entity
@Table(name = SIGNAL")
public class TradingSignal {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID", nullable = false, unique = true)
    private int id;

    @Column(name = "SIGNAL_ID")
    private int signalId;

    @Column(name = "TICKER", length = 6)
    private String ticker;

    @OneToMany(cascade = CascadeType.ALL)
    private Set<TsUsed> tsUsedSet;
}

@Entity
@Table(name = "TS_USED")
public class TsUsed {

    @Id
    @Column(name = "FILTER_ID", nullable = false)
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int filterId;

    @Column(name = "USER_ID_LSB")
    private long userIdLsb;

    @Column(name = "USER_ID_MSB")
    private long userIdMsb;

    @Column(name = "VISIBLE")
    private boolean visible;

    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "ID", nullable = false)
    private TradingSignal tradingSignal;
}

我怎样才能找到全部 TradingSignal 在哪里 TsUsed . userIdLsb 以及 TsUsed . userIdMsb 中不存在 tsUsedSet ?
无法创建有效 predicate 。
这个代码不适合我

Join<TradingSignal, TsUsed> tsUsed = getTsUsedJoin(root);
    Predicate predicateUserIdLsb = builder.equal(tsUsed.get("userIdLsb"), userId.getLeastSignificantBits());
    Predicate predicateUserIdMsb = builder.equal(tsUsed.get("userIdMsb"), userId.getMostSignificantBits());
    Predicate predicateInvisible = builder.isFalse(tsUsed.get("visible"));

    Predicate notInvisibleForUser = builder.and(predicateUserIdLsb, predicateUserIdMsb, predicateInvisible).not();

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题