ORM is a perfect anti-pattern

1,032 views

Published on

JEEConf 2016; Kiev, Ukraine; 21 May 2016. Video is here: https://www.youtube.com/watch?v=63tS3HNmhiE

Published in: Software
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,032
On SlideShare
0
From Embeds
0
Number of Embeds
113
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

ORM is a perfect anti-pattern

  1. 1. /20@yegor256 1 what do you think?
  2. 2. /20@yegor256 2 ORM is a perfect anti-pattern Yegor Bugayenko
  3. 3. /20@yegor256 3 book.setTitle(“Object Thinking”); session.update(book); Book Session MySQL JDBC UPDATE book
 SET title = “Object Thinking”
 WHERE id = 555 book.getTitle(); statement.executeUpdate(); this.title
  4. 4. /20@yegor256 4 Map attrs = new HashMap(); attrs.put(“title”, “Object Thinking”); book.updateAttributes(attrs); Book Base MySQL JDBC UPDATE book
 SET title = “Object Thinking”
 WHERE id = 555 statement.executeUpdate();
  5. 5. /20@yegor256 5 it’s offensive
  6. 6. /20@yegor256 6 SQL-speaking objects
  7. 7. /20@yegor256 7 book.rename(“Object Thinking”); Book MySQL JDBC UPDATE book
 SET title = “Object Thinking”
 WHERE id = 555 statement.executeUpdate();
  8. 8. /20@yegor256 8 JDBC, jOOQ, jcabi-jdbc
  9. 9. /20@yegor256 9 public class Book { private final DataSource source; private final int id; Book(DataSource db, int id) { this.source = db; this.id = id; } public void rename(String title) { new JdbcSession(this.source) .sql(“UPDATE book SET title=? WHERE id=?”) .set(title) .set(this.id) .update(); } }
  10. 10. /20@yegor256 10 www.yegor256.com

×