SlideShare a Scribd company logo
1 of 19
NHibernate by Andriy Buday
Outline Q1: What is NHibernate? Q2: Why do I need it? Q3: How does it look like? Concepts DEMO 1: Hello World! Q4: How can I proceed with it? Queries More about mapping, querying, usage patterns DEMO 2: Customer-Orders-Products http://andriybuday.blogspot.com/ Let see… will we get what we want!
Q1: What is NHibernate?NHibernate is… ORM New level of Abstraction http://andriybuday.blogspot.com/ Paradigm mismatch
Q2: Why Do I need it?Because… http://andriybuday.blogspot.com/ Development speed increases Reducing database work Optimizes access to DB, so could even perform better than plain ADO.NET You think in terms of business model, not database More time for real programming
Q2: Why Do I need it?Why do I like NHibernate? http://andriybuday.blogspot.com/ Mature Free & Open Source Good community support Flexible Allows you do Domain Driven Design You asked for comparison with other ORM… LINQ to SQL doesn’t really lead you to good models Entity Framework has better Linq and it is Microsoft Visit http://ormbattle.net/ for performance numbers Google.Search(string.Format“Nhibernate vs. {0}”, yourORM);
Q3: How does it look like?Concepts: Unit of Work http://andriybuday.blogspot.com/ Kind of “workspace” within which you can do anything you want A Unit Of Work either success or fails as a unit Conceptually like database transactions In NHibernate we have ISession which does the same Conceptually we have the same for in ADO.NET as DataSet
Q3: How does it look like?Concepts: ISession http://andriybuday.blogspot.com/ Open a session We get it from the session factory We do some work Session.Add(…) Session.Delete(…) Commit the session Session.Flush(…)
Q3: How does it look like?Concepts: ISessionFactory http://andriybuday.blogspot.com/ We are getting our session through this class Very expensive to create One per database or application
Q3: How does it look like?Concepts: Summary http://andriybuday.blogspot.com/ Configuration Class builds Session Factory Session Factory builds Session Session is used as Unit Of Work to interaction with objects and persist to underlying database var sessionFactory = newConfiguration().Configure().BuildSessionFactory();       using (var session = sessionFactory.OpenSession()) { var customer = newCustomer();     session.SaveOrUpdate(customer);     session.Flush();  }
Q3: How does it look like?Architecture: and look from inside? http://andriybuday.blogspot.com/
Q3: How does it look like?DEMO: Hello World! http://andriybuday.blogspot.com/ Just basics… to refresh our minds 
Q4: How can I proceed with it? More on Query API http://andriybuday.blogspot.com/ Criteria API Object oriented querying ICriteria chaining Easy to write Hard to read HQL API String based Parameterized Similar to SQL Speak in terms of Objects More flexible “from Customer c where c.FirstName = :firstName” session.CreateCriteria(typeof(Customer))     .Add(Restrictions.Eq("FirstName", "Hello"))
Q4: How can I proceed with it? Mapping http://andriybuday.blogspot.com/ <hibernate-mappingxmlns="urn:nhibernate-mapping-2.2"default-lazy="true"assembly="LearningNHibernate"namespace="LearningNHibernate">   <classname="Customer"table="Customer"xmlns="urn:nhibernate-mapping-2.2">     <idname="CustomerId"column="CustomerId"type="Int32">       <generatorclass="identity" />     </id>     <propertyname="FirstName"column="Firstname"length="50"type="String">       <columnname="Firstname" />     </property>     <propertyname="LastName"column="Lastname"length="50"type="String">       <columnname="Lastname" />     </property>   </class> </hibernate-mapping> publicclassCustomerMap : ClassMap<Customer>     { public CustomerMap()         {             WithTable("Customer");             Id(x => x.CustomerId);             Map(x => x.FirstName, "Firstname");             Map(x => x.LastName, "Lastname").WithLengthOf(50);         }     }
Q4: How can I proceed with it? Fetch strategies http://andriybuday.blogspot.com/ Lazy loading Default for all collections Members are loaded from database when assessed Usually good for performance Session has to stay OPEN Eager Fetching Use when you sure you’ll use data OUTER joins
Q4: How can I proceed with it? Caching, batching, concurrency http://andriybuday.blogspot.com/ First level cache Following will run only one SELECT Second level cache Within two sessions you still run one SELECT It is needed to explicitly turn it on everywhere Batch processing <property name="adonet.batch_size">250</property> Concurrency <version name="Version" column="Version"/>  var customer1 = session.Get<Customer>(5); var customer2 = session.Get<Customer>(5);
Q4: How can I proceed with it? http://andriybuday.blogspot.com/ Use FluentNhibernate to do not bore developers with XML Create wrappers to have NHibernateRepository Implement UnitOfWork VS projects Two ways for kick-off From database to Objects From objects to Database
DEMO 2: Mapping, Querying, LazyLoad, etc.. http://andriybuday.blogspot.com/ Damn it! Let’s write some code again!
Read blog! Follow me! Visit LVIV .NET UG! http://andriybuday.blogspot.com/ http://andriybuday.blogspot.com/ @andriybuday andriybuday@gmail.com http://dotnetug-lviv.blogspot.com/
Links http://andriybuday.blogspot.com/ My blog: http://andriybuday.blogspot.com Lviv .NET User Group: http://dotnetug-lviv.blogspot.com/ NHibernate: Home Page: http://nhibernate.com/ Reference: http://www.nhforge.org/doc/nh/en/index.html Great series of screencasts on NHibernate: http://www.summerofnhibernate.com/ ORM with NHibernate screen cast (2 hours) http://www.flux88.com/uploads/ORMWithNHibernateScreenCast.wmv Tools: Profiler: http://nhprof.com/ Fluent NHibernate: http://fluentnhibernate.org/ MyGeneration: http://www.mygenerationsoftware.com/

More Related Content

What's hot

Introduction to Hibernate Framework
Introduction to Hibernate FrameworkIntroduction to Hibernate Framework
Introduction to Hibernate FrameworkRaveendra R
 
Hibernate Basic Concepts - Presentation
Hibernate Basic Concepts - PresentationHibernate Basic Concepts - Presentation
Hibernate Basic Concepts - PresentationKhoa Nguyen
 
Hibernate Performance Tuning (JEEConf 2012)
Hibernate Performance Tuning (JEEConf 2012)Hibernate Performance Tuning (JEEConf 2012)
Hibernate Performance Tuning (JEEConf 2012)Sander Mak (@Sander_Mak)
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentationguest11106b
 
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2Marco Gralike
 
XFILES, The APEX 4 version - The truth is in there
XFILES, The APEX 4 version - The truth is in thereXFILES, The APEX 4 version - The truth is in there
XFILES, The APEX 4 version - The truth is in thereMarco Gralike
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentationManav Prasad
 
XML Amsterdam - Creating structure in unstructured data
XML Amsterdam - Creating structure in unstructured dataXML Amsterdam - Creating structure in unstructured data
XML Amsterdam - Creating structure in unstructured dataMarco Gralike
 
Hibernate Developer Reference
Hibernate Developer ReferenceHibernate Developer Reference
Hibernate Developer ReferenceMuthuselvam RS
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate pptAneega
 

What's hot (19)

Introduction to Hibernate
Introduction to HibernateIntroduction to Hibernate
Introduction to Hibernate
 
Hibernate
HibernateHibernate
Hibernate
 
Introduction to Hibernate Framework
Introduction to Hibernate FrameworkIntroduction to Hibernate Framework
Introduction to Hibernate Framework
 
Hibernate tutorial
Hibernate tutorialHibernate tutorial
Hibernate tutorial
 
Hibernate 3
Hibernate 3Hibernate 3
Hibernate 3
 
hibernate with JPA
hibernate with JPAhibernate with JPA
hibernate with JPA
 
Hibernate Basic Concepts - Presentation
Hibernate Basic Concepts - PresentationHibernate Basic Concepts - Presentation
Hibernate Basic Concepts - Presentation
 
Hibernate in Action
Hibernate in ActionHibernate in Action
Hibernate in Action
 
Hibernate Performance Tuning (JEEConf 2012)
Hibernate Performance Tuning (JEEConf 2012)Hibernate Performance Tuning (JEEConf 2012)
Hibernate Performance Tuning (JEEConf 2012)
 
Hibernate
HibernateHibernate
Hibernate
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
 
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
 
XFILES, The APEX 4 version - The truth is in there
XFILES, The APEX 4 version - The truth is in thereXFILES, The APEX 4 version - The truth is in there
XFILES, The APEX 4 version - The truth is in there
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
 
XML Amsterdam - Creating structure in unstructured data
XML Amsterdam - Creating structure in unstructured dataXML Amsterdam - Creating structure in unstructured data
XML Amsterdam - Creating structure in unstructured data
 
Hibernate Developer Reference
Hibernate Developer ReferenceHibernate Developer Reference
Hibernate Developer Reference
 
Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
JPA and Hibernate
JPA and HibernateJPA and Hibernate
JPA and Hibernate
 

Similar to NHibernate

Enterprise PHP (PHP London Conference 2008)
Enterprise PHP (PHP London Conference 2008)Enterprise PHP (PHP London Conference 2008)
Enterprise PHP (PHP London Conference 2008)Ivo Jansch
 
Gits class #22: [ONLINE] Analyze Your User's Activities Using BigQuery and Da...
Gits class #22: [ONLINE] Analyze Your User's Activities Using BigQuery and Da...Gits class #22: [ONLINE] Analyze Your User's Activities Using BigQuery and Da...
Gits class #22: [ONLINE] Analyze Your User's Activities Using BigQuery and Da...GITS Indonesia
 
Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestJoshua Warren
 
An Introduction to Microservices
An Introduction to MicroservicesAn Introduction to Microservices
An Introduction to MicroservicesAd van der Veer
 
Php mysql-training online-by_php2ranjan
Php mysql-training online-by_php2ranjanPhp mysql-training online-by_php2ranjan
Php mysql-training online-by_php2ranjanphp2ranjan
 
php training in hyderabad
php training in hyderabadphp training in hyderabad
php training in hyderabadphp2ranjan
 
Semantic logging with etw and slab from DCC 10/16
Semantic logging with etw and slab from DCC 10/16Semantic logging with etw and slab from DCC 10/16
Semantic logging with etw and slab from DCC 10/16Chris Holwerda
 
Developer Night - Opticon18
Developer Night - Opticon18Developer Night - Opticon18
Developer Night - Opticon18Optimizely
 
2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with Blackfire2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with BlackfireMarko Mitranić
 
Fuel for a great web experience
Fuel for a great web experienceFuel for a great web experience
Fuel for a great web experienceChristian Heilmann
 
Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015Mirco Hering
 
Techmindz: Custom Corporate Learning Platform Services in Kochi
Techmindz: Custom Corporate Learning Platform Services in KochiTechmindz: Custom Corporate Learning Platform Services in Kochi
Techmindz: Custom Corporate Learning Platform Services in KochiTechmindz Kochi
 
report_vendor_connect
report_vendor_connectreport_vendor_connect
report_vendor_connectYash Mittal
 
Workshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdfWorkshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdfTobiasGoeschel
 
Machine Learning Platform in LINE Fukuoka
Machine Learning Platform in LINE FukuokaMachine Learning Platform in LINE Fukuoka
Machine Learning Platform in LINE FukuokaLINE Corporation
 
PHP Sessions and Non-Sessions
PHP Sessions and Non-SessionsPHP Sessions and Non-Sessions
PHP Sessions and Non-SessionsSven Rautenberg
 
How Do You Know that Gal Knows Drupal? Towards an Open Source Curriculum and ...
How Do You Know that Gal Knows Drupal? Towards an Open Source Curriculum and ...How Do You Know that Gal Knows Drupal? Towards an Open Source Curriculum and ...
How Do You Know that Gal Knows Drupal? Towards an Open Source Curriculum and ...Dominik Lukes
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeededm00se
 
Building a Beer Recommender with Yhat (PAPIs.io - November 2014)
Building a Beer Recommender with Yhat (PAPIs.io - November 2014)Building a Beer Recommender with Yhat (PAPIs.io - November 2014)
Building a Beer Recommender with Yhat (PAPIs.io - November 2014)Austin Ogilvie
 

Similar to NHibernate (20)

Enterprise PHP (PHP London Conference 2008)
Enterprise PHP (PHP London Conference 2008)Enterprise PHP (PHP London Conference 2008)
Enterprise PHP (PHP London Conference 2008)
 
Gits class #22: [ONLINE] Analyze Your User's Activities Using BigQuery and Da...
Gits class #22: [ONLINE] Analyze Your User's Activities Using BigQuery and Da...Gits class #22: [ONLINE] Analyze Your User's Activities Using BigQuery and Da...
Gits class #22: [ONLINE] Analyze Your User's Activities Using BigQuery and Da...
 
Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWest
 
An Introduction to Microservices
An Introduction to MicroservicesAn Introduction to Microservices
An Introduction to Microservices
 
Performance Tuning with XHProf
Performance Tuning with XHProfPerformance Tuning with XHProf
Performance Tuning with XHProf
 
Php mysql-training online-by_php2ranjan
Php mysql-training online-by_php2ranjanPhp mysql-training online-by_php2ranjan
Php mysql-training online-by_php2ranjan
 
php training in hyderabad
php training in hyderabadphp training in hyderabad
php training in hyderabad
 
Semantic logging with etw and slab from DCC 10/16
Semantic logging with etw and slab from DCC 10/16Semantic logging with etw and slab from DCC 10/16
Semantic logging with etw and slab from DCC 10/16
 
Developer Night - Opticon18
Developer Night - Opticon18Developer Night - Opticon18
Developer Night - Opticon18
 
2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with Blackfire2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with Blackfire
 
Fuel for a great web experience
Fuel for a great web experienceFuel for a great web experience
Fuel for a great web experience
 
Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015
 
Techmindz: Custom Corporate Learning Platform Services in Kochi
Techmindz: Custom Corporate Learning Platform Services in KochiTechmindz: Custom Corporate Learning Platform Services in Kochi
Techmindz: Custom Corporate Learning Platform Services in Kochi
 
report_vendor_connect
report_vendor_connectreport_vendor_connect
report_vendor_connect
 
Workshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdfWorkshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdf
 
Machine Learning Platform in LINE Fukuoka
Machine Learning Platform in LINE FukuokaMachine Learning Platform in LINE Fukuoka
Machine Learning Platform in LINE Fukuoka
 
PHP Sessions and Non-Sessions
PHP Sessions and Non-SessionsPHP Sessions and Non-Sessions
PHP Sessions and Non-Sessions
 
How Do You Know that Gal Knows Drupal? Towards an Open Source Curriculum and ...
How Do You Know that Gal Knows Drupal? Towards an Open Source Curriculum and ...How Do You Know that Gal Knows Drupal? Towards an Open Source Curriculum and ...
How Do You Know that Gal Knows Drupal? Towards an Open Source Curriculum and ...
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
 
Building a Beer Recommender with Yhat (PAPIs.io - November 2014)
Building a Beer Recommender with Yhat (PAPIs.io - November 2014)Building a Beer Recommender with Yhat (PAPIs.io - November 2014)
Building a Beer Recommender with Yhat (PAPIs.io - November 2014)
 

More from Andriy Buday

NHibernate from inside
NHibernate from insideNHibernate from inside
NHibernate from insideAndriy Buday
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven DesignAndriy Buday
 
Windows Communicaiton Foundation
Windows Communicaiton FoundationWindows Communicaiton Foundation
Windows Communicaiton FoundationAndriy Buday
 
Mock Objects Presentation
Mock Objects PresentationMock Objects Presentation
Mock Objects PresentationAndriy Buday
 
Inversion of Control and Dependency Injection
Inversion of Control and Dependency InjectionInversion of Control and Dependency Injection
Inversion of Control and Dependency InjectionAndriy Buday
 
Service Oriented Architecture
Service Oriented ArchitectureService Oriented Architecture
Service Oriented ArchitectureAndriy Buday
 

More from Andriy Buday (7)

NHibernate from inside
NHibernate from insideNHibernate from inside
NHibernate from inside
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven Design
 
Windows Communicaiton Foundation
Windows Communicaiton FoundationWindows Communicaiton Foundation
Windows Communicaiton Foundation
 
Auto mapper
Auto mapperAuto mapper
Auto mapper
 
Mock Objects Presentation
Mock Objects PresentationMock Objects Presentation
Mock Objects Presentation
 
Inversion of Control and Dependency Injection
Inversion of Control and Dependency InjectionInversion of Control and Dependency Injection
Inversion of Control and Dependency Injection
 
Service Oriented Architecture
Service Oriented ArchitectureService Oriented Architecture
Service Oriented Architecture
 

Recently uploaded

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

NHibernate

  • 2. Outline Q1: What is NHibernate? Q2: Why do I need it? Q3: How does it look like? Concepts DEMO 1: Hello World! Q4: How can I proceed with it? Queries More about mapping, querying, usage patterns DEMO 2: Customer-Orders-Products http://andriybuday.blogspot.com/ Let see… will we get what we want!
  • 3. Q1: What is NHibernate?NHibernate is… ORM New level of Abstraction http://andriybuday.blogspot.com/ Paradigm mismatch
  • 4. Q2: Why Do I need it?Because… http://andriybuday.blogspot.com/ Development speed increases Reducing database work Optimizes access to DB, so could even perform better than plain ADO.NET You think in terms of business model, not database More time for real programming
  • 5. Q2: Why Do I need it?Why do I like NHibernate? http://andriybuday.blogspot.com/ Mature Free & Open Source Good community support Flexible Allows you do Domain Driven Design You asked for comparison with other ORM… LINQ to SQL doesn’t really lead you to good models Entity Framework has better Linq and it is Microsoft Visit http://ormbattle.net/ for performance numbers Google.Search(string.Format“Nhibernate vs. {0}”, yourORM);
  • 6. Q3: How does it look like?Concepts: Unit of Work http://andriybuday.blogspot.com/ Kind of “workspace” within which you can do anything you want A Unit Of Work either success or fails as a unit Conceptually like database transactions In NHibernate we have ISession which does the same Conceptually we have the same for in ADO.NET as DataSet
  • 7. Q3: How does it look like?Concepts: ISession http://andriybuday.blogspot.com/ Open a session We get it from the session factory We do some work Session.Add(…) Session.Delete(…) Commit the session Session.Flush(…)
  • 8. Q3: How does it look like?Concepts: ISessionFactory http://andriybuday.blogspot.com/ We are getting our session through this class Very expensive to create One per database or application
  • 9. Q3: How does it look like?Concepts: Summary http://andriybuday.blogspot.com/ Configuration Class builds Session Factory Session Factory builds Session Session is used as Unit Of Work to interaction with objects and persist to underlying database var sessionFactory = newConfiguration().Configure().BuildSessionFactory(); using (var session = sessionFactory.OpenSession()) { var customer = newCustomer(); session.SaveOrUpdate(customer); session.Flush(); }
  • 10. Q3: How does it look like?Architecture: and look from inside? http://andriybuday.blogspot.com/
  • 11. Q3: How does it look like?DEMO: Hello World! http://andriybuday.blogspot.com/ Just basics… to refresh our minds 
  • 12. Q4: How can I proceed with it? More on Query API http://andriybuday.blogspot.com/ Criteria API Object oriented querying ICriteria chaining Easy to write Hard to read HQL API String based Parameterized Similar to SQL Speak in terms of Objects More flexible “from Customer c where c.FirstName = :firstName” session.CreateCriteria(typeof(Customer)) .Add(Restrictions.Eq("FirstName", "Hello"))
  • 13. Q4: How can I proceed with it? Mapping http://andriybuday.blogspot.com/ <hibernate-mappingxmlns="urn:nhibernate-mapping-2.2"default-lazy="true"assembly="LearningNHibernate"namespace="LearningNHibernate">   <classname="Customer"table="Customer"xmlns="urn:nhibernate-mapping-2.2">     <idname="CustomerId"column="CustomerId"type="Int32">       <generatorclass="identity" />     </id>     <propertyname="FirstName"column="Firstname"length="50"type="String">       <columnname="Firstname" />     </property>     <propertyname="LastName"column="Lastname"length="50"type="String">       <columnname="Lastname" />     </property>   </class> </hibernate-mapping> publicclassCustomerMap : ClassMap<Customer> { public CustomerMap() { WithTable("Customer"); Id(x => x.CustomerId); Map(x => x.FirstName, "Firstname"); Map(x => x.LastName, "Lastname").WithLengthOf(50); } }
  • 14. Q4: How can I proceed with it? Fetch strategies http://andriybuday.blogspot.com/ Lazy loading Default for all collections Members are loaded from database when assessed Usually good for performance Session has to stay OPEN Eager Fetching Use when you sure you’ll use data OUTER joins
  • 15. Q4: How can I proceed with it? Caching, batching, concurrency http://andriybuday.blogspot.com/ First level cache Following will run only one SELECT Second level cache Within two sessions you still run one SELECT It is needed to explicitly turn it on everywhere Batch processing <property name="adonet.batch_size">250</property> Concurrency <version name="Version" column="Version"/> var customer1 = session.Get<Customer>(5); var customer2 = session.Get<Customer>(5);
  • 16. Q4: How can I proceed with it? http://andriybuday.blogspot.com/ Use FluentNhibernate to do not bore developers with XML Create wrappers to have NHibernateRepository Implement UnitOfWork VS projects Two ways for kick-off From database to Objects From objects to Database
  • 17. DEMO 2: Mapping, Querying, LazyLoad, etc.. http://andriybuday.blogspot.com/ Damn it! Let’s write some code again!
  • 18. Read blog! Follow me! Visit LVIV .NET UG! http://andriybuday.blogspot.com/ http://andriybuday.blogspot.com/ @andriybuday andriybuday@gmail.com http://dotnetug-lviv.blogspot.com/
  • 19. Links http://andriybuday.blogspot.com/ My blog: http://andriybuday.blogspot.com Lviv .NET User Group: http://dotnetug-lviv.blogspot.com/ NHibernate: Home Page: http://nhibernate.com/ Reference: http://www.nhforge.org/doc/nh/en/index.html Great series of screencasts on NHibernate: http://www.summerofnhibernate.com/ ORM with NHibernate screen cast (2 hours) http://www.flux88.com/uploads/ORMWithNHibernateScreenCast.wmv Tools: Profiler: http://nhprof.com/ Fluent NHibernate: http://fluentnhibernate.org/ MyGeneration: http://www.mygenerationsoftware.com/

Editor's Notes

  1. Hello,Lviv .NET User Group!
  2. Hibernate&apos;s goal is to relieve the developer from 95 percent of common data persistence related programming tasks, compared to manual coding with SQL It handles persisting plain .NET objects to and from an underlying relational database.Nhibernate is an abstraction layer at the top of you database.
  3. It is matureCommunity…Get answers quickly…Has definite path…Have community feedback
  4. This should be simple app… maybe console..I’m going to show few inserts including message “Hello World!” Good to show Nprof in action with this
  5. Todo: add code samples