如何使用新的Scala 2.8.0嵌套的注解 [英] how to use new scala 2.8.0 nested annotations
本文介绍了如何使用新的Scala 2.8.0嵌套的注解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
看起来像斯卡拉时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'")
})
推荐答案
您必须包装元素在阵列()
,写嵌套注释就像一个构造函数调用
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屋!
查看全文