views:

1503

answers:

6

I have been toying with Scala and I was wondering if anyone had had any experience with using hibernate and mysql as a persistent store for scala objects? Does it work out of the box or is there a lot to do?

+2  A: 

I have not used Hibernate with scala directly, but I am using JPA. Hibernate provides a JPA implementation, and the way you define JPA persistent classes or Hibernate ones is not much different, so I think using Hibernate without the JPA layer is possible

robmv
+6  A: 

Most of the time, Scala + Hibernate works quite well, with minor bumps which could be overcome easily. For exmaple, when dealing with collections, Hibernate requires the use of java.util interfaces. But you could import scala.collection.jcl.Conversions._ if you want to tap on Scala's more powerful library.

You may want to check out Frank Sommers' post for more information.

shaolang
+2  A: 

There are issues. Because some features of JPA leverage nested annotations, e.g. collections, you're in trouble because Scala does not yet support nested annotations. That'll go away when 2.8 comes out.

See Wille Faler’s Blog for more on this topic plus other incompatibilities.

arcticpenguin
+3  A: 

Scala Query is not Hibernate but may be interesting.

Phil
+2  A: 

See example of mapping Option in hibernate: http://snippets.dzone.com/posts/show/10025

Alexey
A: 

Note that Scala 2.8, now in RC5 and expected to release shortly, supports nested annotations. The release has many other cool features as well.