SlideShare una empresa de Scribd logo
1 de 7
By
            Sunkara Ravi Prakash
Software Architect(JAVA & VOIP SIP protocol)
                AFxisi Inc LLC
      sunkara.voip.expert@gmail.com
Integration of Springs framework in Hibernates.

         In this docs tells and explains to the Intermediate developers or
          programmers in java. Initial, should be understand how the
          Hibernate ORM framework tool works without integrating with
          springs.

         In Springs there are seven modules. Among them, for hibernate
          integrating with Spring, before that they have to know the
          Abstract DAO and Skeleton Design Patterns.

         Integration of Springs overcomes unnecessary of SessionFactory and
          Session objects of the Hibernate, so it has to close the sessions
          after the used transactions.

         Springs will construct the SessionFactory and Session object of
          Transaction persistence’s. So not to cares about the session
          closing object in Hibernate.

         Some Plug-in’s are they are which can do caring the session
          objects, If you’re going use the Struts2 with hibernates[which
          using AbstractGenricDAO Patterns with cacade pattern].

         But Springs is a AOP, Bean Factory Object patterns. It Can
          Integration different DB vendor in single applicationcontext. So
          Springs care their session objects persistence’s.

         In simply words, initializing the objects through xml and
          reference the objects from xml.



   The modules invoked in Spring and hibernate are.
 Spring Core, which is a IOC, primary component of BeanFactory, an
      Factory Pattern. The container is then responsible for hooking it
      all up. That describes in configure file.
     Spring DAO, module provides a JDBC-abstraction layer that reduces
      the need to do tedious JDBC coding and parsing of database-vendor
      specific error codes. Also, the JDBC package provides a way to do
      programmatic as well as declarative transaction management, not
      only for classes implementing special interfaces, but for all your
      POJOs (plain old Java objects).
     Spring ORM, Spring transaction management supports each of these
      ORM frameworks as well as JDBC.
     Spring AOP, which acts interceptor and proxyobject FactoryBean.




Org.springframework.jdbc,datasource.DriverManagerDataConfig,

      This is an initializing to the Driver connection of the database/s.
    Provides a utility class for easy DataSource access, a
    PlatformTransactionManager for a single DataSource, and various
    simple DataSource implementations.
    In a J2EE container, it is recommended to use a JNDI DataSource
    provided by the container. Such a DataSource can be exported as a
    DataSource bean in an ApplicationContext via JndiObjectFactoryBean,
    for seamless switching to and from a local DataSource bean like this
    class.


Org.springframework.beans.factory.config.PropertiesFacortyBean

      PropertiesFactoryBean, gets a hibernates properties,
      By setting the dialect of database.
    SPI interfaces and configuration-related convenience class for bean
    factory.
    Making the properties file from classpath location as properties
    instance to bean factory.


Org.springframework.orm.hibernate.LocalSessionFactoryBean


    Which returns the SessionFactory of hibernate.
    In config file, either mappingresource from files or
    class(annotions ).
    Reference bean object property of propertyfactorybean to
    localSessionFactoryBean.
    Note that switching to JndiObjectFactoryBean is just matter of
    configured

Org,springframework.org.hibernate.hibernateTransactionManager.
       @param of the sessionfactory object of LocalSessionFactoryBean
       @returns the Transactionmanager object.
     Should access bean reference of SessionFactory to
     HibenateTransactionManager.
The above class most do configure in spring context initial to access the
Business Objects.

For Business Model Object.

If Transaction object can use proxy object then using
Org,springframework.transaction.inteceptor.transactionprocyFactaryBean

          Standard AOP proxyFactoryBean.
          AOP-based solution for declarative transaction demarcation.
          Its an interceptor for hibernate transaction manager.

          So application context file will maps the object of the DAO
    class.
          In TransactionproxyFactoryBean, has to initialize or pass by
    objects of sessionfactory and transactionmanager in that class
    constructor.

How to access the Buniness model object to that
transactionproxyFactoryBean object.

          Maps the bean object to the reference of SeesionFactory object
    of LocalSessionFactoryBean,

          And By targeting the object of the TranctionproxyFactaryBean
    object to the targets objects.
          Every Service implementation of DAO Abstract class or interface
    class, should set bean object. All beans to reference local
    transactionproxyFactoryBean for targets and initial sessionfactory
    bean objects.
Spring AOP.                                                                                     Spring orm.hibernate3
Transaction.interceptor.TransactionProxyFactoryBean.                                            LocalSessionFactoryBean, factory bean
                                                                                                that create local hibernate
                                                                                                SessionFactory instancr.
                                                                                                tranactionManager for sinlge hibernate
                                                                                                sessionfactory.




                                                       Spring context.
                                                       DataSource of drivermanager, this
                                                       jndiobjectfactorybean



                                                                                                       Spring DAO.
                                                                                                       Exception handler to orm



Spring Core.
Bean.factory.config.ProperrtiesBeanFactory
class.
Bean name id.




              Developers has understands the how AOP will calls the Objects of bean
              name.
                   Before that lets gives a sample applicationcontext.xml of hibernate
                   and springs.
                         <bean id="dataSoruce" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
                                 <property name="driverClassName">
                                        <value>com.mysql.jdbc.Driver</value>

                                         </property>
                                         <property name="url" value="jdbc:mysql://localhost/springdb"/>
                                         <property name="username" value="root"/>
                                         <property name="password" value="admin1234"/>

                               </bean>
                             Above bean is a spring context module, for jndiobjectfactorybean
                             Jdbc jndi property, dataSource.

                               <bean id="hibernateProperties"
                               class="org.springframework.beans.factory.config.PropertiesFactoryBean">
                                     <property name="properties">
                                           <props>
                                                 <prop
                               key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop  key="hibernate.connection.pool_size">10</prop>
                   <prop  key="show_sql">false</prop>
                   <prop  key="hibernate.hbm2ddl.auto">update</prop>
                   <prop  key="hibernate.transaction.factory_class">
                          org.hibernate.transaction.JDBCTransactionFactory
                    </prop>
              </props>
        </property>
  </bean>
hibernateProperties bean object, from spring core, for
factoryBean object.


 <bean id="exampleSessionFactory"
 class="org.springframework.orm.hibernate3.LocalSessionFactoryBe
 an">
       <property name="dataSource" >
             <ref local="dataSoruce"/>
       </property>
       <property name="hibernateProperties">
             <ref bean="hibernateProperties"/>
       </property>
       <property name="mappingResources">
             <list>
                    <value>Person.hbm.xml</value>
             </list>
       </property>
 </bean>

 <bean id="transactionManager"
 class="org.springframework.orm.hibernate3.HibernateTransactionM
 anager">
       <property name="sessionFactory"><ref
 bean="exampleSessionFactory"/></property>
 </bean>

 ExampleSessionFactory, Spring orm module, which local reference
instance to dataSource and bean reference instance to
hibernatesproperties. Mapping resouuces just like hibernate
mapping hbm files. Transactionmanager, local reference
sessionfacory object instance to HibernateTranactionManager.

Below Beans are implementing of the business interface.
  <bean id="personDetails" class="com.in.db.impl.PersonImpls">
        <property name="sessionFactory">
              <ref local="exampleSessionFactory"/>
        </property>
  </bean>
  personDetails bean object, local reference to the
  SessionFactory instance.


 Below one, Transactonal proxy for business object
 personDetails.

 <bean id="personsDAO"
 class="org.springframework.transaction.interceptor.TransactionP
 roxyFactoryBean">
       <property name="transactionManager">
             <ref local="transactionManager"/>
       </property>
<property name="target">
             <ref local="personDetails"/>
       </property>
       <property name="transactionAttributes">
             <props>
                   <prop
 key="addPerson">PROPAGATION_REQUIRED</prop>
             </props>
       </property>
 </bean>



Now, for example lets lets do business technique on spring and
hibernate, So you want to add the persons details by using
spring and hibernate.
            Let gets the object of application context, by this
object, getting beanproperty personDetails to PersonImpl,
PersonImpl object model addPerson method will save the person
details table.

      PersonImpl personimpls =
(PersonImpl)xmlbeancontext(“personDetails”);
Personimpl.addPerson(person); // person is persistence class,

 Indirectly is call to spring AOP proxy object to get the
 instances object (implicit object, we called like).


 Now You Under Standard the simple Spring Hibernate

Más contenido relacionado

La actualidad más candente

Java Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet BasicJava Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet BasicIMC Institute
 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Examplekamal kotecha
 
Java Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAXJava Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAXIMC Institute
 
Spring talk111204
Spring talk111204Spring talk111204
Spring talk111204ealio
 
5050 dev nation
5050 dev nation5050 dev nation
5050 dev nationArun Gupta
 
Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2Fahad Golra
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questionsArun Vasanth
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsCarol McDonald
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentationguest11106b
 
Lecture 5 JSTL, custom tags, maven
Lecture 5   JSTL, custom tags, mavenLecture 5   JSTL, custom tags, maven
Lecture 5 JSTL, custom tags, mavenFahad Golra
 
Java Web Programming [7/9] : Struts2 Basics
Java Web Programming [7/9] : Struts2 BasicsJava Web Programming [7/9] : Struts2 Basics
Java Web Programming [7/9] : Struts2 BasicsIMC Institute
 
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUGThe Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUGArun Gupta
 
Spring design-juergen-qcon
Spring design-juergen-qconSpring design-juergen-qcon
Spring design-juergen-qconYiwei Ma
 

La actualidad más candente (20)

Java Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet BasicJava Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet Basic
 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Example
 
Java Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAXJava Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAX
 
Jsp
JspJsp
Jsp
 
The Rails Way
The Rails WayThe Rails Way
The Rails Way
 
Jsf
JsfJsf
Jsf
 
Spring talk111204
Spring talk111204Spring talk111204
Spring talk111204
 
Java EE and Glassfish
Java EE and GlassfishJava EE and Glassfish
Java EE and Glassfish
 
5050 dev nation
5050 dev nation5050 dev nation
5050 dev nation
 
Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2
 
Jsp Notes
Jsp NotesJsp Notes
Jsp Notes
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questions
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.js
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
 
Lecture 5 JSTL, custom tags, maven
Lecture 5   JSTL, custom tags, mavenLecture 5   JSTL, custom tags, maven
Lecture 5 JSTL, custom tags, maven
 
Java Web Programming [7/9] : Struts2 Basics
Java Web Programming [7/9] : Struts2 BasicsJava Web Programming [7/9] : Struts2 Basics
Java Web Programming [7/9] : Struts2 Basics
 
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUGThe Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
 
EJB Clients
EJB ClientsEJB Clients
EJB Clients
 
Spring design-juergen-qcon
Spring design-juergen-qconSpring design-juergen-qcon
Spring design-juergen-qcon
 
Hibernate 18052012
Hibernate 18052012Hibernate 18052012
Hibernate 18052012
 

Similar a Integration Of Springs Framework In Hibernates

Configuring jpa in a Spring application
Configuring jpa in a  Spring applicationConfiguring jpa in a  Spring application
Configuring jpa in a Spring applicationJayasree Perilakkalam
 
Hibernate Developer Reference
Hibernate Developer ReferenceHibernate Developer Reference
Hibernate Developer ReferenceMuthuselvam RS
 
Session 39 - Hibernate - Part 1
Session 39 - Hibernate - Part 1Session 39 - Hibernate - Part 1
Session 39 - Hibernate - Part 1PawanMM
 
02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questions02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questionsDhiraj Champawat
 
Ejb - september 2006
Ejb  - september 2006Ejb  - september 2006
Ejb - september 2006achraf_ing
 
Hibernate tutorial for beginners
Hibernate tutorial for beginnersHibernate tutorial for beginners
Hibernate tutorial for beginnersRahul Jain
 
Spring db-access mod03
Spring db-access mod03Spring db-access mod03
Spring db-access mod03Guo Albert
 
Hibernate - Part 1
Hibernate - Part 1Hibernate - Part 1
Hibernate - Part 1Hitesh-Java
 
Spring 3.1: a Walking Tour
Spring 3.1: a Walking TourSpring 3.1: a Walking Tour
Spring 3.1: a Walking TourJoshua Long
 

Similar a Integration Of Springs Framework In Hibernates (20)

Configuring jpa in a Spring application
Configuring jpa in a  Spring applicationConfiguring jpa in a  Spring application
Configuring jpa in a Spring application
 
Hibernate Developer Reference
Hibernate Developer ReferenceHibernate Developer Reference
Hibernate Developer Reference
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Session 39 - Hibernate - Part 1
Session 39 - Hibernate - Part 1Session 39 - Hibernate - Part 1
Session 39 - Hibernate - Part 1
 
02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questions02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questions
 
Ejb - september 2006
Ejb  - september 2006Ejb  - september 2006
Ejb - september 2006
 
Hibernate tutorial for beginners
Hibernate tutorial for beginnersHibernate tutorial for beginners
Hibernate tutorial for beginners
 
Hibernate.pdf
Hibernate.pdfHibernate.pdf
Hibernate.pdf
 
Sel study notes
Sel study notesSel study notes
Sel study notes
 
Spring db-access mod03
Spring db-access mod03Spring db-access mod03
Spring db-access mod03
 
Hibernate - Part 1
Hibernate - Part 1Hibernate - Part 1
Hibernate - Part 1
 
TY.BSc.IT Java QB U6
TY.BSc.IT Java QB U6TY.BSc.IT Java QB U6
TY.BSc.IT Java QB U6
 
Hibernate
HibernateHibernate
Hibernate
 
Hibernate 3
Hibernate 3Hibernate 3
Hibernate 3
 
Spring
SpringSpring
Spring
 
Spring
SpringSpring
Spring
 
Spring
SpringSpring
Spring
 
Spring database - part2
Spring database -  part2Spring database -  part2
Spring database - part2
 
Hibernate in Nutshell
Hibernate in NutshellHibernate in Nutshell
Hibernate in Nutshell
 
Spring 3.1: a Walking Tour
Spring 3.1: a Walking TourSpring 3.1: a Walking Tour
Spring 3.1: a Walking Tour
 

Último

Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 

Último (20)

Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 

Integration Of Springs Framework In Hibernates

  • 1. By Sunkara Ravi Prakash Software Architect(JAVA & VOIP SIP protocol) AFxisi Inc LLC sunkara.voip.expert@gmail.com
  • 2. Integration of Springs framework in Hibernates.  In this docs tells and explains to the Intermediate developers or programmers in java. Initial, should be understand how the Hibernate ORM framework tool works without integrating with springs.  In Springs there are seven modules. Among them, for hibernate integrating with Spring, before that they have to know the Abstract DAO and Skeleton Design Patterns.  Integration of Springs overcomes unnecessary of SessionFactory and Session objects of the Hibernate, so it has to close the sessions after the used transactions.  Springs will construct the SessionFactory and Session object of Transaction persistence’s. So not to cares about the session closing object in Hibernate.  Some Plug-in’s are they are which can do caring the session objects, If you’re going use the Struts2 with hibernates[which using AbstractGenricDAO Patterns with cacade pattern].  But Springs is a AOP, Bean Factory Object patterns. It Can Integration different DB vendor in single applicationcontext. So Springs care their session objects persistence’s.  In simply words, initializing the objects through xml and reference the objects from xml. The modules invoked in Spring and hibernate are.
  • 3.  Spring Core, which is a IOC, primary component of BeanFactory, an Factory Pattern. The container is then responsible for hooking it all up. That describes in configure file.  Spring DAO, module provides a JDBC-abstraction layer that reduces the need to do tedious JDBC coding and parsing of database-vendor specific error codes. Also, the JDBC package provides a way to do programmatic as well as declarative transaction management, not only for classes implementing special interfaces, but for all your POJOs (plain old Java objects).  Spring ORM, Spring transaction management supports each of these ORM frameworks as well as JDBC.  Spring AOP, which acts interceptor and proxyobject FactoryBean. Org.springframework.jdbc,datasource.DriverManagerDataConfig, This is an initializing to the Driver connection of the database/s. Provides a utility class for easy DataSource access, a PlatformTransactionManager for a single DataSource, and various simple DataSource implementations. In a J2EE container, it is recommended to use a JNDI DataSource provided by the container. Such a DataSource can be exported as a DataSource bean in an ApplicationContext via JndiObjectFactoryBean, for seamless switching to and from a local DataSource bean like this class. Org.springframework.beans.factory.config.PropertiesFacortyBean PropertiesFactoryBean, gets a hibernates properties, By setting the dialect of database. SPI interfaces and configuration-related convenience class for bean factory. Making the properties file from classpath location as properties instance to bean factory. Org.springframework.orm.hibernate.LocalSessionFactoryBean Which returns the SessionFactory of hibernate. In config file, either mappingresource from files or class(annotions ). Reference bean object property of propertyfactorybean to localSessionFactoryBean. Note that switching to JndiObjectFactoryBean is just matter of configured Org,springframework.org.hibernate.hibernateTransactionManager. @param of the sessionfactory object of LocalSessionFactoryBean @returns the Transactionmanager object. Should access bean reference of SessionFactory to HibenateTransactionManager.
  • 4. The above class most do configure in spring context initial to access the Business Objects. For Business Model Object. If Transaction object can use proxy object then using Org,springframework.transaction.inteceptor.transactionprocyFactaryBean Standard AOP proxyFactoryBean. AOP-based solution for declarative transaction demarcation. Its an interceptor for hibernate transaction manager. So application context file will maps the object of the DAO class. In TransactionproxyFactoryBean, has to initialize or pass by objects of sessionfactory and transactionmanager in that class constructor. How to access the Buniness model object to that transactionproxyFactoryBean object. Maps the bean object to the reference of SeesionFactory object of LocalSessionFactoryBean, And By targeting the object of the TranctionproxyFactaryBean object to the targets objects. Every Service implementation of DAO Abstract class or interface class, should set bean object. All beans to reference local transactionproxyFactoryBean for targets and initial sessionfactory bean objects.
  • 5. Spring AOP. Spring orm.hibernate3 Transaction.interceptor.TransactionProxyFactoryBean. LocalSessionFactoryBean, factory bean that create local hibernate SessionFactory instancr. tranactionManager for sinlge hibernate sessionfactory. Spring context. DataSource of drivermanager, this jndiobjectfactorybean Spring DAO. Exception handler to orm Spring Core. Bean.factory.config.ProperrtiesBeanFactory class. Bean name id. Developers has understands the how AOP will calls the Objects of bean name. Before that lets gives a sample applicationcontext.xml of hibernate and springs. <bean id="dataSoruce" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url" value="jdbc:mysql://localhost/springdb"/> <property name="username" value="root"/> <property name="password" value="admin1234"/> </bean> Above bean is a spring context module, for jndiobjectfactorybean Jdbc jndi property, dataSource. <bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="properties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
  • 6. <prop key="hibernate.connection.pool_size">10</prop> <prop key="show_sql">false</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.transaction.factory_class"> org.hibernate.transaction.JDBCTransactionFactory </prop> </props> </property> </bean> hibernateProperties bean object, from spring core, for factoryBean object. <bean id="exampleSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBe an"> <property name="dataSource" > <ref local="dataSoruce"/> </property> <property name="hibernateProperties"> <ref bean="hibernateProperties"/> </property> <property name="mappingResources"> <list> <value>Person.hbm.xml</value> </list> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionM anager"> <property name="sessionFactory"><ref bean="exampleSessionFactory"/></property> </bean> ExampleSessionFactory, Spring orm module, which local reference instance to dataSource and bean reference instance to hibernatesproperties. Mapping resouuces just like hibernate mapping hbm files. Transactionmanager, local reference sessionfacory object instance to HibernateTranactionManager. Below Beans are implementing of the business interface. <bean id="personDetails" class="com.in.db.impl.PersonImpls"> <property name="sessionFactory"> <ref local="exampleSessionFactory"/> </property> </bean> personDetails bean object, local reference to the SessionFactory instance. Below one, Transactonal proxy for business object personDetails. <bean id="personsDAO" class="org.springframework.transaction.interceptor.TransactionP roxyFactoryBean"> <property name="transactionManager"> <ref local="transactionManager"/> </property>
  • 7. <property name="target"> <ref local="personDetails"/> </property> <property name="transactionAttributes"> <props> <prop key="addPerson">PROPAGATION_REQUIRED</prop> </props> </property> </bean> Now, for example lets lets do business technique on spring and hibernate, So you want to add the persons details by using spring and hibernate. Let gets the object of application context, by this object, getting beanproperty personDetails to PersonImpl, PersonImpl object model addPerson method will save the person details table. PersonImpl personimpls = (PersonImpl)xmlbeancontext(“personDetails”); Personimpl.addPerson(person); // person is persistence class, Indirectly is call to spring AOP proxy object to get the instances object (implicit object, we called like). Now You Under Standard the simple Spring Hibernate