how to use new scala 2.8.0 nested annotations
Asked Answered
B

1

9

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'")
})
Brume answered 31/7, 2010 at 1:48 Comment(0)
O
14

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'")
))
Overfill answered 31/7, 2010 at 3:33 Comment(4)
so one more problem emerged: for Stateless(name="Bean") Bean{...} I' ve got error: expected start of definitionBrume
@coubeatczech for top level annotations you cannot omit the '@'. I do not know the context of that error but did you mean to write @Stateless(name="Bean") class Bean { /* ... */ }?Overfill
sorry, I wrote this without checking if the typed text corresponds the thought, and yes, I meant this: @Stateless(name="Bean") class Bean{...}Brume
Well, I wasted my 1 hour figuring this out and then I found this. Works like charm!Parashah

© 2022 - 2024 — McMap. All rights reserved.