如何使用新的scala 2.8.0嵌套注释

时间:2010-07-31 01:48:35

标签: scala persistence annotations scala-2.8 java-ee-6

看起来当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'")
})

1 个答案:

答案 0 :(得分:14)

您必须将元素包装在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'")
))