the blog for developers

ORMs are a thing of the past

ORMs are a thing of the past. Hold your anger! I always thought ORMs were the next best thing after sliced bread. I was so convinced about ORMs that I wrote some of them on my own in Ruby and Java – not very good, mind you – during the 90s. Later I switched to commercial ones and settled with Hibernate and JPA for many projects. But after years of usage and seeing developers on my teams work with Hibernate, I’m no longer sure it is a good thing.

Beware: This is a non-conformist post. I’m also one of the very few people who think JPA/Hibernate annotations are bad for your domain classes. Keep this in mind while reading further.

Problems with ORMs

They are a delusion. They help you getting up to speed fast and prevent you from writing noisy boiler code. Over time they will pose problems, those problems becoming bigger than the speed you’ve gained. The biggest two:

  1. ORMs are most problematic due to performance concerns. Many developers I’ve met never look into Hibernate SQL logs to see what queries are generated, and how many of them. Should they ever look in the SQL which is executed, their eyes will pop up. Mine did. Nearly.
    As Aldo wrote in “A Farewell to ORMs”

    Whether or not the magical plumbing is worthwhile depends largely on how often the abstraction breaks down. The ORM approach does so frequently. Yes, I can use an ORM and think at the object level in the common case, but whenever I need to do anything remotely complicated – optimising a query, say – I’m back in the land of tables and foreign keys. In the end, the structure of data is something fundamental that can’t be simplified or abstracted away. The ORM doesn’t resolve the impedance mismatch, it just postpones it.

  2. Leaky abstractions. You think the ORM works but it doesn’t. It throws exceptions to you. Lazy initialization exceptions in Hibernate popping up in the most unfortunate circumstances because you made wrong assumptions about sessions, scope and flow. These are hard to find and often harder to fix.

But these are not the main reasons for the phasing out of ORMs over the next years. Additionally ORMs may hinder future development and not be a safe investment because they lose their grip on enterprise development with the advent of NoSQL data stores. Polyglot persistence will make it harder to store data via ORMs, as thouse would need to cross reference stores. This is all highly speculative, and could be countered by: “Well, SQL isn’t safe either”. But nevertheless it needs consideration.

Solutions without ORMs

The most common argument against the performance impact of ORMs is to use caching. Caching in Hibernate does reduce the number of queries indeed. But caching done in XML, JSON or HTML is often more efficient than object caching. And should you need object caching, other solutions beside ORMs exist which explicit caching of objects like ehCache or Terracott in Java.

What about less boiler plate code due to ORMs? Good DAOs with standard CRUD implementations help there. Just use Spring JDBC for databases. Or use Scala with closures instead of templates. A generic base dao will provide create, read, update and delete operations. With much less magic than the ORM does. And although others think that DAOs are dead, the fraction of persistence increases the need for DAO abstraction. The downside of managing relations yourself isn’t as large as ten years ago, with many web databases denormalized. Or with part of the data already in NoSQL document databases.

Think about ORMs the next time you start a project.

You can leave a Reply here. Of course, you should follow me on twitter here.

You can share this post!
Do you want to tell others about this article? Use the social bookmark icons to submit this artice to the service of your choice. Thanks.

About the author: Stephan Schmidt has more than 15 years of internet technology experience and 10 years experience in agile. He was head of development, consultant and CTO and is a speaker, author and blog writer. He specializes in organizing and optimizing software development helping companies by increasing productivity with lean software development and agile methodologies. Want to know more? All views are only his own.

57 Tweets 23 Comments 14 Other Comments

Leave a reply.

Comments

I’d say ORMs are just as much a thing of the past as Java.

Of course your points are valid, but really the problem is: what do you gain by not using an ORM? You are solving the problem that you have in some of the cases with an ORM for all SQL Statements. You loose the power of refactoring your database with your domain objects. You have to track the changes you do yourself.

You are basically building your own specialized ORM. Again.

As to Scala and non sql databases. I say: Nice ideas, but by far not enough ressources available for usage in many projects. Hell, often we have to fight for using Java 1.5 because big companies are still stuck at Websphere 6.0

@Jens: “You are basically building your own specialized ORM. Again.”

Yes and no. No because you will not use the magic of ORMs like session managment, change management etc. Yes because you will need to manage your associations by yourself. But association managment with ORMs has the same problem as RMI: It seems to be transparent, but it is not (lazy exceptions and remote exceptions).

I just get sick and tired of maintaining the database schema, the queries, the data structures to hold the results and the code to query the database…So many cards stacked delicately. At least with something like ActiveRecord you only ever say things once, and can drop down to SQL if you want.

I’m sorry, but if I have a PERSON table with a FIRST_NAME and a LAST_NAME, why, in this day and age, do I need to put together a class named Person with fields named firstName and lastName and glue it all together myself? Not everyone is building amazon.com and Facebook. In fact, few are. And for the vast majority of us, ORMs like HB or AR are more than sufficient. Rolling your own is so ‘98.

Cedric

Hi Stephan,

Well, you’re not offering much of an alternative, are you? :-)

Sure, ORM’s have well documented deficiencies, but they’re really the best solution we have right now, and to be honest, they perform much better than what you claiming.

As for these other solutions that you mention (NoSQL, Polyglot Persistence), they are far, far, far from having proven themselves in even the simplest scenarios, and their shortcomings have already been widely documented.

Hibernate and JPA will still be around and dominant in 5-10 years, as will Java.


Cedric

Stephan, I agree in principle with what you say. Having said that I think ORM is here to stay (like Java) until we will have devised a better, faster way to talk to relational databases.

Spring JDBC absolutely rocks, but can you deal with the time-to-market demand on a medium / large project with that? Time-to-market is at least one reason why we still need ORM. I would recommend ORM for prototyping.

Key-value data stores are going to mature and get better or probably we will begin to see hybrids. Till then, I guess we just need to grin and bear ORM.

Yes it’s true that almost every abstraction leaks one way or another.

Nevertheless, I think ORMs are established and used in many new projects. Even companies that can’t rely on 3rd party ORMs, build their own.

On the other hand, sometimes a good ORM can even predict and optimize the generated SQL queries. Granted, the manually crafted SQL queries can’t be easily beaten, but for most scenarios you don’t need them and if you do, you just break the abstraction yourself (and that’s possible if your ORM choice was wise).

Joe

Amen. Embrace the ‘base!

@Cedric: “Hibernate and JPA will still be around and dominant in 5-10 years, as will Java.”

Ah the Java argument again. We do differ on that one +g+

I do not think Hibernate will be an obvious choice for projects in 10 years, not so sure about 5 years.

I’ve seen ORMs in multi-million line projects and in smaller ones.

They do help write less boiler code, but people often do misjudge the amount of SQL code they really need beside CRUD.

And many queries I have seen are aggregates. Where a simple count(*) or sum(*) would be enough, developers fetch all objects via Hiberante into a List and then call size().

And there are many more defiancies: The lack of interface support in Hibernate for example often prevents good code. The tight coupling of objects to normalized database schemas often prevent domain object refactoring. And I could go on.

@Shantanu:

“Time-to-market is at least one reason why we still need ORM. I would recommend ORM for prototyping.”

I do agree on that one, yes. If you need a short time to market or do a VC presentation, use an ORM. Or better use Rails ;-) and drop it afterwards.

ORMs also have the same problems as RMI. Method calls are not simple method calls. Calling getOrders() on a Customer might result in an exception as does e.g. a simple add(3,4) with RMI.

At my (soon to be former) workplace, there was a strong tendency for devs to develop a bad mental model with Hibernate of the RDBMS (in this case, Postgres.) The #1 offense was using Hibernate’s lazy evaluation *everywhere*, such that the ‘Object’ model was a massive multi-route graph. It’s from maintaining this system that I grew to hate Hibernate.

I switched the group to doing the majority of effort in Scala. Mostly using a tweaked version of the “pimped Connection” too -> basically, just doing straight SQL programming.

The end result: vastly improved quality and performance. For our situation, it’s all we needed as well, and as the system flushed out, the devs just have a better idea of what’s going on. And I’m talking about “this part in memory, this part in the DB” sort of awareness. They just missed and mixed up everything when using an ORM.

In the hands of a master, Hibernate can be impressive. But in a company where the devs are constantly hacking in features, I found it a nightmare.

programmer x

i just started a new project and it’s entirely based on orm.

as for this lazy exception stuff: i allways wonder why there is no hook or configuration to change this behavior.. if you know, why you wan’t it, a framework like hibernate should not tell you that this idea is wrong.

btw i use hibernate a lot and i am still happy with it (it does fit my needs). and if persistence is not a part of your core business, you should stay with hibernate or any orm you use today…

so i think “orm is dead for somebody”…

Michael L

I think *JAVA* orms are especially leaky. Python and ruby are much tighter IMO

What you are saying is that ORM is bad, because most programmers lack the knowledge to use them correctly. Sessions, lazy loading and performance issues are not something magical, but easily understandable if you understand the framework you’re using.
So the solution is to go back to basics and do everything ourselves again? I doubt that’s the right solution. You will soon run into the problems we did run in to that made us create ORM frameworks, and from there it all starts over again ;-)

The same is true for web frameworks (or any framework). Is Grails or Seam bad because there’s too much “magic”? Should you prefer plain Servlets?

That being said, if you want to have a simpler ORM framework, you should take a look at iBatis. That’s a very low-level framework that doesn’t have the complexity of a full blown ORM tool, but still offers a good way to map Java classes to a database.

Casper Bang

I hate the ORM’s I’ve seen. They all try to do so much magic, in the end you end up dealing with just as many problems as without an ORM except now it’s all masked behind countless frameworks.

I think the real way to go is integrate queries into the language, like LINQ does. Though not constrained to ORM’s, it proves tremendously powerful as you get type-safety, syntax help etc. unlike the nasty misuse of annotations and string concatenation known as JPQL.

Cedric

Stephan,

Just like you, I have seen a lot of horrible code written in the ORM layers, but do you have any evidence that these problems will disappear with NoSQL and other alternatives?

At any rate, you can’t dismiss a technology just by observing that it can be misused. After all, C++ is still going very strong today…


Cedric

Cedric

How timely: on the MongoDB blog, somebody just wrote that databases should be dynamically typed:

http://blog.mongodb.org/post/215738382/databases-should-be-dynamically-typed

Take a look at the comments on the blog post, and also on Hacker News:

http://news.ycombinator.com/item?id=887605

Sorry, but I’m still not overly impressed with the alternatives so far…

mironsadziak

Good article. But not all deficiencies explained here apply to all of ORM solutions. For instance OQM (Object-Query Mappers) like iBatis give much more control over the way you communicate with a database. Personally I prefer it for big projects, in connection with a good framework like Spring, which takes care of session and exception handling.

@Cedric

Bad code may not be a problem with ORM per se. The implementation framework should make it extra-hard to do it wrong, and should not hide details under three levels of abstraction within the framework itself (this is what people call “magic” [in a bad sense] when they do).

For example, Hibernate’s Level-1 Object cache may be fine for some use-cases but in general, trading lazy-loading/sync’ing for freedom from Level-1 blues appears to be a good balance. “Hibernate Lite”, anyone ?

Another gripe is with XML and annotations. Why not create DSL-like API for declaring entities and associations? (Think SQLAlchemy)

I’ve heard it more and more that people prefer iBatis.

The biggest problem – for us – with static typed databases is that they are hard to change, and because we’re not big enough, a schema change results in a web-downtime. With dynamic / schemaless databases the need would go away and we could better server our customers.

The downside is highly increased application code and logic, because you need to deal with NULL values.

From my experience though, over years NULL values also creep into RDBMS.

andrevd

It is funny to see that NoSQL databases becoming in advance for now.

I’ve been developing over three years with Lotus Domino / Lotus Notes platform with it’s own databaseformat NSF which is a NoSQL database. Adding fields, sorting, data replication with many other instances of the database were such a charme. Our complete CRM was implemented as many databases in this hierarchical structure and it worked very fast on huge amount of records and data. Everything was documented in it even binary files (.doc, .xls, .ppt and so on).

The only “problems” we had were that we’ve encountered a “missing link” with the “classical” business reporting systems which mostly do only support relational structures. And sadly with many consultants blaming that databases because of they only know relational ones. But if they had to change their tables (datatype migration, add one field, …) there was a need to take their application offline. With the NSF database we just developed (using DAOs) in a testenvironment and deployed it to production. All changes were replicated automatically to other instances of the database.

[...] Shared ORMs are a thing of the past. [...]

Here here, after spending 2 years working on a project where I, myself, convinced the team that Hibernate was the only option I have now worked on two separate projects and have chosen iBatis and most recently I have simply chosen Spring JDBC. Taking some ideas from the ActiveObject api and using java.net’s Inflector class I have created a simple genericized dao with all the benefits of type safety and all the simplicity of the rails naming convention. Sure, you have to jump through some hoops to pull a huge object graph out of the database but that use case is fairly rare and with spring, dropping down to sql is simple and easy. Finally, developing in a modern IDE simple means creating a database object class, typing in a few fields and the ide generates all the getters, setters, toString, hashcode, and equals without you having to think.

@Benjamin: Care to post the code?

@stephan, I agree. Many problems can be solved in SQL a lot more elegantly (and easier) than in Java.
If you truly needs caching, object-identity management and fast time-to-marked, considering a object-database would be a lot better choice than an ORM framework.

bubak

I store everything in RAM and use serialization…

[...] In a late blog post Stephan Schmidt vents his problems with hibernate and declares “ORMs are a thing of the past“ [...]

For me ORMs are necessary in any project which interact with a non-object database. Of course an ORM is complex, but you can hide most of it complexity behind a good DAO infrastructure.

Using Hibernate/JPA+Spring and some Java annotations I wrote the DAOs of the Parancoe meta-framework:

http://docs.parancoe.org/reference/html/persistence.html

Using these DAOs developers have a very little interaction with the ORM system: they only need to define the mapping, and the queries (using HQL or Criteria API), nothing else. They become productive immediately, and the possibilities of being wrong using the ORM are reduced at the minimum.

I’m a big fan of the Propel ORM for PHP5. It generates 2 sets of classes from the schema: base & implementation.

Base: extended by the implementation classes. Contain all the getters & setters, which you are free to override in the implementation classes. You never modify the Base classes directly. They are always fully auto-generated. If you want, you can even customize the class that generates the Base classes, so they all have the same customized core functionality.

Implementation: allows you to customize the getter/setter for any property, and to add your own for virtual properties, etc. The Implementation objects are also host to your save & delete methods. Implementation classes are not regenerated/overwritten when you regenerate the Base classes due to a schema change.

As for selecting data from the database, this is where Propel starts to shine. It actually generates another class for each table called a “Peer”. They are essentially containers for static methods for fetching rows of that table. They come with a few built-in queries, which you can add to. Example:
PersonPeer::retrieveByPk(42);

You can also select using “Criteria” objects.
Example:
$c = new Criteria();
$c->add(PersonPeer::FIRST_NAME, ‘Derek’);
$people = PersonPeer::doSelect($c);

You can also select using straight-up SQL if you like, and then populate your Implementation objects from the result set. Although you lose database portability by doing this (versus Criteria), you gain the benefit of having very straightforward easy-to-read queries.

Altogether, it gives you quite a flexible abstraction layer, which has helped me out of more than just one or two tricky situations.

For example, I’ve customized the Peer objects so that they automatically cache my result sets, and the Implementation objects so that they automatically save the History of all object changes.

Remco

I don’t like ORM’s (like Hibernate/JPA/JDO) either.
But the current alternatives also have flaws (Spring JDBC, iBatis, AR).

Sometimes I think we need something completely different. Should relational data be “mapped” to objects? What would a relational domain model look like?

Ho do you feel about pure object databases?

@Sena: I like them did some work with OO databases at the university, I think they never gained traction because they are hard to integrate and hard to use for reporting.

Basically everything written here:

http://codemonkeyism.com/dark-side-nosql/

applies to them.

Cedric

Stephan,

In this particular case, I see “hard to change” as a feature. When you change a type in an existing schema (something that’s pretty rare, to be honest), you have to do some extra work in order to give the database as much information as possible. In return, you get static safety, optimized queries and many other features that we have learned over the past decades in the RDBMS world.

Consider this analogy: in a Java program where all the objects are of type Object, changes are very easy to make, but you will most certainly break a lot of code doing so.


Cedric

Gernot Kogler

I helped designing and writing an ORM that is still used in a very large product (Hibernate wasn’t born then), wrote another one later for my own purposes and have used (n)Hibernate in several projects.

Then I tried Rails 3 years ago and now I’m absolutely in love with ActiveRecord. Paired with the power of ruby there’s no way I would write my own DAO again (or use another platform – hehe). If properly used, it generates SQL that could hardly be written better “by hand”.

Replace the term ORM in your post with Hibernate and I agree with you. Hibernate is a terrible approach. Have you looked at iBatis? It is the best way to do ORM.

Karl Peterbauer

Two arguments pro ORM/JPA: JPA queries are sweet and compact, much easier to read/debug/maintain than standard SQL (no foreign key constraints, some nice extensions). And they try hard to scrape off the rough edges of the different SQL dialects. Don’t talk to the driver directly if you want to have a minimal chance of switching databases…

Steven P. Goldsmith

We use meta programming to generate DTOs and DAOs with a single DAO based on Java generics. If the underlying data model changes we can simple regenerate the code. One nice thing is since we use templates we can use any technology we choose. We also generate the meta file :) We can generate composite DAOs which are handy for legacy data models.

../genericdaotest/src
jsmith
jsmith@smith.com
dto.vm
dao.vm
applicationContext.vm

select tripid, carrentalid, provider, city, pickupdate, returndate, cartype, rate, bookingstatus, lastupdated from carrental limit 1

select tripid, carrentalid, provider, city, pickupdate, returndate, cartype, rate, bookingstatus, lastupdated from carrental where carrentalid = :carrentalid
insert into carrental (tripid, carrentalid, provider, city, pickupdate, returndate, cartype, rate, bookingstatus, lastupdated) values(:tripid, :carrentalid, :provider, :city, :pickupdate, :returndate, :cartype, :rate, :bookingstatus, :lastupdated)
update carrental set tripid = :tripid, carrentalid = :carrentalid, provider = :provider, city = :city, pickupdate = :pickupdate, returndate = :returndate, cartype = :cartype, rate = :rate, bookingstatus = :bookingstatus, lastupdated = :lastupdated where carrentalid = :carrentalid
delete from carrental where carrentalid = :carrentalid

I just blogged about the same thing:

http://blog.devtrain.fi/2009/10/18/kauklahti-making-orm-simple

My solution is simple extension to JdbcTemplate to support joins and CRUD generation for class hierarchy. Also ResultSet extraction into objects is provided.

Let me see if I understand that: because bad developers don’t know how to use the tools (ORMs), you are judging them – the tools – as thing of the past. Because bad developers don’t know when to use the right tool for the job, you are judging them – the tools – as thing of the past.

Well, here are the news: bad developers will mess up ANY tool that you can imagine. Anyway, thanks for the provocative text, but I was expecting some alternatives instead of just negative comments.

Kind Regards

Bjarne Saebaeck

I fully agree with Marcos: Developers always have to know how the tools or technologies work they want or are told to use. That of course is true for Hibernate or JPA but also for SQL.

At one time as a developer I used Hibernate on some projects. Those went well because the primary interest was in data insertion. Hibernate made it dirt easy to insert an object graph generated from an XSD-described XML message (JAXB generated the classes that Hibernate in turn persisted).

These days, a flagship product that is heavy on full range of database interactions (especially query) is using iBATIS. We’re finding iBATIS strikes a pretty good balance. We hand write the SQL (and often call stored procedures), but iBATIS assist with the tedium of mapping inputs and result sets to Java objects. It also nicely integrates with Spring Framework, where Spring is the bean factory facility for BlazeDS services, DAOs, iBATIS, and JMS message processing beans.

iBATIS is a good way forward for large scale projects that don’t want to compromise on the SQL layer that is used.

[...] ORMs are a thing of the past – Another opinion that might get in the way of hibernate fanboys. We’ve had our share of hibernate “experiences”. It’s a useful tool if you know how to use it – and when not to. Replies followed instantly, here are two noteworthy ones by Scot Mcphee and by Jens Schauder. [...]

I think ORMs are great. I just don’t care for the ones that are currently out there so I built my own ORM as a learning experience and to rectify the shortcommings of Hibernate. Namely:

The ORM should be able to automatically map plural table names.
The ORM should have no mapping files and have default conventions that make sense.
The ORM should support standard ANSI SQL not some crazy variation.
When an error occurs, not only should the SQL be displayed but also the parameters. The SQL should be nicely formatted.
The ORM should detect when a field length is too long and display the field name and the text that was tried.

I wish Hibernate would do all that.

Sounds like Hibernate would be good to slapping together a usable system using scaffolding and other quick-to-market stuff. But at some point, it would be nice for Hibernate to spill out the queries its using, and transform the solution into a fine-tunable iBatis solution. Any chance Hibernate could be patched to yield its secrets?

Good post. I know several other smart people who are starting to feel the same way.

The other day I heard one of them say, “I used NHibernate to solve a problem. Now I have two problems.”

karl

I use JDBC + memcached

I’m not sure about this article.

The way you put it is coloured and when reading I thought you where completely right. But then I started to think about the alternatives.

When you are using Spring JDBC you have to write your own SQL and do the mapping yourself. This will prevent much of the N+1 mistakes, sure. But why does it prevent these mistakes: Because we are writing SQL again.

The problem doesn’t come with the ORM as mapper, the problem is that people let the ORM-framework come up with queries! We need to write the queries ourself! There is nothing wrong with the mapping part.

IMHO it would be best if we had ORM mappers that take SQL queries and maps the results to objects. Then the people who still understand SQL could write the queries, and the resulting objects can be used throughout the program.

ORM isn’t a thing of the past, SQL-generation might be.

@Roy: The problem arises because ORMs are a leaky abstraction, they want to make something complex simple. In the process something is lost, and the question is: was the lost thing essential or not.

“There is nothing wrong with the mapping part.”

Then you don’t need use an ORM, iBatis or another simple mapper is sufficient.

People use ORMs because it transparently handles associations and generates all queries. The mapping part is the simple one.

With rowMap in Spring JDBC one gets a lot of things.

Janez

Hi there,

I’ve spent the last 4 years developing Lotus Domino applications – most of this time I worked on legacy applications.

And I have to say that most of you people will be hugely disappointed by the NOSQL world (Domino is one of the Original NOSQL database systems :)).

Why? Because in NOSQL databases schema is implicit and hugely dependent on context. Meaning that when you work on data that is 10 years old and that had schema changed 10 times in between can be HUGE PITA!

I have learned though that “schema” (although implicit) should always be well documented – especially the transitions between them.

When you sift through this kind of data and start getting “errors” like date fields with prosaic values, you realize how important it is to keep track of your design :).

What I’m trying to get across is: There is no silver bullets. If RDBMS doesn’t cut it for you then neither ORM neither NOSQL wont.

Yes there are problems out there that are more suited for this type of DB than the other.

BUT! There is no substitution for discipline, getting your basics straight and for developers having an good ol’ experienced DBA behind their necks.

I believe ORM’s are great for prototyping, maybe some smaller stuff – and that’s it. Its not that they wouldn’t be able to “get it done”. Its just that when shit hits the fan – you really won’t know how to help yourself out.

And cocky young developers (who don’t believe DBA’s) have a tendency to do just that! :)

Adrian

“And many queries I have seen are aggregates. Where a simple count(*) or sum(*) would be enough, developers fetch all objects via Hiberante into a List and then call size().”
- actualy Hibernate allows you an lazy “extra” config which doesn’t load the entire collection to give you the size, but executes a Count query to give you the result

[...] 09/09, NoSQL的缺点 “The dark side of NoSQL”, Stephan Schmidt, » (but ORMs are bad as well?! 原文 [...]

Leave a Reply

What people wrote somewhere else:

Published new blog post: “ORMs are a thing of the past” http://bit.ly/43Y7Km

This comment was originally posted on Twitter

RT @codemonkeyism Published new blog post: “ORMs are a thing of the past” http://bit.ly/43Y7Km

This comment was originally posted on Twitter

RT @codemonkeyism Published new blog post: “ORMs are a thing of the past” http://bit.ly/43Y7Km

This comment was originally posted on Twitter

RT: @codemonkeyism: “ORMs are a thing of the past” http://bit.ly/43Y7Km

This comment was originally posted on Twitter

IMHO ORMs use to be a PITA after the initial simplicity … RT @codemonkeyism: “ORMs are a thing of the past” http://bit.ly/43Y7Km

This comment was originally posted on Twitter

RT @andreisavu: RT @codemonkeyism Published new blog post: “ORMs are a thing of the past” http://bit.ly/43Y7Km

This comment was originally posted on Twitter

RT @codemonkeyism: Published new blog post: “ORMs are a thing of the past” http://bit.ly/43Y7Km

This comment was originally posted on Twitter

RT @codemonkeyism Code Monkeyism: ORMs are a thing of the past http://bit.ly/43Y7Km

This comment was originally posted on Twitter

RT @codemonkeyism: Published new blog post: “ORMs are a thing of the past” http://bit.ly/43Y7Km

This comment was originally posted on Twitter

RT @codemonkeyism: Published new blog post: “ORMs are a thing of the past” http://bit.ly/43Y7Km

This comment was originally posted on Twitter

Finally people are starting to agree with me: ORMs are a thing of the past http://codemonkeyism.com/orms/

This comment was originally posted on Twitter

RT: @codemonkeyism: Published new blog post: “ORMs are a thing of the past” http://bit.ly/43Y7Km

This comment was originally posted on Twitter

The best ORMs let you use SQL too RT @codemonkeyism: Published new blog post: “ORMs are a thing of the past” http://bit.ly/43Y7Km

This comment was originally posted on Twitter

RT interesting point again. @codemonkeyism: Published new blog post: “ORMs are a thing of the past” http://bit.ly/43Y7Km

This comment was originally posted on Twitter

RT @codemonkeyism: Published new blog post: “ORMs are a thing of the past” http://bit.ly/43Y7Km

This comment was originally posted on Twitter

RT @codemonkeyism: Published new blog post: “ORMs are a thing of the past” http://bit.ly/43Y7Km

This comment was originally posted on Twitter

By @codemonkeyism, with my Amen: http://bit.ly/397KMR

This comment was originally posted on Twitter

Some comments:

"[...] littered with SQL that’s impossible to refactor when my schema changes."

Never saw a ORM (like Hibernate) help when changing the database. And on the contrary: I haven’t seen schema changes in large databases, because too many systems (reporting, accounting) depend on a schema. Your domain model will change much more likely, and when the gap between your domain classes and your db is too large, your ORM will break. This often prevents refactoring of domain classes.

"If you are not designing an ActiveRecord based model, it’s of paramount importance that you keep your domain model decoupled from the persistent model."

As said above, ORMs do not decouple your domain classes from the database, but instead nail your domain classes to your database schema.

Ever tried splitting domain classes that are in one table? Everything beside renaming classes and attributes is out of the window if you use an ORM (just my experience, YMMV).

Cheers
Stephan
http://www.codemonkeyism.com

This comment was originally posted on Ruminations of a Programmer

Interesting read: “ORMs are a thing of the past” http://bit.ly/43Y7Km (via @codemonkeyism)

This comment was originally posted on Twitter

You can also use refactoring aware SQL dsls like squill, jequel, empiredb.

Regarding those _big_ domain models. In DDD terms they are broken anyway as there are no modules or bounded contexts that address the relevant part of the domain model at once.

When talking to BigDaveThomas at JAOO he also stressed that most solutions today are just simple CRUD systems that are bloated with ORM. Just mapping the tables to a screen is often a simple case of generic SQL and you’re done :)

Michael
Michael

This comment was originally posted on Ruminations of a Programmer

ORMs are a thing of the past… http://codemonkeyism.com/orms/

This comment was originally posted on Twitter

"Have a look at how grids like Terracotta can use distributed caches like EhCache to scale out your data layer seamlessly."

We use TC and it does scale out our data without Hibernate.

Cheers
Stephan

This comment was originally posted on Ruminations of a Programmer

ORMs are a thing of the past http://bit.ly/1EMUpw

This comment was originally posted on Twitter

Ari

I am starting to learn that Hibernate requires more understanding and time than most people want to give it, but with that understanding, it can really work for you. I was talking to a user yesterday who asserts that QueryCaching is bad for him. I listened, checkpointed with someone who knew query caching very well, and found out that it will indeed work for this user if used properly.

I see that since Terracotta stopped fighting Hibernate and embraced it in the market and now that we build products for Hibernate users, my understanding of the technology has grown. Our ability to serve the needs of higher performance while staying within the confines of the Hibernate world have vastly improved over the last year.

Yes Hibernate has a few problems but I see the path fwd as contributing fixes and helping and not trying to invent yet another way to do what is inevitable, marshaling data to and from an RDBMS.

–Ari

This comment was originally posted on Ruminations of a Programmer

Lazy Initialization is not a feature/side-effect of ORMs, they can be present in your DSLs as well.

ORMs seems like a hindrance at the start of the project or when there are less "objects".

I think they are well suited for Object-Oriented minded teams. But now, as we are exploring different areas, paradigms, we tend to move away from ORMs and that’s natural for these kinds of projects.

This comment was originally posted on Ruminations of a Programmer

http://codemonkeyism.com/orms/ ORMs are a thing of the past

This comment was originally posted on Twitter

I’m seeing alot of articles advocating against ORMs. http://codemonkeyism.com/orms/

This comment was originally posted on Twitter

StartupNews: ORMs are a thing of the past http://bit.ly/1yfxmx

This comment was originally posted on Twitter

Interesting post: ORMs are a thing of the past – http://bit.ly/4xOvah

This comment was originally posted on Twitter

RT @codemonkeyism Code Monkeyism: ORMs are a thing of the past http://bit.ly/43Y7Km

This comment was originally posted on Twitter

RT @codemonkeyism: Published new blog post: “ORMs are a thing of the past” http://bit.ly/43Y7Km

This comment was originally posted on Twitter

The end of ORM’s time?: http://codemonkeyism.com/orms/

This comment was originally posted on Twitter

ORMs are a thing of the past http://codemonkeyism.com/orms/

This comment was originally posted on Twitter

RT @codemonkeyism Code Monkeyism: ORMs are a thing of the past http://bit.ly/43Y7Km

This comment was originally posted on Twitter

“ORMs are a thing of the past”,http://tinyurl.com/ylgwpru, nice discussions

This comment was originally posted on Twitter

RT @eelzinga: “ORMs are a thing of the past”,http://tinyurl.com/ylgwpru, nice discussions

This comment was originally posted on Twitter

Shared Feed: ORMs are a thing of the past http://bit.ly/2UEQ4

This comment was originally posted on Twitter

Anonymous

ORM is nothing more than an alternate marshalling scheme. To add layers upon layers of marselling has never made sense. That said db calls are tied to the network and is the case with all technologies that rely on aslow under pinnings caching will be essential. The best way to make an application cache resistant is to scatter the calls throughout your application. At least ORM normalize execution paths which makes it easier to add caching.

That said for the moment, applications are going to need to rely on something other than RDB technologies if they are going to scale. Technologies such as memcached look very interesting in that it is a very simple technology that is highly scalable

Kirk

This comment was originally posted on Ruminations of a Programmer

Sharing… ORMs are a thing of the past: ORMs are a thing of the past. Hold your anger! I always thoug.. http://bit.ly/fWRVC

This comment was originally posted on Twitter

I’m not sure with Stephen means that ORMs cannot help when refactoring a database; they help a hell of a lot more than strings containing SQL all over the place would; it’s trivial to write an integration test to load up all your mapped beans and try to access one. If your mappings and database are inconsistent, you will know immediately what is the problem and where.

Having seen many codebases NOT using an ORM, I have to say they were all a big, huge, mess. ORM makes the code cleaner (or can help). And clean code can be refactored, maintained and optimized a lot better than a big mess of SQL statements everywhere.

This comment was originally posted on Ruminations of a Programmer

Code Monkeyism: ORMs are a thing of the past http://ow.ly/v52R

This comment was originally posted on Twitter

ORMs are a thing of the past http://bit.ly/397KMR

This comment was originally posted on Twitter

ORMs are a thing of the past http://ff.im/-a4mvr

This comment was originally posted on Twitter

Gotta retweet this great post from Stephan Schmidt: http://bit.ly/397KMR

This comment was originally posted on Twitter

ORMs are a thing of the past http://bit.ly/2WPXlv

This comment was originally posted on Twitter

RT @justinvincent: ORMs are a thing of the past http://bit.ly/2WPXlv

This comment was originally posted on Twitter

Anonymous

Just put everything in stored procs, then your java code is completely shielded from the database structure. I’ve used this approach on a number of projects, and it has worked well. Simple and easy to maintain. This is in stark contrast to the ORM based projects I’ve worked on where no one on the project truly understood what was going on with all of the complex mappings, cachings, cryptic errors, etc. I can show any who knows SQL how to do virtually anything needed in a few hours with stored procs. ORM adds much more complexity…and I often see lazy loading all over the place causing horrible performance.

This comment was originally posted on Ruminations of a Programmer

Are ORMs a thing of the past? Two different views by @codemonkeyism (http://bit.ly/35UnCR) and @debasishg (http://bit.ly/12UNV1).

This comment was originally posted on Twitter

structure of data can’t be simplified or abstracted away. ORM doesn’t resolve the impedance mismatch, just postpones it http://bit.ly/35UnCR

This comment was originally posted on Twitter

I can understand decoupling your domain model from the database in that the domain objects should be simple POJOs. That is where something like JdbcTemplate really shines (similar to using iBatis).

In this modern era of polyglot, how come we don’t recognize that SQL is a language of its own. When tuning queries, it seems easier to enlist our team’s database engineer to help me out by showing him queries, rather than bringing him up to speed on XYZ-QL.

This comment was originally posted on Ruminations of a Programmer

Read: “Code Monkeyism: ORMs are a thing of the past” http://codemonkeyism.com/orms/

This comment was originally posted on Twitter

Maybe the real solution is some kind of "extended ddl" where one could specify validations/constraints/other business logic" more easily.
Like Hibernate, but without the "object mapping" part (why should one try to map relational data to objects?). Like "stored procedures", but functional instead of procedural (though i like spaghetti with cheese).

(just an idea)

This comment was originally posted on Ruminations of a Programmer

Anonymous

Rails doesnt use straight SQL, so there is no need to move away from ORMs. Just wait and see what the Rails guys do.

This comment was originally posted on Ruminations of a Programmer

RT @justinvincent: ORMs are a thing of the past http://bit.ly/2WPXlv – Interesting.

This comment was originally posted on Twitter

ORMs are a thing of the past http://codemonkeyism.com/orms/

This comment was originally posted on Twitter

RT: @marciolx: ORMs are a thing of the past http://codemonkeyism.com/orms/

This comment was originally posted on Twitter

Anonymous

I worked on a complete rewrite of a system and the Lead Developer did not use an ORM. We basically wrote our own, and it was a total mess and a waste of time. We spent most of our time debugging our data access layer and never made meaningful progress on the true functional requirements. After a year of hell, the Lead was fired and we threw the code away and started over with an ORM. What a relief! Not having to spend a lot of time dealing with the data access layer freed us up to focus on the functional requirements which makes happy clients which makes happy managers which makes happy developers.
Somehow I ended up on a team of developers that thought 3rd party tools are for wimps, and they could write everything themselves. What a bunch of arrogant fools, and what a waste of time. If we had all the time in the world, maybe we could write a better tool, but I doubt it. I freely admit that developers who create tools like Hibernate are smarter than me. Why would I waste any time trying to reinvent the wheel? It may not be perfect, but it’s better than anything I could create myself. As for the arrogant fools who liked to create their own tools instead of just finding one already built? They were all fired at various times for consistently not finishing projects.

This comment was originally posted on Ruminations of a Programmer

@Anonymous (of the last comment)
You resonate pretty much what I wanted to say. It’s true that ORMs like Hibernate are not without the warts. At the same time they offer a tonne of benefits too. My suggestion will be :
1. to use what good they offer (and they really offer a lot)
2. avoid the sucky features
3. use your judgement to selectively apply the ones that are debatable.

If you do not want to use the persistence context or automated session management, use the stateless session interface, where you use your ORM to marshal / unmarshal data out of your RDBMS and get stuff in the form of detached objects. Hibernate offers this .. check out http://docs.jboss.org/hibernate/core/3.3/reference/en/html/batch.html#batch-statelesssession ..

This comment was originally posted on Ruminations of a Programmer

Debasish Ghosh: Are ORMs really a thing of the past? http://bit.ly/4CIiFr in response to http://bit.ly/43Y7Km

This comment was originally posted on Twitter

A good summation on the pain I’ve felt during the last 3 years of enterprise hibernate usage: http://bit.ly/35UnCR

This comment was originally posted on Twitter

ovo me zabrinjava http://codemonkeyism.com/orms/

This comment was originally posted on Twitter

RT @codemonkeyism Code Monkeyism: ORMs are a thing of the past http://bit.ly/43Y7Km

This comment was originally posted on Twitter

Code Monkeyism: ORMs are a thing of the past http://ff.im/-adRZs

This comment was originally posted on Twitter

Code Monkeyism: ORMs are a thing of the past http://ff.im/-adSqM

This comment was originally posted on Twitter

leyendo: “ORMs are a thing of the past” http://icio.us/32updp

This comment was originally posted on Twitter

ORMs are a thing of the past http://bit.ly/2nb2zV (via feedly)

This comment was originally posted on Twitter

Code Monkeyism: ORMs are a thing of the past http://ff.im/-ajsrN

This comment was originally posted on Twitter

RT @codemonkeyism Code Monkeyism: ORMs are a thing of the past http://bit.ly/43Y7Km

This comment was originally posted on Twitter

@froots101 Agreed but bear in mind… http://codemonkeyism.com/orms/

This comment was originally posted on Twitter

RT @codemonkeyism Code Monkeyism: ORMs are a thing of the past http://bit.ly/43Y7Km

This comment was originally posted on Twitter

Session-less Approach
———————-
For those wanting a "session-less" approach you can also check out Ebean ORM to see if it is more of your liking.

http://www.avaje.org

This means you don’t need to worry about
- LazyInitialisationException
- management of session objects (Hibernate session/ JPA EntityManager).
- merge/persist/flush replaced with save

Sorry for the blatent plug but if you are looking for a simpler/session less approach it would be worth a look :)

Cheers, Rob.

This comment was originally posted on Ruminations of a Programmer

Additional comments powered by BackType

Guide to CodeMonkeyism

Over the last 4 years I wrote many articles on this blog. To make it easier for you to find the relevant ones, I've organized them into topics.

Top 10

6 reasons why my VC funded startup did fail

Go Ahead: Next Generation Java Programming Style

Java Interview questions: Write a String Reverser

The dark side of NoSQL

7 Bad Signs not to Work for a Software Company or Startup

Is Java dead?

Scala vs. Clojure

Never, never, never use String in Java

No future for functional programming in 2008 – Scala, F# and Nu

Clojure vs Scala, Part 2

Java Developer

Is Java Dead?

Go Ahead: Next Generation Java Programming Style

Be careful with magical code

All variables in Java must be final

Never, never, never use String in Java

Bending Java: More readable code with methods that do nothing?

NoSQL Guy

NoSQL: The Dawn of Polyglot Persistence

The dark side of NoSQL

Essential storage tradeoff: Simple Reads vs. Simple Writes

Sharding destroys the goals of your relational database

The unholy legacy of databases

Startup/CTO

Development Dream Teams

6 reasons why my VC funded startup did fail

American vs. European style of Software Development

12 Things to Reduce Your Lead Time and Time to Market

The high cost of overhead when working in parallel

Essential storage tradeoff: Simple Reads vs. Simple Writes

Job Seeker

Another Good (Java) Interview Question

7 Bad Signs not to Work for a Software Company or Startup

Java Interview questions: Write a String Reverser (and use Recursion!)

Java Interview questions: Multiple Inheritance

As a Manager: What I value in developers

Top 10 Tips (+1) to Get a Pay Raise

Agilist

What Developers Need to Know About Agile

5 Practices Better to Change in Your Scrum Implementation

Scrum is not about engineering practices

ScrumMaster and ZenMaster: The joke of certification

What is Trans-Scrum?