9

看起来当 scala 2.8.0 出来时,我们可以在持久层中使用嵌套的@annotations。但是怎么做?任何人都可以将它从java转换为scala吗?谢谢。

@NamedQueries({
    @NamedQuery(name = "findAll", query="select p from Person p"),
    @NamedQuery(name = "findTheOne",
          query="select p from Person p where p.name = 'Neo'")
})

4

1 回答 1

14

您必须将元素包装在 an 中Array()并像构造函数调用一样编写嵌套注释:

@NamedQueries(Array(
    new NamedQuery(name = "findAll", query="select p from Person p"),
    new NamedQuery(name = "findTheOne",
          query="select p from Person p where p.name = 'Neo'")
))
于 2010-07-31T03:33:22.000 回答