3

I am using Squeryl as an ORM with MySQL. This is a new project working with existing schemas that contain several hundred tables.

As far as I can tell, neither Squeryl nor any of the available Scala ORMs can generate the O (Scala classes) from the R (mysql tables). I suppose it wouldn't be too hard to roll my own by crawling the information schema, but I'd rather not duplicate that effort if someone else has already done so.

I'm also curious if anyone can tell me why the R->O direction is so often neglected. In my experience, O->R is the exception and not the rule.

I'll probably start down the path of rolling my own solution. If that's anywhere near complete before I hear of another option, I'll post a link to that code.

Thanks.

Adam Pingel
  • 681
  • 4
  • 19

3 Answers3

3

QueryDSL provides you with a utility, that can generate code from existing tables. You would however need to accept, that it's primarily a Java lib, and Scala is treated only as an extension there.

I guess the support for R-O is just a matter of time and users' feedback.

Przemek Pokrywka
  • 2,219
  • 17
  • 23
2

There is Squealer which does query database tables and generate scala code. It uses Squeryl and other libraries.
I managed to use it with minimal tweaking.

Its gitub is here

Darian
  • 21
  • 1
1

I'm curious what type of projects you are working on where you've found R->O to be the rule. My experience, and I'm including not just my own projects but those that other Squeryl users have mentioned on the mailing list, is that most Squeryl projects are predominantly new applications where an SQL database is being used to persist an application specific model rather than a model being created to match an existing schema. Like most OS projects the developers tend to focus first on features that they themselves need and second on features that are most requested by the community so I would encourage you to take this up at the Squeryl Google Group as well.

Dave Whittaker
  • 3,102
  • 13
  • 14
  • Will go both ways: you'll inherit an existing schema or have the freedom to create DB from scratch. AR migrations, wonderful. LINQ-to-SQL code generator is nice as well. On the flip side Grails ORM provides an excellent DSL for DB schema generation. Scala equivalents are way behind AR, LINQ-to-SQL (now EF) and GORM. It's early days for Scala ORMs, however; Squeryl and ScalaQuery are the frontrunners. Would love to see a full blown Scala LINQ-to-SQL with migrations -- essentially a best of breed typed ORM without the boilerplate and performance overhead normally associated with the term – virtualeyes Dec 06 '11 at 22:40