如何使用新的 scala 2.8.0 嵌套注释 [英] how to use new scala 2.8.0 nested annotations
本文介绍了如何使用新的 scala 2.8.0 嵌套注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
看起来当 scala 2.8.0 出来时,我们可以在我们的持久层中使用嵌套的 @annotations.但是如何?任何人都可以将它从java转换为scala吗?谢谢.
looks like when scala 2.8.0 is out, we can use nested @annotations in our persistence layers. But how? Can anyone please transform this from java to scala? Thanks.
@NamedQueries({
@NamedQuery(name = "findAll", query="select p from Person p"),
@NamedQuery(name = "findTheOne",
query="select p from Person p where p.name = 'Neo'")
})
推荐答案
您必须将元素包装在 Array()
中,并像构造函数调用一样编写嵌套注释:
You have to wrap the elements in an Array()
and write the nested annotations like a constructor call:
@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'")
))
这篇关于如何使用新的 scala 2.8.0 嵌套注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文