HIBERNATE Report - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

HIBERNATE Report

Description:

matches the pojo to table id identifies the PK. There are many different types of generators: ... adding comments to your pojo. Example: carDTO.java. SHAOJIAN ... – PowerPoint PPT presentation

Number of Views:119
Avg rating:3.0/5.0
Slides: 13
Provided by: renn8
Category:
Tags: hibernate | pojo | report

less

Transcript and Presenter's Notes

Title: HIBERNATE Report


1
HIBERNATE Report
Object/Relational Mapping
  • SHAOJIAN ZHU CHIH-HUNG CHO

2
Lazy Initialization
  • Class initialization needs time
  • Until we need it, we initialize it.
  • This until-use-initialize method is lazy
    initialization
  • Advantage
  • Save time and computing for wasted class
    initialization

3
Fine-grained vs Coarse-grained
  • Fine-grained PO (persistant object)
  • Control the one-to-one mapping of data and table
    column
  • Coarse-grained PO
  • Using multiple coarse-grained PO to control the
    whole data management
  • Users can use Coarse-grained PO to indirectly
    call the Fine-grained PO to carry out the
    data-management task
  • Disadvantage for Coarse-grained PO
  • As a whole system, so lazy initialization is
    impossible.
  • It limits the use of inheritance and polymorphism
    in the coding.
  • For Hibernate.
  • Supports both of Fine-grained vs Coarse-grained
  • Provide more flexibility.

4
HBM hibernate mapping files
  • ltclassgt
  • matches the pojo to table
  • ltidgt
  • identifies the PK
  • There are many different types of generators
  • Increment
  • native
  • ltpropertygt mapping a class field to a table
    column
  • ltsetgt subclass
  • carDTO.hbm.xml
  • But, this task seems time-consuming
  • Is there any automatic way to generate mapping
    file?

5
XDoclet can help
  • Automate the generating of the
  • mapping xml file.
  • By adding comments to your pojo.
  • Example
  • carDTO.java

6
Service Descriptor file
  • Hibernate MBean Service Descriptor file
  • ltmbeansgt
  • Names the service and specifies the implementing
    class
  • ltDialectgt
  • tells Hibernate which type of database it is
    talking to.
  • ltSessionFactoryNamegt
  • the global JNDI name for the services
    sessionfactory (we need it in jboss-web.xml)
  • ltCacheProvideClassgt
  • element tells Hibernate what caching strategy to
    use!
  • ..
  • See Example
  • Hibernate-service.xml

7
Create a HAR
  • Hibernate applications are bundled up in
  • Hibernate Archive (HAR)
  • See har_build.xml

8
Add the HAR to EAR
  • HARs are not standard parts of a J2EE EAR file
  • JBoss looks for jboss-app.xml
  • See example jboss-app.xml
  • Now lteargt task now includes this file along with
    the traditional application.xml
  • See example ear_build.xml

9
Create JNDI Lookup
  • Create a JNDI reference
  • ltres-ref-namegt is the local name
  • ltjndi-namegt is global which matches the setting
    in hibernate-service.xml
  • See jboss-web.xml
  • web.xml file
  • Generated automatically by XDoclet
  • See ControllerServlet.java

10
Hibernate Checklist
  • Add Hibernate tags to the CarDTO
  • Created a Hibernate MBean service descriptor
  • Bundled these files up in a HAR
  • Created a JNDI reference

11
CRUD
  • CRUD (Create,Read,Update,and Delete)
  • are the four basic functions of persistent
    storage,
  • a major part of nearly all computer software.
    Sometimes
  • CRUD is expanded with the words retrieve or
    destroy.
  • Create or add new entries
  • Read or view existing entries
  • Update or edit existing entries
  • Delete existing entries

12
Thank You !
  • SHAOJIAN ZHU CHIH-HUNG CHO
Write a Comment
User Comments (0)
About PowerShow.com