Я запускаю запрос через Hibernate, и он возвращает список.Но список содержит объекты вместо моих сущностей ... Я не профессионал в Hibernate, но другие мои запросы работают хорошо.Я понятия не имею, в чем моя ошибка сейчас.
List getAllUsersBasedOnMandant(Long id) {
List users = null;
try {
startOperation(false);
Query query = getSession().createQuery(" from UserEntity where mandant = '" + id + "'");
users = query.list();
} catch (HibernateException e) {
handleException(e);
} finally {
getSession().close();
}
return users;
}
Мой вывод выглядит следующим образом:
[int_plan.entity.UserEntity@4b82b237, int_plan.entity.UserEntity@7141a0bb, int_plan.entity.UserEntity@65b0a12c]
Моя сущность выглядит так:
@Entity
@Table(name = "user", schema = "entw_pares")
public class UserEntity {
@Expose() private Long userId;
@Expose() private String gender;
@Expose() private String firstname;
@Expose() private String lastname;
@Expose() private String username;
@Expose() private String email;
private String password;
private String secQuestion;
private String secAnswer;
private String saltAnswer;
private String salt;
private String emailValidationCode;
private Long expireTime;
private Boolean emailEnable = false;
@Expose() private Timestamp dateCreated;
@Expose() private Timestamp dateUpdated;
private Boolean admin = false;
private MandantEntity mandantEntity;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_id", nullable = false)
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
@Basic
@Column(name = "gender", nullable = false)
public String getGender() { return gender; }
public void setGender(String gender){
this.gender = gender;
}
@Basic
@Column(name = "firstname", nullable = false)
public String getFirstname() { return firstname; }
public void setFirstname(String firstnme) { this.firstname = firstnme; }
@Basic
@Column(name = "lastname", nullable = false)
public String getLastname() { return lastname; }
public void setLastname(String lastname) { this.lastname = lastname; }
@Basic
@Column(name = "username")
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@Basic
@Column(name = "email", nullable = false)
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Basic
@Column(name = "password", nullable = false)
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Basic
@Column(name = "sec_question")
public String getSecQuestion() { return secQuestion; }
public void setSecQuestion(String sec_question) { this.secQuestion =
sec_question; }
@Basic
@Column(name = "sec_answer")
public String getSecAnswer() { return secAnswer; }
public void setSecAnswer(String secAnswer) { this.secAnswer = secAnswer; }
@Basic
@Column(name = "salt_answer")
public String getSaltAnswer() { return saltAnswer; }
public void setSaltAnswer(String saltAnswer) { this.saltAnswer = saltAnswer;
}
@Basic
@Column(name = "salt")
public String getSalt() {
return salt;
}
public void setSalt(String salt) {
this.salt = salt;
}
@Basic
@Column(name = "email_validation_code")
public String getEmailValidationCode() {
return emailValidationCode;
}
public void setEmailValidationCode(String emailValidationCode) {
this.emailValidationCode = emailValidationCode;
}
@Basic
@Column(name = "expire_time", nullable = false)
public Long getExpireTime() {
return expireTime;
}
public void setExpireTime(Long expireTime) {
this.expireTime = expireTime;
}
@Basic
@Column(name = "email_enable")
public Boolean getEmailEnable() {
return emailEnable;
}
public void setEmailEnable(Boolean emailEnable) {
this.emailEnable = emailEnable;
}
@Basic
@CreationTimestamp
@Column(name = "date_created")
public Timestamp getDateCreated() {
return dateCreated;
}
public void setDateCreated(Timestamp dateCreated) {
this.dateCreated = dateCreated;
}
@Basic
@UpdateTimestamp
@Column(name = "date_updated")
public Timestamp getDateUpdated() {
return dateUpdated;
}
public void setDateUpdated(Timestamp dateUpdated) {
this.dateUpdated = dateUpdated;
}
@Basic
@Column(name = "admin")
public Boolean getAdmin() {
return admin;
}
public void setAdmin(Boolean admin) {
this.admin = admin;
}
public void applyValue(Field field, Object value) throws
IllegalAccessException {
field.set(this, value);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UserEntity that = (UserEntity) o;
return userId == that.userId &&
Objects.equals(gender, that.gender)&&
Objects.equals(firstname,that.firstname)&&
Objects.equals(lastname,that.lastname)&&
Objects.equals(username, that.username) &&
Objects.equals(email, that.email) &&
Objects.equals(password, that.password) &&
Objects.equals(secQuestion,that.secQuestion) &&
Objects.equals(secAnswer, that.secAnswer) &&
Objects.equals(salt, that.salt) &&
Objects.equals(emailValidationCode, that.emailValidationCode) &&
Objects.equals(emailEnable, that.emailEnable) &&
Objects.equals(dateCreated, that.dateCreated) &&
Objects.equals(dateUpdated, that.dateUpdated) &&
Objects.equals(admin, that.admin);
}
@Override
public int hashCode() {
return Objects.hash(userId, gender, firstname, lastname, username, email,
password, secQuestion, secAnswer,
salt,
emailValidationCode,
emailEnable,
dateCreated, dateUpdated, admin);
}
@ManyToOne
@JoinColumn(name = "mandant_id", referencedColumnName = "mandant_id")
public MandantEntity getMandant() {
return mandantEntity;
}
public void setMandant(MandantEntity mandant) {
this.mandantEntity = mandant;
}
Есть идеи, что я делаю неправильно?