1

我有对象user。在我看来,我可以检索user.name user.email等...但我无法检索user.service.name,它返回空白而User.service.id返回 id 正确。

Service是一个对象,user并且service@ManyToOnefetch 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>

}
4

0 回答 0