0% found this document useful (0 votes)
162 views26 pages

Seminar Lab

The document discusses Spring and Hibernate frameworks. It provides an overview of Spring including what it is, its history, components like dependency injection and MVC, and advantages. It also discusses Hibernate as an ORM tool that handles object-relational mapping and minimizes JDBC code. Key benefits are that Spring and Hibernate simplify application development, are lightweight, and make the code reusable and easy to test.

Uploaded by

Saumya Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
162 views26 pages

Seminar Lab

The document discusses Spring and Hibernate frameworks. It provides an overview of Spring including what it is, its history, components like dependency injection and MVC, and advantages. It also discusses Hibernate as an ORM tool that handles object-relational mapping and minimizes JDBC code. Key benefits are that Spring and Hibernate simplify application development, are lightweight, and make the code reusable and easy to test.

Uploaded by

Saumya Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

SEMINAR LAB

Swami Keshwanand Institute of


Technology,Management and Gramothan
Jaipur – 302017

Topic: Spring and Hibernate


Submitted by: Saumya Singh(16ESKIT080)
Submitted to: Mrs. Shalini Singhal
What is Spring Framework?
• Spring Framework is on Java platform that provides
comprehensive infrastructure support for developing Java
applications. Spring handles the infrastructure so you can focus
on your application.

• Spring is a lightweight framework. It can be thought of as


a framework of frameworks because it provides support to
various frameworks such as Struts, Hibernate, EJB, JSF etc. The
framework, in broader sense, can be defined as a structure
where we find solution of the various technical problems.
A little bit of the history: Evolution of J2EE
Why Spring?
Spring in a nutshell:

• Very popular framework for building a java application.

• Initially a simpler and lightweight alternative to J2EE.

• Provides a large number of helper classes…..makes things easier.


What does the Spring Framework provide?

• Application context and dependency injection

• Data Access

• Spring MVC (Model View Controller)


Dependency Injection
• Dependency Injection (DI) is a design pattern that removes the
dependency from the programming code so that it can be easy to
manage and test the application. Dependency Injection makes our
programming code loosely coupled.

• Spring framework provides two ways to inject dependency


By Constructor
By Setter method
The car Example:
How to relate to Spring:
How spring works behind the scene
What is Spring MVC?
• A Spring MVC is a Java framework which is used to build web
applications. It follows the Model-View-Controller design pattern. It
implements all the basic features of a core spring framework like
Inversion of Control, Dependency Injection.

• A Spring MVC provides an elegant solution to use MVC in spring


framework by the help of DispatcherServlet.
Here, DispatcherServlet is a class that receives the incoming request
and maps it to the right resource such as controllers, models, and
views.
• Model - A model contains the data of the application. A data can be a
single object or a collection of objects.
• Controller - A controller contains the business logic of an application.
Here, the @Controller annotation is used to mark the class as the
controller.
• View - A view represents the provided information in a particular
format. Generally, JSP+JSTL is used to create a view page. Although
spring also supports other view technologies such as Apache Velocity,
Thymeleaf and FreeMarker.
……continued
A look at development process
Example:
Annotations in java:
• The @Required annotation :
applies to bean property setter methods and it indicates that the
affected bean property must be populated in XML configuration file at
configuration time.
Example:
@Required
Public void setlastname(String name)
{
this.name=name;
}
The override annotation:

• The @Override annotation indicates that the child class method is


over-writing its base class method.

• @Override
• public String getFortune() {
• // TODO Auto-generated method stub
• return null;
•}
The JSP(Java Server Pages)
• <html>
• <body>
• <p>Welcome to Spring MVC by Saumya Singh</p>
• </body>
• </html>
Output:
Advantages of Spring Framework
• Separate roles - The Spring MVC separates each role, where the model
object, controller, command object, view resolver, DispatcherServlet,
validator, etc.
• Light-weight - It uses light-weight servlet container to develop and deploy
your application.
• Rapid development - The Spring MVC facilitates fast and parallel
development.
• Reusable business code - Instead of creating new objects, it allows us to
use the existing business objects.
• Easy to test - In Spring, generally we create JavaBeans classes that enable
you to inject test data using the setter methods.
• Flexible Mapping - It provides the specific annotations that easily redirect
the page.
What is Hibernate?
• Hibernate is the framework for persisting/saving java objects in the
database.
• Hibernate is a Java framework that simplifies the development of Java
application to interact with the database. It is an open source,
lightweight, ORM (Object Relational Mapping) tool.
Why Hibernate?
• When a Java application needs to access database:
• open connection to database
• use JDBC driver to send SQL queries to database
• process the results that are returned
• close the connection.

BENEFITS OF HIBERNATE:
Hibernate handles all the low level sql tasks.
Minimizes the amount of JDBC code you have to develop.
Hibernate provides Object-to-Database Mapping(ORM)
ORM:
• The developer defines the mapping between java class and database
tables.
Saving the java object with Hibernate:
• Creating the object
• Storing the object
Retrieving the data from database:
References:

• Udemy course by Chad Darby


• Tutorial point and javaTpoint websites for the definations
• Images from www.luv2code.com
Thank you!

Any Questions?

You might also like