领域在循环

时间:2017-10-04 09:41:22

标签: android realm

我在这里有点担心,也许是我,但我似乎无法在循环中获得领域价值,让我解释一下:

我有2个真实对象:

public class jPV extends RealmObject{
@PrimaryKey
private String NUMPV;
private String NOMPV;

public jPV(){}

public jPV(String NUMPV, String NOMPV){
    this.NUMPV = NUMPV;
    this.NOMPV = NOMPV;
}

public String getNUMPV() {
    return NUMPV;
}

public void setNUMPV(String NUMPV) {
    this.NUMPV = NUMPV;
}

public String getNOMPV() {
    return NOMPV;
}

@Override
public String toString() {
    return this.NOMPV;
}

public void setNOMPV(String NOMPV) {
    this.NOMPV = NOMPV;
}}

public class jFlashLine extends RealmObject{
@PrimaryKey
private int PRIMARYKEY;
private String ANNEE;
private String MOIS;
private String PV;
private Float CA_MOIS;
private Float CA_MOIS_OBJ;

public jFlashLine(){}

public jFlashLine(int PRIMARYKEY,String ANNEE,String MOIS,String PV,Float CA_MOIS, Float CA_MOIS_OBJ){
    this.PRIMARYKEY = PRIMARYKEY;
    this.ANNEE = ANNEE;
    this.MOIS = MOIS;
    this.PV = PV;
    this.CA_MOIS = CA_MOIS;
    this.CA_MOIS_OBJ = CA_MOIS_OBJ;
}

public int getPRIMARYKEY() {
    return PRIMARYKEY;
}

public void setPRIMARYKEY(int PRIMARYKEY) {
    this.PRIMARYKEY = PRIMARYKEY;
}

public String getANNEE() {
    return ANNEE;
}

public void setANNEE(String ANNEE) {
    this.ANNEE = ANNEE;
}

public String getMOIS() {
    return MOIS;
}

public void setMOIS(String MOIS) {
    this.MOIS = MOIS;
}

public String getPV() {
    return PV;
}

public void setPV(String PV) {
    this.PV = PV;
}

public Float getCA_MOIS() {
    return CA_MOIS;
}

public void setCA_MOIS(Float CA_MOIS) {
    this.CA_MOIS = CA_MOIS;
}

public Float getCA_MOIS_OBJ() {
    return CA_MOIS_OBJ;
}

public void setCA_MOIS_OBJ(Float CA_MOIS_OBJ) {
    this.CA_MOIS_OBJ = CA_MOIS_OBJ;
}}

我试图从每个jFlashLine获取jPV.NOMPV,其中jPV.NUMPV = jFlashLine.PV

到目前为止,我正在循环使用不同的jFlashLine

val users : ArrayList<jPV?> = arrayListOf<jPV?>()
for(line in realm.where(jFlashLine::class.java).distinct("PV")){
    users.add(realm.where(jPV::class.java).equalTo("NUMPV",line.pv).findFirst())
}

事情是用户数组填充了空对象。如果计算表达式line.pv它会返回“211”并且如果我执行

realm.where(jPV::class.java).equalTo("NUMPV","211").findFirst()

它返回“NAME LASTNAME”但

realm.where(jPV::class.java).equalTo("NUMPV",line.pv).findFirst()

返回null。我真的无法理解为什么......有人帮我吗?

真诚地,Benji

1 个答案:

答案 0 :(得分:0)

好的,对不起每个人,神经,我是个白痴...... 出于信息目的,我正在寻找2小时,并没有质疑我得到的数据。事实证明,我的Web服务正在发送给我&#34; 211&#34;而不是&#34; 211&#34; ... 我的坏......