aspose file tools*
The moose likes Scala and the fly likes Lift and database access? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Scala
Bookmark "Lift and database access?" Watch "Lift and database access?" New topic
Author

Lift and database access?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61232
    
  66

One of the things I really like about Play!, and the reason used I used it for a handful of projects despite the many things that I don't like about Play!, is its fairly seamless integration with Hibernate/JPA that factors away most of the pain of dealing with databases.

How does Lift fare in this space?

Nothing drives me crazier than having to deal with JPA and Hibernate nonsense.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Timothy Perrett
author
Greenhorn

Joined: Nov 21, 2011
Posts: 19
Bear Bibeault wrote:One of the things I really like about Play!, and the reason used I used it for a handful of projects despite the many things that I don't like about Play!, is its fairly seamless integration with Hibernate/JPA that factors away most of the pain of dealing with databases.

How does Lift fare in this space?

Nothing drives me crazier than having to deal with JPA and Hibernate nonsense.


Personally I avoid JPA like the plague. There is support for a more reasonable abstraction of working with JPA (chapter 13 in LIA), but you very much still know you're working with JPA. It's essentially a wrapper on JPA to give the API more of a Scala feel. Depending on how much JPA you need to use, this may or may not eliminate some of the pain.

Lift does ship with its own database layers, but you are in no way bound to use them. I typically don't use Mapper (lifts ORM) at all, rather, I use ScalaQuery when I need to interact with RDBMS. There are several very excellent database abstractions in the Scala eco-system, so it doesn't pay to be tied by the one that a particular framework brings to the table (that goes for both Lift and Play!)

Cheers, Tim
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61232
    
  66

Timothy Perrett wrote:Personally I avoid JPA like the plague.


I hear you!

Again, that's one of the things I like about Play!, except for annotating the models, you hardly know that JPA is in use.

So you are saying that the Lift/Scala ecosystem has numerous DB access choices and that you can pick the one that best suits your project or programming style?

Is there one that's similar to Play's ORM approach? Is there an even simpler (as in straight-forward) choice? Which would you use for a RESTful web service that's mostly a glorified CRUD layer?

Timothy Perrett
author
Greenhorn

Joined: Nov 21, 2011
Posts: 19
Bear Bibeault wrote:
Timothy Perrett wrote:Personally I avoid JPA like the plague.

So you are saying that the Lift/Scala ecosystem has numerous DB access choices and that you can pick the one that best suits your project or programming style?


Yup this is exactly what I'm saying.

Bear Bibeault wrote:
Timothy Perrett wrote:Personally I avoid JPA like the plague.

Is there one that's similar to Play's ORM approach? Is there an even simpler (as in straight-forward) choice? Which would you use for a RESTful web service that's mostly a glorified CRUD layer?


Similar to AnORM? I don't think so. Personally I don't like that kind of approach as I prefer something typesafe like ScalaQuery which is the absolute awesome :-)

Cheers, Tim

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61232
    
  66

I'm all ears -- can you give a capsule summary of the ScalaQuery approach and what makes ScalaQuery so awesome?

(DB access has always been a thorn in my side, so I'm always looking for better ways.)

Timothy Perrett
author
Greenhorn

Joined: Nov 21, 2011
Posts: 19
Bear Bibeault wrote:I'm all ears -- can you give a capsule summary of the ScalaQuery approach and what makes ScalaQuery so awesome?

(DB access has always been a thorn in my side, so I'm always looking for better ways.)



Database queries using monad comprehensions... what's not to like :-D Here's an example:

for {
c <- Coffees
s <- c.supplier
_ <- Query groupBy s.id
} yield s.name.min.get ~ c.name.count

Super, super nice as its all typesafe, and if it doesn't compile, the query wouldn't run. Essentially anything that compiles is a valid query.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61232
    
  66

I don't know enough Scala (as in none) to grok what all that means, but I like "typesafe".
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Is ScalaQuery the equivalent to .NET LINQ?
Timothy Perrett
author
Greenhorn

Joined: Nov 21, 2011
Posts: 19
Hussein Baghdadi wrote:Is ScalaQuery the equivalent to .NET LINQ?


I'm not hugely familiar with link, but scalaquery only works with RDBMS, not say, XML files or whatever which I think LINQ does?
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4392
    
    8

Knowing nothing about ScalaQuery other than what's written above, it looks to me that you could possibly consider it equivalent to the LINQ to SQL (or LINQ to Entities) part of .NET. LINQ allows you to use a similar programming style against anything that has a LINQ provider - which includes XML files and the collections framework as well as databases. From the above ScalaQuery seems to allow you to use databases in a similar way to how you'd traverse and transform collections in Scala. So both technologies are letting you have common language idioms for disparate sources of data.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Lift and database access?