Alex Rivera | Logout

How do I specify a static array in a Scala 2.8 annotation?

Asked 2010-03-15T15:40:16.797
11

I've been building out some annotated domain classes in Scala 2.8.0 using Hibernate Annotations 3.4.0. It's been working fine, except that there are certain annotations which take an array as a parameter. For example, here's a Java annotation that I want to express in Scala:

@OneToMany(mappedBy="passport_id", cascade=CascadeType.PERSIST)

However, the annotation requires an array/set as input:

[ERROR] .../Passport.scala:50: error: type mismatch; 
[INFO]  found   : javax.persistence.CascadeType(value PERSIST)
[INFO]  required: Array[javax.persistence.CascadeType]
[INFO]     @OneToMany(mappedBy="passport_id", cascade=CascadeType.PERSIST)

I've tried various parentheses, square/angle/curly brackets, and so on:

@OneToMany(mappedBy="passport_id", cascade=(CascadeType.PERSIST))
@OneToMany(mappedBy="passport_id", cascade=[CascadeType.PERSIST])
@OneToMany(mappedBy="passport_id", cascade=<CascadeType.PERSIST>)
@OneToMany(mappedBy="passport_id", cascade={CascadeType.PERSIST})

... but unfortunately I've reached the end of my understanding of Scala/Java annotations. Help is appreciated.

Edit
Report

1 Answer

8

From Rex Kerr:

@OneToMany(mappedBy="passport_id", cascade=Array(CascadeType.PERSIST))

This worked. Thanks.

answered 2010-03-15T16:59:20.907

Your Answer