I have an table in database that contains 3 values did, pid and fid. which is something like below:
---------------------
| did | fid | pid |
--------------------|
| 259 | 431 | 128 |
--------------------|
| 259 | 431 | 132 |
|-------------------|
| 260 | 432 | 128 |
--------------------|
| 260 | 432 | 129 |
|-------------------|
| 260 | 432 | 132 |
|-------------------|
| 261 | 460 | 128 |
--------------------|
| 261 | 460 | 132 |
|-------------------|
Now if any new entry comes up. I want to check in table where it exists or not. None of them is unique. In the response one must be uniuqe all of them can not be same for new entry.
I am using currently double for loop
which is not working.
Thanks in advance
EDITED
public class DetailingTripleCheck {
private int nid;
private int did;
private int fid;
public DetailingTripleCheck() {
// TODO Auto-generated constructor stub
}
public DetailingTripleCheck(int nid, int did, int fid) {
this.nid = nid;
this.did = ddnid;
this.fid = fid;
}
public int getNid() {
return nid;
}
public void setNid(int nid) {
this.nid = nid;
}
public int getDid() {
return did;
}
public void setDid(int did) {
this.did = did;
}
public int getFid() {
return fid;
}
public void setFid(int fid) {
this.fid = fid;
}
@Override
public boolean equals(Object o) {
// TODO Auto-generated method stub
return super.equals(o);
}
@Override
public int hashCode() {
// TODO Auto-generated method stub
return super.hashCode();
}
}
Where i am using this class:
for (int i = 0; i < NewDids.length; i++) {
if (OldDids.length > 0) {
DetailingTripleCheck ddSet = new DetailingTripleCheck();
ddSet.setDdnid(Integer.parseInt(NewDids[i]));
ddSet.setProdNid(Integer.parseInt(NewNids[i]));
ddSet.setFid(Integer.parseInt(Newfids[i]));
HashSet<DetailingTripleCheck> set = new HashSet<DetailingTripleCheck>();
for (int j = 0; j < OldDids.length; j++) {
DetailingTripleCheck triple = new DetailingTripleCheck(
Integer.parseInt(OldDids[j]),
Integer.parseInt(OldNids[j]),
Integer.parseInt(OldFids[j]));
if (set.contains(triple)) {
System.out.println("TRUE");
} else {
System.out.println("FALSE");
}
}
}