I have written a method in Java and It returns list according to query. By mistake I wrote allotment_date to allotmentDate but it returns same list after correcting it and in mysql table fields name also allotment_date. I don't understand why allotment_date returning same list.
public List<ShareAllotment> getlis(STUDENT st, Date fromAllotDate, Date toAllotDate, Integer branch_code) {
Session session = getSessionFactory(st).openSession();
try {
Criteria criteria = session.createCriteria(Student.class);
if (fromAllotDate != null) {
criteria.add(Restrictions.ge("allotment_date", fromAllotDate));
}
if (toAllotDate != null) {
criteria.add(Restrictions.le("allotment_date", toAllotDate));
}
if(branch_code != null && branch_code > 0)
criteria.add(Restrictions.eq("branch_code", branch_code));
return criteria.list();
} finally {
session.flush();
session.close();
}
}
public List<ShareAllotment> getlis(STUDENT st, Date fromAllotDate, Date toAllotDate, Integer branch_code) {
Session session = getSessionFactory(st).openSession();
try {
Criteria criteria = session.createCriteria(Student.class);
if (fromAllotDate != null) {
criteria.add(Restrictions.ge("allotmentDate", fromAllotDate));
}
if (toAllotDate != null) {
criteria.add(Restrictions.le("allotmentDate", toAllotDate));
}
if(branch_code != null && branch_code > 0)
criteria.add(Restrictions.eq("branchCode", branch_code));
return criteria.list();
} finally {
session.flush();
session.close();
}
}
Student POGO is
@Entity(name = "student")
@Table(name = "student")
public class Student extends BaseDO{
public Student() {
}
@Column(name = "application_date")
@DateTimeFormat(pattern = "dd-MMM-yyyy")
@NotNull(message="Please enter Application Date")
private Date applicationDate;
@Column(name = "receipt_date")
@DateTimeFormat(pattern = "dd-MMM-yyyy")
@NotNull(message="Please enter Date of Receipt")
private Date dateofReceipt;
@DateTimeFormat(pattern = "dd-MMM-yyyy")
@NotNull(message="Please enter Allotment Date")
@Column(name = "allotment_date")
private Date allotmentDate;
@Column(name = "branch_code")
private Integer branchCode;
public void setApplicationDate(Date applicationDate) {
this.applicationDate = applicationDate;
}
public Date getAllotmentDate() {
return allotmentDate;
}
@Transient
public String getAllotmentDateStr() {
return allotmentDate != null ? Configuration.DATE_FORMAT.format(allotmentDate): "";
}
@Transient
public String getAllotDateShotStr() {
DateFormat df = new SimpleDateFormat("dd-MMM-yy");
return allotmentDate != null ? df.format(allotmentDate): "";
}
public void setAllotmentDate(Date allotmentDate) {
this.allotmentDate = allotmentDate;
}
public Integer getBranchCode() {
return branchCode;
}
public void setBranchCode(Integer branchCode) {
this.branchCode = branchCode;
}
}
please help me. Thanks in advance.