tags:

views:

650

answers:

6

I'm considering taking up scala programming but i'm really concerned about what will become of my ORM based applications. I currently use hibernate as my ORM and i find it a really reliable tool. I'd like to know if there's any ORM tool as efficient but written in scala, or will hibernate work seamlessly with it. i don't want to have to start writing endless sql queries again (like the days of JDBC). I also have the same thought about erlang. is there a good orm out there for erlang?? and can i use erlang with other DBMS like oracle and mysql with ORM

+3  A: 

Why not make use of the fact that you can use standard Java libraries with Scala, and thus use Hibernate within Scala ?

Brian Agnew
ok.. good suggestion.. but how about all the concurrency i hear scala will provide? will this blend well with the existing hibernate architecture?? and is there anything like this in erlang??
Emotu Balogun
Scala concurrency is (I understand) based on the VM threading, so it should be no different to a threaded model with Hibernate. I confess this is speculation on my part.
Brian Agnew
Hibernate works with Scala extremely well (make sure you use annotations). You're *much* better off going with hibernate than one of the half cooked Scala ORMs floating around, speaking as a person who's been burnt.
Michael
+3  A: 

I'm not aware of any ORM written in Scala. M. Odersky's book Programming in Scala has some code for what's essentially a DSL wrapping JDBC, but that wouldn't really qualify for you.

But as Brian says, Scala is compatible with Java to a large extent, so you can (mostly) just use Java libraries from Scala.

Here's an article that says "Generally, Hibernate and Scala work together very easily." There is a "But..." following though. http://www.artima.com/forums/flat.jsp?forum=276&thread=222229 One particular problem found was that annotations aren't yet fully supported in Scala (this may have been fixed in the recent 2.8 upgrade).

On the whole, though, if these people got it working then you should be able to manage too.

I'd be a little less optimistic about Erlang, to put it mildly. Erlang is not a JVM language, and it's significantly different from Java, unlike Scala. But to be honest, that's about all I can say on the subject as I'm not an Erlang programmer.

Carl Smotricz
A: 

Hibernate will work from scala without much difficulty once you've gotten used to the slightly different syntax.

One of the great benefits of switching to scala from java is that initially you can start using scala as a more succinct version of java and gradually move toward more idiomatic use of scala.

Using hibernate, you'll be restricted to the traditional ORM approach of having mutable objects that keep track of modifications for when they need to be persisted.

A more functional approach might involve immutable objects but there don't appear to be any ORM implementations specifically for scala. scalaz (http://code.google.com/p/scalaz/) contains some functionality for wrapping JDBC but has some fairly sparse documentation at this stage.

The lift web development framework (http://liftweb.net/) contains an orm but I'm not sure how easily that could be used in isolation.

Mark Ryall
+3  A: 

Erlang isn't object oriented so why would you want to try and shoehorn something as hacky as an ORM library, which all of them all because there is a severe impedance mismatch between Relational Databases and OO. The same mismatch would be there as well with Erlang. Mnesia is more of a hierarchical database and that model works well with a functional language like Erlang. ORM libraries are not the end all be all, especially not for Erlang.

fuzzy lollipop
When I hear about Erlang and databases, the name I most frequently come across is Mnesia. I also ran into an interesting other product, ErlyDB, an Erlang DB wrapper generator.
Carl Smotricz
You've got a point when you say Erlang isn't OO. What i really would like to know is if i'd still have to churn out sql queries within my erlang functions once i get started with erlang. the major attraction for me in ORM's like hibernate is the fact that i can actually generate all my database tables and java objects in one shot. is there something that does this in erlang??
Emotu Balogun
+1  A: 

If you are thinking about Erlang, CouchDB is probably the way to go. I would HATE having to deal with a relational database from a functional language with immutable data structures.

jdc0589
could you explain why whould you hate to deal with a relational detabase from a functional langauge with immutable DSs and what is the alternative then?
Alexey
+1  A: 

Take a look at Circumflex. An ORM written in Scala for Scala.

Hugo Palma