我已将我的关系 bbdd 表映射到 Java 对象。
@Entity
@Table(name = "user")
public class User implements Serializable{
// Another attributes...
@OneToOne
@JoinColumn(name = "id")
private UserAccount userAccount;
// Getters and setters...
}
@Entity
@Table(name = "user_account")
public class UserAccount implements Serializable{
@Id
@GenericGenerator(name = "generator", strategy = "foreign",
parameters =
@Parameter(name = "property", value = "user"))
@GeneratedValue(generator = "generator")
@Column(name = "user_id", unique = true, nullable = false)
private int user_id;
// Another attributes...
// Getters and setters...
}
我有一个这样的标准。
Criterion crit = Restrictions.and(
Restrictions.like("userAccount.email", email),
Restrictions.like("userAccount.password", MD5.crypt(password)));
但我得到这个错误。
org.hibernate.QueryException: could not resolve property: User of: com.mypackage.entity.User
如何通过标准从用户访问 UserAccount.email?