我有对象user
。在我看来,我可以检索user.name
user.email
等...但我无法检索user.service.name
,它返回空白而User.service.id
返回 id 正确。
Service
是一个对象,user
并且service
与@ManyToOne
fetch eager 相关。
任何想法?
我有课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>
}