1 / 51

Become the nhibernate Guru

Become the nhibernate Guru. Torkel Ödegaard. torkel.odegaard@gmail.com. www.codinginstinct.com. Nhibernate?. ORM (Object-Relational Mapper). Transparent persistance. Persistence ignorance. Become the Guru. Identity map (L1 Cache) Unit Of Work (Session Flush) Cascading

Download Presentation

Become the nhibernate Guru

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Become the nhibernate Guru

  2. Torkel Ödegaard torkel.odegaard@gmail.com www.codinginstinct.com

  3. Nhibernate? ORM (Object-Relational Mapper) Transparent persistance Persistence ignorance

  4. Become the Guru • Identity map (L1 Cache) • Unit Of Work (Session Flush) • Cascading • Attached / Detached • Proxy / Lazy loading • ID generation / unsaved-value • Concurrency • Legacy databases • Performance

  5. IStarShip

  6. Those WERE the droids I was looking for...

  7. MAPPing

  8. Mapping

  9. example

  10. session

  11. Session

  12. unit of work session.Flush()

  13. Flush Mode • Auto • Commit • Never • Unspecified

  14. Transaction Unit Of Work

  15. identity map An identity map is a database access design pattern  used to improve performance by providing a context-specific in-memory cache to prevent duplicate retrieval of the same object data from the database.

  16. identity map True

  17. identity map True

  18. identity map - Problems Same instance Will return instance from identity map

  19. identity map - Problems NHibernate.NonUniqueObjectException A different object with the same identifier value was already associated with the session Two instances with same id

  20. identity map - Problems NHibernate.HibernateException Identifier of an instance of TieFighter was altered …

  21. Cascading

  22. cascading • None • Save-update • Delete • Delete-orphan • All • All-delete-orphan

  23. Cascade & Save-update Transient (unsaved) instance Transient (unsaved) instance INSERT INTO Pilot .... INSERT INTO TieFighter ...

  24. Cascade & delete DELETE TieFighter ... DELETE Pilot ...

  25. Cascade & none Transient (unsaved) instance Transient (unsaved) instance NHibernate.TransientObjectException Object references an unsaved transient instance -save the transient instance before flushing

  26. Cascade & none

  27. Cascade & none

  28. Cascade & none UPDATE Pilot ....

  29. PRoxy

  30. PRoxy

  31. PRoxy

  32. Fetch Select / Lazy /N plus 1

  33. Fetch join

  34. inverse false

  35. concurrency

  36. Concurrency

  37. Concurrency - version

  38. Concurrency - version

  39. Concurrency - timestamp

  40. legacy • Composite primary keys • Relations on non-primary keys • Join • SQL Queries • DB Generated fields

  41. Property-ref

  42. Sql queries

  43. generated - insert

  44. performance • Batching • Eager loading (eliminate N+1) • Query Cache • L2 Cache

  45. Batching

  46. Batching

  47. i could go on an on... • NHibernate = endless number of features 

More Related