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

Scala @BeanProperty with other annotations

1 reply
Nelson Silva
Joined: 2009-04-02,
User offline. Last seen 42 years 45 weeks ago.

Hi all,

I'm just experimenting with Scala and Seam to try and get these two to work.

I'm looking for first class support for Java annotations in order to
take advantage of all of SEAM's offerings.

I have a simple RegisterAction (ported from the SEAM examples) and I
need to b e able to inject the PersistenceContext.

If I add a @BeanProperty to the attribute:

@PersistenceContext
@BeanProperty var em:EntityManager=_;

I get a getter and setter but still JBoss complains with:

@PersistenceUnit can only be used with a set method: public void
org.jboss.seam.example.registration.RegisterAction.em_$eq(javax.persistence.EntityManager)

If on the other hand I use

var em:EntityManager=_;
@PersistenceContext
def setEm(e:EntityManager)={ em=e; }

It works but is just too verbose...

Any ideas why the first approach doesn't work ?

Regards,

Nelson Silva

Florian Hars
Joined: 2008-12-18,
User offline. Last seen 42 years 45 weeks ago.
Re: Scala @BeanProperty with other annotations

Nelson Silva schrieb:
> If I add a @BeanProperty to the attribute:
>
> @PersistenceContext @BeanProperty var em:EntityManager=_;
>
> I get a getter and setter but still JBoss complains [...]
>
> Any ideas why the first approach doesn't work ?

Because scalac doesn't put the annotations on the generated setters and
getters. It's just another case of the bug I filed today:

https://lampsvn.epfl.ch/trac/scala/ticket/1846

- Florian.

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