Okay - so maybe my mistake is to try using a Java ORM solution for Scala.
 :-) And maybe there are bit too much byte code weaving tricks involved
here...

What persistence solution would you advise for newbies ? The Squeryl you
mentioned ?

On Wed, Jun 15, 2011 at 19:28, Dick Wall <[email protected]> wrote:

> Well - that's a really interesting question. Certainly JPA could be
> scala-fied somehow, but that's not the reason I don't use it any more
> (I have nothing against annotations even if they sometimes look a bit
> awkward in Scala). The reason I look for other alternatives now is
> that JPA pretty much totally relies on mutable state (vars rather than
> vals) - the fields are all filled in after initial instance creation.
> Squeryl and other options in Scala opt for a more idiomatic immutable
> model (although you can make them mutable if you want), so everything
> ends up as vals or (often more usefully) lazy vals, even the results
> of relationships.
>
> This does take a little getting used to, the "new" way often involves
> making a database update through a DSL expression (like a SQL update
> statement, which leaves the original object intact and just changes
> the data in the database), and then re-querying the object to get it
> in its new state, rather than just updating fields and saving the new
> object. It's a trade-off I willingly make though for the extra safety
> and consistency of handling only immutable instances in my programs.
> It ends up being a bit like a database enforced STM. Another advantage
> is you can easily disconnect these objects from the database and hold
> them as simple in-memory representations, getting a ton of performance
> improvement by dropping all of the semaphors for updates, dirty
> caches, etc. If you need the most recent version of the object,
> requery it and get on with life.
>
> All of this suits databases with lower write and higher read ratios,
> but fortunately that's what I tend to work on.
>
> On Jun 15, 7:07 am, Jan Goyvaerts <[email protected]> wrote:
> > No problem. We're not getting any younger, are we ? ;-)
> >
> > If I'm not mistaken it was one of the things about Scala being
> appreciated
> > by Java developers. Because it felt more natural to do this in Scala.
> > Something like that anyway. But I'll have to listening again to make
> sure.
> >
> > Traits ? Is it enough to add a trait to a class to make it JPA compliant
> ?
> >
> >
> >
> >
> >
> >
> >
> > On Wed, Jun 15, 2011 at 15:47, Dick Wall <[email protected]> wrote:
> > > Gosh - Sorry Jan, I have absolutely no recollection of saying that,
> > > can someone give me a hint what my train of thought might have been.
> >
> > > I don't use JPA in Scala, as much as I liked it in Java. I use
> > > Squeryl, sometimes Querulous, and MongoDB whenever I can. I think
> > > traits can be a more natural way of mixing in persistence to a class
> > > than annotations (perhaps that's what I was thinking), but beyond that
> > > I can't imagine what I would have been thinking at the time :-).
> >
> > > Dick
> >
> > > On Jun 15, 2:37 am, Jan Goyvaerts <[email protected]> wrote:
> > > > In the aforementioned episode Dick talks about Scala being
> > > natural/intuitive
> > > > for object persistence. I assumed he meant using JPA with case
> classes.
> > > But
> > > > did he meant it that way ? In the last week I had various trials with
> > > mixed
> > > > success. I'd rather have case classes for their advantages but then
> > > there's
> > > > the tricky formatting of the annotations.
> >
> > > > Does anybody in here have a working example/doc of these
> Scala-natural
> > > > entities ? (case classes ? all in one file ? etc ...)
> >
> > > > My biggest frustration : I can't get the 2nd level caching working.
> I've
> > > > done this many times in Java. But Scala code resisted all my attempts
> so
> > > > far. Does anybody in here managed to enable the 2nd level cache ?
> Please
> > > ...
> > > > :-P
> >
> > > > Thanks !
> >
> > > > Jan
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "The Java Posse" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected].
> > > For more options, visit this group at
> > >http://groups.google.com/group/javaposse?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "The Java Posse" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/javaposse?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to