Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I asked a question on SO, and found that there are no non-blocking ORMs for my favorite web framework. By non-blocking I mean an ORM with callback support for asynchronous retrieval. The ORM would be supplied with a callback or some such to execute when data has been received.

I want to create one, but I have some questions that blocking me from starting development:

  • What issues might be encountered when developing ORM?
  • Does supporting non-blocking retrieval dramatically increase the complexity of an ORM?
  • Why are there so few non-blocking ORMs around?

Update: It looks like I have to improve my question. We have solutions that already allow us to receive data in non-blocking way, and I believe that most companies that use such solutions use raw SQL. We want to create a more generic solution that we can reuse in future projects. What difficulties might we encounter?

Update 2: Preferred language is python, but I'm interested in principles. This question is actually for me, as I will look at platforms which already have non-blocking ORM.

share|improve this question
What is a "Non-blocking ORM?" How can you display the data before you receive it? – Robert Harvey Jun 22 '12 at 1:32
@RobertHarvey: asynchronous retrieval sounds pretty good actually. The ORM would be supplied with a callback or some such to "activate" when data has been received. Otherwise your ORM needs to be split of in a separate thread to guarantee UI responsiveness. – Marjan Venema Jun 22 '12 at 7:05
@MarjanVenema, yes, I want ORM with callback support. – Nikolay Fominyh Jun 22 '12 at 7:21
So why not just use asynchronous callbacks with your favorite synchronous ORM? – Robert Harvey Jun 23 '12 at 2:40
@RobertHarvey, because synchronous ORM blocks asynchronous server. – Nikolay Fominyh Jun 24 '12 at 6:51
up vote 2 down vote accepted

What issues might be encountered when developing ORM?

You'll need to address the laundry list of issues required to bridge the Object Relational Impedance Mismatch, as well as dealing with idiosyncrasies of SQL provided by each RDBMS vendor. The more advanced your requirements get, the worse your troubles would be in this department: for example, SQL that you generate to implement results paging will differ rather dramatically between Oracle, SQL Server, and mysql. Fortunately, this is not different between blocking and non-blocking ORM implementations, so if there is an open-source ORM for Python, you would be able to heavily borrow from it to address nearly all these issues.

Does supporting non-blocking retrieval dramatically increase the complexity of an ORM?

The biggest issue that you are going to face is that the connection library for accessing the RDBMS itself would be blocking. This is another difference that you must address. Managing the threads invisible to your users will be the additional challenge for you. In addition, loading of dependencies on demand would be a challenge, because the operation is perceived as synchronous by the users of your framework: after all, they do not normally expect a notification on when it's OK to access a collection property of their object.

Why are there so few non-blocking ORMs around?

I can only speculate on this last point, but I think it has to do with low demand for such frameworks: since you can partially simulate non-blocking ORM by adding another level of threading to your application code as needed, and keep the regular blocking kind everywhere else, developing a specialized framework for it would seem suboptimal.

share|improve this answer
Not sure, if answer on this question can be better. Thanks. – Nikolay Fominyh Jun 30 '12 at 8:13

You didn't say which language you're using so I'm going to recommend Node.js, and an ORM for it: Node ORM, everything in node is async, this is no different.

share|improve this answer
Question updated. – Nikolay Fominyh Jun 22 '12 at 10:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.