I used to have great expectations for using Hibernate with Scala.
Since Scala is a JVM language and highly Java compatible, using a Java
ORM appears to be a good choice.
However, I found one huge problem when trying to use that combination:
Scala has different collection types than Java. Hibernate expects
mapped members to be, for example, of type java.util.Set . It's not
really possible to introduce the Scala collection types as so-called
UserCollectionTypeinstances.
I summed up my problems and questions in this thread at the Hibernate
forums:
https://forum.hibernate.org/viewtopic.php?f=1&t=1003746
Please refer to that page; I would find it inappropriate to copy all
the text to this forum.
My impression is that no one at the Hibernate forums answers to Scala
related questions, and there is really no Scala related development
coming any time soon to Hibernate. So I looked around for other ORMs.
This is how I came across Ebean. I was delighted to see that there is
even a Scala example in the Ebean reference documentation. The problem
with the example is that it declares a mapped collection explicitly as
java.util.List .
In the Hibernate forum article above, I wrote why I think it's not
that great an idea to be forced to use Java collection types in ORM-
able objects. And I also wrote down which ideas I see for a possible
solution. Since I got no response from the Hibernate forum, I thought
maybe I could use Ebean.
So, with reference to the Hibernate forum thread linked above, my
question is: Do you see a possibility that the problems which I have
with Scala+Hibernate might be solvable with Scala+Ebean?
Thanks for your attention.
Madoc.
--
To unsubscribe, reply using "remove me" as the subject.
This is a bit off topic, but I'm wondering what it means to call Ebean
"JPA compliant"?
/Daryl
--
On Apr 11, 5:26 pm, Rob Bygrave <robin.bygr...@gmail.com> wrote:
> Interestingly, this issue can up amongst the Ebean 'committers' just
> recently (whether to support a JPA EntityManager etc).
Noooooooooooooooooooo! If this comes up for a vote I'll use all my
credits against it! :-)
> Ebean does want to use the same JPA Mapping and does want to be as similar
> as possible but at the same time the fundamental differences are the reason
> Ebean exists.
Exactly. That's what drew me to Ebean. I hate "attached/detached"
entities. (And the many great features has me continuing to work with
it in the hopes I can prove everything out and "sell" it to my boss.)
/Daryl
/Daryl
At the moment Ebean is not aware of the Scala collection types so not really pluggable at this point (but could be without too much effort). I think we can leave it like this for the moment and if we need this to be pluggable look at that later (we don't need this for Groovy right?).
Is there a good / best way to convert the scala mutable types to immutable ?
val y = scala.collection.immutable.Set.empty ++ x
So the current scala test code I'm using is:
[...]
Ebean is written in Java has to do the same thing using Java code. The question is, how do you do that in Java? Scala has provided the JavaConversions object to help but it doesn't cover the immutable types.
> You could of course easily convert a mutable set x to an immutable set y by calling:
val y = scala.collection.immutable.Set.empty ++ x
Note that with the mutable types they are actually wrappers around the Java ones so Ebean is literally wrapping them and then later from the scala types getting the "underlying()" java List, Set or Map. It doesn't look like similar wrapping support is available for the scala immutable collections. To me that could be a enhancement request to scala - for JavaConversion to have methods to wrap as immutable collections (and where Java code can later get back the underlying java list, set or map).
> I am really amazed by Ebeans and by your support of Scala.I think it suggests Ebean's type system is in reasonable shape which is good.
Still problems on Ebean.save():
java.lang.NoClassDefFoundError: scala/Option
at
com.avaje.ebeaninternal.server.persist.DmlUtil.isNullOrZero(DmlUtil.java:
20)
at
com.avaje.ebeaninternal.server.persist.dml.InsertHandler.bind(InsertHandler.java:
90)
at
com.avaje.ebeaninternal.server.persist.dml.DmlBeanPersister.execute(DmlBeanPersister.java:
97)
at
com.avaje.ebeaninternal.server.persist.dml.DmlBeanPersister.insert(DmlBeanPersister.java:
75)
at
com.avaje.ebeaninternal.server.persist.DefaultPersistExecute.executeInsertBean(DefaultPersistExecute.java:
100)
at
com.avaje.ebeaninternal.server.core.PersistRequestBean.executeNow(PersistRequestBean.java:
400)
at
com.avaje.ebeaninternal.server.core.PersistRequestBean.executeOrQueue(PersistRequestBean.java:
430)
at
com.avaje.ebeaninternal.server.persist.DefaultPersister.insert(DefaultPersister.java:
369)
at
com.avaje.ebeaninternal.server.persist.DefaultPersister.saveEnhanced(DefaultPersister.java:
313)
at
com.avaje.ebeaninternal.server.persist.DefaultPersister.saveRecurse(DefaultPersister.java:
283)
at
com.avaje.ebeaninternal.server.persist.DefaultPersister.save(DefaultPersister.java:
267)
at
com.avaje.ebeaninternal.server.core.DefaultServer.save(DefaultServer.java:
1480)
at
com.avaje.ebeaninternal.server.core.DefaultServer.save(DefaultServer.java:
1470)
at com.avaje.ebean.Ebean.save(Ebean.java:535)
Rien