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