This question already has an answer here:
- How do I compare strings in Java? 23 answers
so this is an odd one and I don't know if I am having a bad day and over looking something silly or what.
I have the following Affidavit Class
package com.cgsinc.dal.aba.model.program;
import com.cgsinc.dal.user.model.Attendee;
import com.cgsinc.dal.utils.AbstractAuditable;
import com.google.common.collect.Sets;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.Where;
import org.hibernate.envers.Audited;
import javax.persistence.*;
import java.util.Set;
@Audited
@Entity
@Table(name = "registrant_affidavit", schema = "aba_mcle")
@DynamicUpdate
@Where(clause = "is_active <> 'N'")
public class RegistrantAffidavit extends AbstractAuditable<Attendee> {
@OneToOne(fetch=FetchType.LAZY)
private Program program;
@ManyToOne(fetch=FetchType.LAZY)
private ProgramReconciliationRegistrant programReconciliationRegistrant;
@Column(name="is_complete",columnDefinition="CHAR(1) DEFAULT 'N'")
@Type(type="yes_no")
private boolean complete;
@Column(columnDefinition="CHAR(1) DEFAULT 'N'")
@Type(type="yes_no")
private boolean attested;
@OneToOne(fetch=FetchType.LAZY)
private ProgramSelectedDeliveryMethod programSelectedDeliveryMethod;
private String status;
public RegistrantAffidavit() {
}
public String getStatus(){
return status;
}
public void setStatus(String status){
this.status = status;
}
public ProgramSelectedDeliveryMethod getProgramSelectedDeliveryMethod() {
return programSelectedDeliveryMethod;
}
public void setProgramSelectedDeliveryMethod(ProgramSelectedDeliveryMethod programSelectedDeliveryMethod) {
this.programSelectedDeliveryMethod = programSelectedDeliveryMethod;
}
public void setProgram(Program program){
this.program = program;
}
public Program getProgram(){
return program;
}
public boolean isComplete() {
return complete;
}
public void setComplete(boolean complete) {
this.complete = complete;
}
public boolean isAttested() {
return attested;
}
public void setAttested(boolean attested) {
this.attested = attested;
}
public ProgramReconciliationRegistrant getProgramReconciliationRegistrant() {
return programReconciliationRegistrant;
}
public void setProgramReconciliationRegistrant(ProgramReconciliationRegistrant programReconciliationRegistrant) {
this.programReconciliationRegistrant = programReconciliationRegistrant;
}
}
In one of my Controllers I Have the following code
//Find the affidavit by the ID sent in URL
RegistrantAffidavit affidavit = affRepo.findOne(affidavitIdUUID);
String currentStatus = affidavit.getStatus();
logger.debug("Current Status :: " + currentStatus);
if (currentStatus == "Saved") {
logger.debug("STATUS WAS SAVED");
}
It will currently print out
Current Status :: Saved
but it doesn't enter the if block like I expect
if I manually create a string and assign it like
String currentStatus = "Saved"
then the if block will get entered.
I am not seeing where my issue is. my getStatus() function returns a string. The string has a value of "Saved" so why is the If block not getting entered?
any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire