This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Annotations support in 2.9: documentation incorrect?

2 replies
Richard Kennard
Joined: 2011-08-14,
User offline. Last seen 42 years 45 weeks ago.

Hi guys,

Thanks for all the great work you do on Scala! You have really
invigorated the JVM languages debate over the past few years, by
providing a viable successor to Java.

I am trying to migrate my framework Metawidget (http://metawidget.org)
from Scala 2.7.2 to 2.9.0. Annotations support seems to have changed a
bit? The new support says:

"By default, field annotations are only added to the actual field, but
not to any of the accessors"

But in my tests annotations don't seem to be added to fields at all.
On the web I find blogs like this:

http://www.davidgreco.it/MySite/Blog/Entries/2011/2/16_Scala_and_JPA__a_...

Where people are explicitly saying...

@(Id @field)

...and indeed this works. But if field annotations are added to the
actual field by default, why do you need to specify @field? Shouldn't
simply @Id work?

Regards,

Richard.

rytz
Joined: 2008-07-01,
User offline. Last seen 45 weeks 5 days ago.
Re: Annotations support in 2.9: documentation incorrect?
Hi,
In your example, "id: Long" is not a field (syntactically), it's a classparameter. That's the reason.
Cheers: Lukas

On Sun, Aug 14, 2011 at 12:53, Richard Kennard <richard [dot] kennard [dot] consulting [at] gmail [dot] com> wrote:
Hi guys,

Thanks for all the great work you do on Scala! You have really
invigorated the JVM languages debate over the past few years, by
providing a viable successor to Java.

I am trying to migrate my framework Metawidget (http://metawidget.org)
from Scala 2.7.2 to 2.9.0. Annotations support seems to have changed a
bit? The new support says:

"By default, field annotations are only added to the actual field, but
not to any of the accessors"

But in my tests annotations don't seem to be added to fields at all.
On the web I find blogs like this:

http://www.davidgreco.it/MySite/Blog/Entries/2011/2/16_Scala_and_JPA__a_couple_of_hints.html

Where people are explicitly saying...

@(Id @field)

...and indeed this works. But if field annotations are added to the
actual field by default, why do you need to specify @field? Shouldn't
simply @Id work?

Regards,

Richard.

Richard Kennard
Joined: 2011-08-14,
User offline. Last seen 42 years 45 weeks ago.
Re: Annotations support in 2.9: documentation incorrect?

Terrific! Thanks so much.

Regards,

Richard.

On Aug 14, 9:27 pm, Lukas Rytz wrote:
> Hi,
>
> In your example, "id: Long" is not a field (syntactically), it's a class
> parameter. That's the reason.
>
> Cheers: Lukas
>
> On Sun, Aug 14, 2011 at 12:53, Richard Kennard <
>
>
>
> richard [dot] kennard [dot] consult [dot] [dot] [dot] [at] gmail [dot] com> wrote:
> > Hi guys,
>
> > Thanks for all the great work you do on Scala! You have really
> > invigorated the JVM languages debate over the past few years, by
> > providing a viable successor to Java.
>
> > I am trying to migrate my framework Metawidget (http://metawidget.org)
> > from Scala 2.7.2 to 2.9.0. Annotations support seems to have changed a
> > bit? The new support says:
>
> > "By default, field annotations are only added to the actual field, but
> > not to any of the accessors"
>
> > But in my tests annotations don't seem to be added to fields at all.
> > On the web I find blogs like this:
>
> >http://www.davidgreco.it/MySite/Blog/Entries/2011/2/16_Scala_and_JPA_...
>
> > Where people are explicitly saying...
>
> > @(Id @field)
>
> > ...and indeed this works. But if field annotations are added to the
> > actual field by default, why do you need to specify @field? Shouldn't
> > simply @Id work?
>
> > Regards,
>
> > Richard.- Hide quoted text -
>
> - Show quoted text -

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland