i have a code, like this
public static Response updateDataFiles(String id, String checksum){
SessionFactory sf = HibernateUtil.getSessionFactory();
Session session = sf.openSession();
Transaction trans = session.beginTransaction();
Files files = (Files) session.get(Files.class, id);
System.out.println("checksum "+checksum);
System.out.println("checksum file "+files.getChecksumFile());
String checksumFile = files.getChecksumFile();
if(checksum == checksumFile){
System.out.println("upload success");
files.setStatusUpload(EnumStatusUpload.statusUpload.UPLOADED_AND_SUCCESS.toString());
}else{
System.out.println("upload success but checksum error");
files.setStatusUpload(EnumStatusUpload.statusUpload.UPLOADED_BUT_ERROR_CHECKSUM.toString());
}
session.update(files);
trans.commit();
session.flush();
session.close();
Response respon = new Response();
respon.status = 200;
return respon;
}
at if(checksum == checksumFile)
there's something wrong, the checksum variable and checksumFile have a same value, but if did not execute the right condition, if executed else condition.
In my log i had seen the value of checksum variable, and checksumFile like this
checksum 9d73d945294d5488056bb5da54f62e8f
checksum file 9d73d945294d5488056bb5da54f62e8f
i don't know what's wrong in my code. Can anyone help me? and sorry for my bad English