Embed
Email

Hibernate_

Document Sample

Shared by: xiaoyounan
Categories
Tags
Stats
views:
8
posted:
12/28/2011
language:
pages:
30
Seminar

on

Overview





 Hibernate. What is it?



 Hibernate. How does it work?



 Hibernate Tools

Hibernate. What is it?

Definition



 Hibernate is free as open source software



 Hibernate is an ORM library for the Java

language, providing a framework for mapping

an object-oriented domain model to a

traditional relational database

Definition

Definition

Creator









 Gavin King

 gavin@hibernate.org

 The author of the book «Hibernate in Action»

together with Christian Bauer

The Goals



 To provide automated & optimized

techniques

 To reduce the time that developers devote to

manual coding & make them concentrated

more on business logic of their application

(25%)

 To insulate two object models

 To provide smart fetching & cashing

 To supply a toolset for development

Benefits



 Provides quite  DBMS

simple model independence

(fewer LOC)  Own query

 Rather easy for language (HQL)

learning

 Open source

software

Hibernate.

How does it work?

All you need for start



 Hibernate distribution (hibernate.org)

 Database of your choice (hsqldb preferably)

 SQL tables to hold your persistent objects

 Java classes to represent that objects in

code

 XML mapping files

 Configuration file for database connection

settings

Development strategies





 Java → Hibernate → Database (top-down)



 Java ← Hibernate ← Database (bottom-up)



 Java ← Hibernate → Database (middle-out)

Persistent Class

package hello;



private class Message{

private Long id;

private String text;

private Message nextMessage;

private Message() {}

public Message(String text){

this.text = text;

}

public Long getId(){

return id;

}

Persistent Class

public void setId(Long id){

this.id = id;

}

public String getText(){

return text;

}

public void setText(String text){

this.text = text;

}

public Message getNextMessage(){

return nextMessage;

}

public void Message(Message nextMessage){

this.nextMessage = nextMessage;

} }

XML Mapping





 Tells Hibernate what classes to store in a

database and how they relate to Tables and

Columns



Instead of mappings you can use annotated

classes

XML Mapping









(assigned, natural)











Database settings (.cfg.xml)





org.hsqldb.jdbcDriver

jdbc:hsqldb:hsql://localhost/



sa



org.hibernate.dialect.HSQLDialect









Create Database Table



 Start the database

 Create a table

 Now it’s time to see Hibernate in action

Work with objects

Work with objects



 Through the Session Hibernate works with a

Database

 Transaction involves a unite of work with a

Database

Work with objects

Hibernate Tools

Hibernate Tools



 Toolset for development

 Makes working with Hibernate much easier

 Comes with JBoss Tools

 A part of JBDS

 Available both as plugin to Eclipse or via Ant

tasks

Shortly about Ant task



 To start using Hibernate Tools via Ant define

the fallowing task:





Hibernate plugin within Eclipse



 Provides a number of wizards & editors for

smart & simpler work with Hibernate

 Allows to watch the structure of mapping

files, execute queries as well as see the

results

 All of these features are available through

the Hibernate perspective

Development Wizards



for creating:



 Hibernate Configuration File (.cfg.xml)

 Hibernate XML mapping file (.hbm.xml)

 Hibernate Console Configuration

 Hibernate Reverse Engineering (reveng.xml)

Code Generation



 Make use of it when you need to generate

one kind of artifacts to another

 Note :

while generating hbm.xml’s, not all

conversions might be implemented, thus

some hand code editing can be necessary.

Editors





 Hibernate Configuration file editor

 Hibernate Mapping file editor

 Reveng.xml editor

Hibernate Console Perspective



 Hibernate Configuration view

 Mapping Diagram

 HQL or Hibernate Criteria editors

 Hibernate query result view & Dynamic SQL

translator view

 Properties View

Gratitude



 Thanks a lot Vitalii Yemialyanchyk &

Geraskov Dmitrii







Presentation is made with help of the book

“Hibernate in action” & “Hibernate Tools

Reference Guide”



Related docs
Other docs by xiaoyounan
uses chart
Views: 2  |  Downloads: 0
least_squares_fit_manual
Views: 0  |  Downloads: 0
ENTERING_THE_ROADWAY_AND_BACKING_NOTES
Views: 0  |  Downloads: 0
FFaith presentation
Views: 0  |  Downloads: 0
Ward_Nutritioin
Views: 1  |  Downloads: 0
0604477_Goldburg
Views: 0  |  Downloads: 0
salary-delegation-authority-summary-temporary
Views: 0  |  Downloads: 0
August 2011 _excel format_
Views: 19  |  Downloads: 0
1350 Tally FINANCE
Views: 1  |  Downloads: 0
Ch. 6.3.Martinez
Views: 0  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!