无法访问Scala中对象的属性

时间:2012-05-30 11:23:16

标签: scala jpa playframework

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

Service是一个对象,userservice与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>

}

0 个答案:

没有答案