0
我無法檢查JPA中兩個日期的相等性。下面的比較工作正常,直到我添加出生日期。我不知道如果我的JPQL是正確的:如何檢查JPA中兩個日期的相等性
TypedQuery<Applicant> query = em.createQuery("select app "
+ "from Applicant app where "
+ "app.firstName = :firstName AND app.middleName = :middleName "
+ "AND app.lastName = :lastName"
+" AND app.dob = :dateOfBirth", Applicant.class);
query.setParameter("firstName", searchableApplicant.getFirstName().trim());
query.setParameter("middleName", searchableApplicant.getMiddleName().trim());
query.setParameter("lastName", searchableApplicant.getLastName().trim());
query.setParameter("dateOfBirth", searchableApplicant.getDob());
申請人對象屬性:
public class Applicant implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "applicant_id")
private Integer applicantId;
@Size(max = 45)
@Column(name = "first_name")
private String firstName;
@Size(max = 45)
@Column(name = "middle_name")
private String middleName;
@Size(max = 45)
@Column(name = "last_name")
private String lastName;
@Size(max = 45)
@Column(name = "maiden_name")
private String maidenName;
@Column(name = "dob")
@Temporal(TemporalType.DATE)
private Date dob;