RealmQuery也获取具有null值的记录

时间:2018-01-31 12:05:20

标签: android realm

我有RealmClass ProspectGson as,

public class ProspectGson extends RealmObject
{
    public ProspectMaster prospectMaster;
    public RealmList<ContactDetail>  contactDetails=new RealmList<>();
    public RealmList<DiscussionDetail> discussionDetail=new RealmList<>();
    @PrimaryKey
    public long id;
}

班级ProspectMaster as,

public class ProspectMaster extends RealmObject
{
     private long ProspectId;
    private String ProspectCode;
    private String ProspectName;
    private String TrustName;
}

班级DiscussionDetail as,

public class DiscussionDetail extends RealmObject
{

    private long RecId;
    private long ProspectId;
    private String    DiscussionDetails;
    private  String    CallPriority;
}

我的领域查询是,

RealmResults results= realm.where(ProspectGson.class)
        .contains("prospectMaster.ProspectName", "abv", Case.INSENSITIVE)
        .contains("prospectMaster.TrustName", "xyz", Case.INSENSITIVE)
        .contains("discussionDetail.CallPriority", "High", Case.INSENSITIVE)
        .findAll();

我有很多ProspectGson的记录,其中一些包含多个DiscussionDetail,有些记录没有DiscussionDetail

我想要提取包含ProspectGson DisucssionDetailCallPriority的所有high条记录,并记录哪些记录没有DiscussionDetail

目前我正在收到ProspectGson CallPriority high.

String tmp = "begin ? := pkgioexportora.request(?); end;"; String xml = "<ttc.export.public.data.search><query><popid>1</popid> <moduleid>3</moduleid><only_changes>0</only_changes></query></ttc.export.public.data.search>"; CallableStatement callableStmt = oracle.prepareCall(tmp); // Register the type of the out param - an Oracle specific type callableStmt.registerOutParameter(1, OracleTypes.NUMBER); callableStmt.setString(2, xml); 条记录

请帮帮我

1 个答案:

答案 0 :(得分:2)

RealmResults<ProspectGson> results= realm.where(ProspectGson.class)
        .isNotEmpty("discussionDetail")
        .contains("discussionDetail.CallPriority", "High", Case.INSENSITIVE)
        .findAll();

请尝试