我有对象user
。在我看来,我可以检索user.name
user.email
等...
但是我无法检索user.service.name
,它会返回空白,而User.service.id
会返回ID。
Service
是一个对象,user
和service
与fetch eager的@ManyToOne
关系相关联。
有什么想法吗?
我上课User
Public class User extends Model {
@Id
@GeneratedValue
Public Integer id;
@Constraints.Required
@Column(nullable = false)
Public string nom;
@Constraints.Required
Public string password;
@ManyToOne
public Service service;
}
班级Service
@Entity
Public class Service extends Model {
@Id
@GeneratedValue
Public Integer id;
@Column(unique = true, nullable = false)
@Constraints.Required
public String nom;
@OneToMany(mappedBy = "service")
Public Set<User> users = new LinkedHashSet<User>();
}
在listUser.scala.html
我有这个
@for(user <- currentPage.getList) {
<tr>
<td>@user.nom</td>
<td>@user.service.nom</td>
</tr>
}