NHibernate for .NET

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    NHibernate for .NET - Presentation Transcript

    1. NHibernate for .NET
      Albert Kuo
      1
    2. Introduction to ORM
      Introduction to NHibernate
      Scenario
      NHibernate Demo
      Demo Process
      Hibernate-config.xml
      Mapping files & classes
      SessionManager
      DAO (Data Access Object)
      Create ASPX to do testing
      Reference
      2
      Agenda
    3. Introduction to ORM
      3
    4. Object-relational mapping (aka ORM, O/RM, and O/R mapping) is a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages (Wikipedia)
      Objects are hierarchical
      Databases are relational
      What is ORM?
      ORM
      objects
      relational
      4
    5. Productivity
      Eliminates lots of repetitive code – focus on business logic
      Database schema is generated automatically
      Maintainability
      Fewer lines of code – easier to understand
      Easier to manage change in the object model
      Performance
      Lazy loading – associations are fetched when needed
      Caching
      Database vendor independence
      The underlying database is abstracted away
      Can be configured outside the application
      ORM Benefits
      5
    6. 6
      ORM and Architacture
      Oracle, MS SQL Server, DB2, MySQL, Sybase, etc.
    7. Introduction to NHibernate
      7
    8. Initially developed for Java
      created in late 2001 by Gavin King
      absorbed by the JBossGroup / Red Hat
      Ported to .NET 1.1, 2.0, 3.5
      Resulting product called “NHibernate”
      All popular databases supported
      Oracle, SQL Server, DB2, SQLite, PostgreSQL, MySQL, Sybase, Firebird, …
      XML-based configuration files
      Good community support
      Free/open source -NHibernateis licensed under the LGPL (Lesser GNU Public License)
      Introduction to NHibernate
      8
    9. 9
      High-level overview of the Nhibernate API
    10. NHibernate managing database access
      10
    11. 11
      Access Persistent Object
    12. ISessionFactory
      One per database (or application)
      Expensive to create
      Reads configuration
      ISession
      Portal to the database
      Saves, retrieves
      ITransaction
      Encapsulates database transactions
      Nhibernate in a Nutshell
      12
    13. Scenario
      13
    14. One people may have more than one contact
      One contact belongs to one people
      14
      Database schema
    15. 15
      Use Case Diagram
    16. 16
      Sequence diagram – create
    17. 17
      Sequence diagram – Read
    18. 18
      Sequence diagram – Update
    19. 19
      Sequence diagram – Delete
    20. 20
      Project Directories
      Stored persistence tier-related code
      Stored presentation tier-related code
      Data access objects
      Value objects and mapping files
    21. NHibernate
      21
    22. Libraries
      Required library
      Required for lazy loading
      Antlr3.Runtime.dll
      Iesi.Collections.dll
      log4net.dll
      NHibernate.dll
      Castle.Core.dll
      Castle.DynamicProxy2.dll
      NHibernate.ByteCode.Castle.dll
      22
    23. 23
      Demo Process
    24. 24
    25. 25
      Hibernate-config.xml
    26. 26
      Hibernate-config.xml
    27. 27
    28. <class> declare a persistent class
      <id> defines the mapping from that property to the primary key column
      Specifies strategy
      <property> declares a persistent property of the class
      <component> maps properties of a child object to columns of the table of a parent class.
      Associations
      One-to-Many
      Many-to-One
      Many-to-Many
      One-to-One (uncommon)
      28
      Mapping Concepts
    29. 29
      Mapping Collections
    30. 30
      Mapping files & classes
      ORM
      objects
      relational
    31. 31
      Mapping files & classes – cont.
    32. 32
      Mapping files & classes – cont.
    33. 33
      Mapping files & classes – cont.
    34. 34
      Session Manager
      [ISession]
      • Obtained from a SessionFactory instance
      • Responsible for storing and retrieving objects
      • Think of it as a collection of loaded objects related to a single unit of work
    35. 35
      DAO (Data Access Object)
    36. 36
      DAO (Data Access Object) – cont.
    37. 37
      DAO (Data Access Object) – cont.
    38. 38
      DAO (Data Access Object) – cont.
    39. 39
    40. Transaction: A set of database operations which must be executed in entirety or not at all
      Should end either with a commit or a rollback
      All communication with a database has to occur inside a transaction!
      40
      Transactions
    41. 41
      Transactions – cont.
    42. Create a new record
    43. 43
      Read data by criteria
    44. Update record
    45. 45
      Delete record
    46. O/R Mapping
      http://en.wikipedia.org/wiki/Object-relational_mapping
      Official site
      www.hibernate.org
      NHibernate in Action
      NHibernate Made Simple
      http://www.codeproject.com/KB/database/Nhibernate_Made_Simple.aspx
      NHibernate Best Practices
      http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx
      46
      Reference
    SlideShare Zeitgeist 2009

    + Guo AlbertGuo Albert Nominate

    custom

    315 views, 0 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 315
      • 315 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 6
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Tags