2

I've been using Scala for about 6 months, but just getting into the Lift framework. In the Lift docs, it is mentioned that although the default Mapper stuff is provided, one can use any ORM (or similar).

Are there any good examples (uncommented source is OK) of using an alternate ORM with Lift? I'm interested in using ScalaQuery, but am open to suggestions. My only requirement is that the lib has to support MSSQL. From what I've seen, this boils down to using the JTDS JDBC driver and you're off to the races.

Connor Doyle
  • 1,812
  • 14
  • 22
  • I don't really understand what you want to do. Do you want to use different tools than Mapper's ones to perform some queries? – Christopher Chiche Jan 18 '12 at 18:48
  • @ChrisJamesC yes for the most part. I was just curious about what issues would arise and if there exists a good explanation of all the moving parts involved. The answer below from hedefalk is pretty much what I was looking for. Sorry if it was too vague to have a specific answer. – Connor Doyle Jan 19 '12 at 01:22

1 Answers1

4

If you want to use an ORM in Lift other than Mapper, I would suggest checking out SquerylRecord. This should be a good starting point: http://www.assembla.com/spaces/liftweb/wiki/Squeryl

I wouldn't really consider ScalaQuery an ORM, but rather a Scala DSL for SQL queries. However, I think it's a really nice option if you don't need an ORM. Also check out the work being done with Scala Integrated Query: http://days2011.scala-lang.org/node/138/279. I don't think it's ready for production use yet though.

Viktor Hedefalk
  • 3,572
  • 3
  • 33
  • 48
  • 1
    FWIW, I actually disagree with this; ScalaQuery is (IMO) superior to Squeryl. That might be a matter of taste, but you don't need anything specific to use a database layer with Lift. – timothy Jan 20 '12 at 12:05
  • Record is pretty broken/unfinished still, so you gain very little by using SquerylRecord. Squeryl is full of arbitrary limitations and makes all sorts of bad assumptions about your database that makes it very hard to deal with. It also does far less to provide type safety. Rolling our own model objects using ScalaQuery was so much easier than trying to wrestle with squeryl's limitations all the time. – Some Guy Jan 20 '12 at 17:09
  • I've coded up little examples in each and I came to a similar conclusion. I like ScalaQuery's syntax and it seems like less voodoo to get it talking to the DB. SquerylRecord was informative to look at though. – Connor Doyle Jan 21 '12 at 18:00
  • 1
    Tim, I'm not sure what in my answer you disagree with? I'm not saying that Squeryl is a better option than ScalaQuery, just that if he need an ORM he could look at SquerylRecord. As far as I know there's really no Lift-ORM for ScalaQuery? I wouldn't even consider Squeryl an ORM, but Squeryl has some ORM-features though (stateful relations) which ScalaQuery doesn't, right? – Viktor Hedefalk Jan 22 '12 at 13:17