how to use new scala 2.8.0 nested annotations

梦想与她 提交于 2019-12-04 21:02:30

问题


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'")
})

回答1:


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'")
))


来源:https://stackoverflow.com/questions/3376441/how-to-use-new-scala-2-8-0-nested-annotations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!