Closest equivalent to SQLAlchemy for Java/Scala [closed]

One of the notable things about SQLAlchemy is that it makes tables first class objects. Thus the core API is really written around table objects, and the API therefore is essentially relational in nature. Thus at this level even if the API is OO, it is essentially reflecting RDBMS objects or functions such as Tables, Columns, Relationships, Joins, Aliases etc. At this level SQLAlchemy gives you essentially a OOSQL where SQL and Relational Databases are not given the second class treatment. Its also at this that SQLAlchemy really shines since this level of abstraction gives you an ability to step down to a bit of a “raw” relational level and thus gain enormous amounts of flexibility which I really haven’t seen any other ORM offer. Interestingly some of the underlying capabilities that are required to model class inheritance in ORMs are implemented at this layer eg. Joined Table Inheritance http://docs.sqlalchemy.org/en/rel_0_7/orm/inheritance.html#joined-table-inheritance

The API that is more often used (at least lately) is the declarative API which is really a lot more OO and maps objects in the business domain to the objects I referred to above (in most cases transparently). Here’s where the ORM functionality comes in and the API is a little bit more similar to other ORM APIs where one works with domain objects and these actions get translated into the underlying table actions directly.

To the best of my awareness, ORMs in Scala are still playing catch-up to what is easily available in Java (eg. inheritance) even as they offer other capabilities (eg. type safety, LINQ like constructs), even as they struggle with some serious issues like 22 column limitations. (I’ve read comments where few have wondered why anyone would need more than 22 columns, and at least in my experience there are situations I wouldn’t call rare, where one needs a multiple of that).

ORMs in scala (even as they take on a different flavour from Java) I think are still catching up to whats required. With respect to SQLAlchemy, is there a close enough equivalent to it I’ve seen in Java or Scala? I haven’t seen any.

EDIT: One thing I forgot to add, is that even if one uses the declarative API, SQLAlchemy still gives you direct access to the underlying objects. So if “class Foo” is mapped declaratively, Foo.__table__ is the table object that you can directly use if you so desire.

Leave a Comment