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

Re: Default field annotation?

No replies
Roland RECKEL
Joined: 2010-05-19,
User offline. Last seen 42 years 45 weeks ago.
Thanks for the reply!I noticed that I was wrong! So sorry for that!!
Thanks for the suggestion of type aliases! With your help, the refactoring was quite easy!!
Roll
On 29 juil. 2010, at 11:43, Lukas Rytz wrote:
Hi Roll,
It's expected behavior (it was a bug in the 2.8.0.beta). The reason is that in
   case class Test(@Id val id: Long = 0l)
`id` is a parameter, not a field.
I'd recommend defining a type alias somewhere in your project
object jpaAnnots {  type Id = presistence.Id @field}
and then `import jpaAnnots._` instead of the original annotation classes.
Cheers: Lukas

On Thu, Jul 29, 2010 at 10:46, Roland RECKEL <rreckel@vdl.lu> wrote:
Hi all,
I have a little problem with scala 2.8.0 (I used 2.8.0.beta before)
I have the following Hibernate entity case class:
@Entitycase class Test(
  @Id  val id: Long = 0l) extends Serializable {  def this() = this(0l)}
I 2.8.0.beta this worked perfect, because the annotations are attached to the private field (so no need for getter/setter methods for Hibernate). Now with 2.8.0 Hibernate throws an AnnotationException saying; "No identifier specified for entity"and so I have to explicitly tell scala to annotate the field:
@Entitycase class Test(
  @(Id @field)  val id: Long = 0l) extends Serializable {  def this() = this(0l)}
Is this the expected behavior?The documentation http://www.scala-lang.org/sid/5 seems to say that by default the field should be annotated!
Thanks for replies/help
Roll


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