what good orm api will work well with scala or erl

2020-07-27 23:25发布

问题:

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

回答1:

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



回答2:

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.



回答3:

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.



回答4:

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



回答5:

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.



回答6:

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.



回答7:

There's BossDB as part of ChicagoBoss, but it can be used standalone



标签: orm scala erlang