以上是JPA班级
public class UsersDaoJpa extends BaseDaoJpa<Users> implements UsersDao {
public UsersDaoJpa() {
super(Users.class, "Users");
}
@Override
public List<Users> findByRegisteredUserEmail(String emailId) {
Query query = getEntityManager().createQuery("SELECT us FROM Users AS us WHERE us.emailId =:emailId");
query.setParameter("emailId", emailId);
return query.getResultList();
}
@Override
public List<Users> findByRegisteredUserPhone(String mobileNo) {
Query query = getEntityManager().createQuery("SELECT us FROM Users AS us WHERE us.mobileNo =:mobileNo");
query.setParameter("mobileNo", mobileNo);
return query.getResultList();
}
@Override
public List<Users> FindUsersByEmailPhoneRole(String emailId, String mobileNo, String userRole) {
Query query = getEntityManager().createQuery("SELECT us FROM Users AS us WHERE us.mobileNo =:mobileNo AND us.emailId =:emailId AND us.userRole =:userRole");
query.setParameter("mobileNo", mobileNo);
query.setParameter("emailId", emailId);
query.setParameter("userRole", userRole);
return query.getResultList();
}
@Override
public List<Users> checkUserNameAvailability(String userName) {
System.out.println("the username is " + userName);
Query query = getEntityManager().createQuery("SELECT us FROM Users AS us WHERE us.userName =:userName");
System.out.println("the username2 is " + userName);
query.setParameter("userName", userName);
System.out.println("the username3 is " + userName);
return query.getResultList();
}
@Override
public List<Users> checkEmailNMobileVerificationByUname(String userName, Boolean bolVal) {
Query query = getEntityManager().createQuery("SELECT us FROM Users AS us WHERE us.userName =:userName AND us.mobileVerifyStatus =:bolVal AND us.emailVerifyStatus =:bolVal");
query.setParameter("userName", userName);
query.setParameter("bolVal", bolVal);
return query.getResultList();
}
}
上面是针对我的数据库表的域类或实体类
@Entity
@Table(name = "users")
public class Users extends BaseDomain {
private static final long serialVersionUID = 1L;
@Basic(optional = false)
@Column(name = "full_name")
private String fullName;
@Basic(optional = false)
@Column(name = "email_id")
private String emailId;
@Basic(optional = false)
@Column(name = "mobile_no")
private String mobileNo;
@Basic(optional = false)
@Column(name = "dob")
@Temporal(TemporalType.DATE)
private Date dob;
@Basic(optional = false)
@Column(name = "user_name")
private String userName;
@Basic(optional = false)
@Column(name = "password")
private String password;
@Basic(optional = false)
@Column(name = "email_verify_code")
private String emailVerifyCode;
@Basic(optional = false)
@Column(name = "mobile_verify_code")
private String mobileVerifyCode;
@Basic(optional = false)
@Column(name = "email_verify_status")
private boolean emailVerifyStatus;
@Basic(optional = false)
@Column(name = "mobile_verify_status")
private boolean mobileVerifyStatus;
@Basic(optional = false)
@Column(name = "user_role")
private String userRole;
@Basic(optional = false)
@Column(name = "login _utc")
@Temporal(TemporalType.TIMESTAMP)
private Date loginUtc;
@Basic(optional = false)
@Column(name = "registration_utc")
@Temporal(TemporalType.TIMESTAMP)
private Date registrationUtc;
@Basic(optional = false)
@Column(name = "is_approved")
private boolean isApproved;
@Basic(optional = false)
@Column(name = "is_blocked")
private boolean isBlocked;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "userId")
private Collection<AdvisorDocument> advisorDocumentCollection;
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getEmailId() {
return emailId;
}
public void setEmailId(String emailId) {
this.emailId = emailId;
}
public String getMobileNo() {
return mobileNo;
}
public void setMobileNo(String mobileNo) {
this.mobileNo = mobileNo;
}
public Date getDob() {
return dob;
}
public void setDob(Date dob) {
this.dob = dob;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmailVerifyCode() {
return emailVerifyCode;
}
public void setEmailVerifyCode(String emailVerifyCode) {
this.emailVerifyCode = emailVerifyCode;
}
public String getMobileVerifyCode() {
return mobileVerifyCode;
}
public void setMobileVerifyCode(String mobileVerifyCode) {
this.mobileVerifyCode = mobileVerifyCode;
}
public boolean getEmailVerifyStatus() {
return emailVerifyStatus;
}
public void setEmailVerifyStatus(boolean emailVerifyStatus) {
this.emailVerifyStatus = emailVerifyStatus;
}
public boolean getMobileVerifyStatus() {
return mobileVerifyStatus;
}
public void setMobileVerifyStatus(boolean mobileVerifyStatus) {
this.mobileVerifyStatus = mobileVerifyStatus;
}
public String getUserRole() {
return userRole;
}
public void setUserRole(String userRole) {
this.userRole = userRole;
}
public Date getLoginUtc() {
return loginUtc;
}
public void setLoginUtc(Date loginUtc) {
this.loginUtc = loginUtc;
}
public Date getRegistrationUtc() {
return registrationUtc;
}
public void setRegistrationUtc(Date registrationUtc) {
this.registrationUtc = registrationUtc;
}
public boolean getIsApproved() {
return isApproved;
}
public void setIsApproved(boolean isApproved) {
this.isApproved = isApproved;
}
public boolean getIsBlocked() {
return isBlocked;
}
public void setIsBlocked(boolean isBlocked) {
this.isBlocked = isBlocked;
}
public Collection<AdvisorDocument> getAdvisorDocumentCollection() {
return advisorDocumentCollection;
}
public void setAdvisorDocumentCollection(Collection<AdvisorDocument> advisorDocumentCollection) {
this.advisorDocumentCollection = advisorDocumentCollection;
}
}
并且它抛出的错误是它的一个mysql sysntax错误异常。但据我说,代码应该正常工作,但不知道为什么它不起作用。 抛出的错误如下