Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Hibernate, how the magic is really done

2,192 views

Published on

Almost every Java developer knows ORM concepts and Hibernate as the most popular solution in Java world in this area. But it is big surprise that very small percent of Java developers (even experienced ones) can answer very simple questions about how Hibernate really do all this “magic”. In this live coding session we will go through many practical samples and finally show truth to the Java community. ;)

P.S. After this talk you could pass through any Senior Developer interview easily.

Code samples can be found here: https://github.com/xpinjection/hibernate-basics
.

Published in: Technology
  • Be the first to comment

Hibernate, how the magic is really done

  1. 1. Hibernate, how the magic is really done? Mikalai Alimenkou/Igor Dmitriev http://xpinjection.com @xpinjection
  2. 2. Disclaimer This is only my personal experience
  3. 3. You could follow code samples https://github.com/xpinjection/hibernate-basics
  4. 4. What Hibernate really does?
  5. 5. PURE MAGIC!
  6. 6. Demo database schema
  7. 7. #1. Lazy loading internals • Persistent collections • Lazy component/field • Entity VS Proxy
  8. 8. #2. WHAT?!? Proxies? • Load • Optimized dirty checking • Lazy loading
  9. 9. #3. What about collections? • Collections affect performance • All relations are lazy by default • Some works not like you expect • Merging values is always a pain • Extra laziness is available
  10. 10. #4. But what was changed? • Dirty checking is applied: – Default approach based on properties with reflection – Optimized with bytecode instrumentation – Manual with SelfDirtyCheckingEntity
  11. 11. #5. But when real queries run? • Predefined order of queries is applied – inserts – updates – deletions of collections elements – inserts of the collection elements – deletes • Flush mode AUTO tries to be “smart”
  12. 12. @xpinjection http://xpinjection.com mikalai.alimenkou@xpinjection.com ihor.dmitriiev@gmail.com

×