I've recently started to fell in love with SQLAlchemy. You can write clean and fast SQL statements without having to write one line of SQL. There is no need to write most of the meta configuration you would need for something like Hibernate. At work I managed to create a mapper for a table which doesn't have a primary key! I can have composite primary keys, no need to spread an id column over all tables if you have a real primary key. And its autoload feature really works, at least for the Oracle engine. Is there any ORM out there which has the same capabilities? Till now I haven't found one.
Do you mean, for a non-Python environment? With Python, you could just use SQLAlchemy with Elixir (or the declarative layer included with SQLAlchemy itself) - this gives you the ability to easily work with objects persisted via SQLAlchemy.
You can use the Django ORM as a stand alone solution, without all the rest of the Django framework. It has very similar capabilities. Together with South of Django-migrations this is very nice.
I haven't seen anything other than Hibernate that has capabilities similar to SQLAlchemy. This is not entirely accidental as SQLAlchemy has been heavily influenced by Hibernate (although not completely). Hibernate's HQL allows pretty good expression support and it allows a decoupled datamapper pattern, lots of flexibility about primary keys and collections, and eager loading of collections via joins - SQLA's eager loading in particular as well as its "cascade" feature were inspired by that of Hibernate. At a nuts and bolts level, SQLAlchemy's approach of actually loading collections and related items into an object's __dict__
, as opposed to proxying attributes which perform a load everytime (which is what SQLObject and Storm do), makes it more similar to Hibernate than any other Python solution I've seen.
i think that it will be helpful for you
http://www.sqlalchemy.org/docs/05/ormtutorial.html#using-subqueries