Presentation on MVC and ORM

73
PROJECT ON STUDENT INFORMATION SYSTEM

Transcript of Presentation on MVC and ORM

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 1/73

PROJECT ON

STUDENTINFORMATION

SYSTEM

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 2/73

A STORY

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 3/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 4/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 5/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 6/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 7/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 8/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 9/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 10/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 11/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 12/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 13/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 14/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 15/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 16/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 17/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 18/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 19/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 20/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 21/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 22/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 23/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 24/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 25/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 26/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 27/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 28/73

MVC

• Model- Entity solely concerned with getting the

data, providing the data and being the data itself.

(The role of cook)

• View- Renders the model into a form that is actually

displayable. (The role of decorator) 

• Controller- Orchestrates the entire architecture,

passes the necessary details to models and then calls

the right view in order to do the presentation. (The

roll of stickman)

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 29/73

Why MVC

• Controller is separated from Model. (Concept of 

multiple cooks)

• View is separated from Model. (Cook doesn’t worry

about the presentation of food)

• View is separated from Controller. (Stickmen

doesn’t worry about the presentation) 

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 30/73

MVC Frameworks

• Different MVC frameworks have different

implementations of these concepts.

• They provide prebuilt classes.

• They are extensible.

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 31/73

Popular Java MVC frameworks

• Struts

• Struts 2

• Springs MVC

• Play

• JSF

• Wicket

• Many More

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 32/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 33/73

Pattern vs. Framework

• Pattern is a set of guidelines

on how to architect the

application

• When we implement a

pattern we need to havesome classes and libraries

• Thus, pattern is the way

you can architect your

application.

• Framework helps us to

follow a particular pattern

when we are building a web

application

• These prebuilt classes andlibraries are provided by the

MVC framework.

• Framework provides

foundation classes andlibraries.

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 34/73

Advantages of Frameworks

• Gets us started really quickly- If we are developing a

number of web applications on a similar pattern, then instead

of rewriting the same classes again and again, we have a set

of classes and libraries that make our work easier.

• Leverages industries best practices- If we use MVC

framework, it proves to be really helpful, because the way the

framework has been designed, it consumes a lot of real worldexperience.

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 35/73

JSPs

BUSINESS LOGIC

SERVLETS

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 36/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 37/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 38/73

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 39/73

STRUTS 2 DISPATCHER: web.xml

• Verifies the request URI and determine which action to

invoke.

• Two types of dispatchers are used

 – Filter Dispatcher (org.apache.struts2.dispatcher.FilterDispatcher)

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 40/73

STRUTS 2 DISPATCHER: web.xml

 – StrutsPrepareAndExecuteFilter (org.apache.struts2.dispatcher.ng.filter

.StrutsPrepareAndExecuteFilter)

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 41/73

STRUTS 2 MODEL and VIEW

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 42/73

STRUTS 2 MODEL and VIEW 

admin

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 43/73

STRUTS 2 MODEL and VIEW 

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 44/73

STRUTS 2 MODEL and VIEW 

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 45/73

STRUTS 2 CONTROLLERS- struts.xml

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 46/73

ABOUT STRUTS 2

• It’s an MVC framework 

•Version 2

• Gives us prebuilt classes for MVC that we can

use / extend

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 47/73

HIBERNATE: AN APPROACH OF

ORM

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 48/73

JDBC

•Standard Java API for database-independent connectivity betweenthe Java programming language and a wide range of databases.

• JDBC provides a flexible architecture to write a database

independent applications that can run on different platforms and

interact with different DBMS without any modification.

• JDBC includes APIs for each of the task commonly associated with

database usage:

 – Making a connection to a database.

 – Creating SQL statements.

 – Executing SQL queries in the database.

 – Viewing & modifying the resulting records.

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 49/73

JDBC

Pros of JDBC

• Clean and simple SQL

processing

Good performance withsmall data

• Very good for small

applications

Simple syntax so easy tolearn

Cons of JDBC

• Complex if it is used in large

projects

Large programmingoverhead

• No encapsulation

• Hard to implement MVC

concept• Query is DBMS specific

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 50/73

HIBERNATE

• An ORM tool

• Used in the data layer of application, for

persisting application data into database

• Implements JPA

 – This means that it follows a set of standards for

implementing persistence, so that in future if we want to

change from Hibernate, we can easily do it without anyperformance issues.

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 51/73

The Problem

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 52/73

The Problem  

• Mapping member variables to columns

• Mapping Relationships

• Handling data types (esp. Boolean)

• Managing changes to object state

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 53/73

The Problem

Object

Relational

Mapping!

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 54/73

ORM

• Converts data between relational databases and

object oriented programming languages

• Advantages over JDBC

 –Lets business code access objects rather than DB tables

 – Hides details of SQL queries from OO logic

 – Based on JDBC ‘under the hood’ 

 – No need to deal with database implementation

 – Transaction Management and automatic key generation

 – Fast development of applications

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 55/73

 JAVA ORM Frameworks

• Enterprise JavaBeans Entity Beans

• Java Data Objects

• Castor

• TopLink

• Springs DAO

Hibernate• Many More

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 56/73

Saving without Hibernate

• JDBC Database Configuration

• The Model Object

• Service method to create the model object

• Database Design

• DAO method to save the object using SQL

queries

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 57/73

The Hibernate Way 

• JDBC Database Configuration – Hibernate

Configuration

• The Model object – Annotations

• Service method to create the model object – 

Use the Hibernate API

• Database Design – Not Needed !

• DAO method to save the objects using SQL

queries – Not Needed !

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 58/73

Supported Databases

• HSQL

• DB2

• MySQL

• PostgreSQL

• FrontBase

• Oracle

• H2• Sybase and many more

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 59/73

Supported Technologies

• Xdoclet Spring

• J2EE

• Eclipse plug-ins

• Maven

Hibernate Architecture

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 60/73

Hibernate Architecture

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 61/73

HIBERNATE CONFIGURATION 

• Refers to the hibernate configuration file that is

hibernate.cfg.xml

• This file is read first by the hibernate framework and the data

flow is done accordingly

• Consists of properties and mapping resource

• Mapping resource can consist of a xml file or a POJO class

with annotations

• Consists of properties such as connection url, driver class,

username, password, dialect and hbm2ddl.auto

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 62/73

HIBERNATE show sql

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 63/73

HIBERNATE show_sql 

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 64/73

Hibernate Mapping Resource

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 65/73

Hibernate Table Creation

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 66/73

Features of Hibernate

• Implementation of JPA

• ORM tool

• Has data caching abilities

• Provides an entire different SQL implementation known as

HQL, which is the basis of NoSQL databases

• Can persist the following relations in database, using

annotations as well as xml files.

 – One to One

 – One to Many

 – Many to One

 – Many to many

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 67/73

PROJECT MODULE:CONTACT MANAGER

HOME PAGE

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 68/73

HOME PAGE

Deleting a Record

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 69/73

Deleting a Record

Deleting a Record

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 70/73

Deleting a Record

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 71/73

PROJECT SUMMARY

HARDWARE SPECIFICATION SOFTWARE VERSION

MEMORY 10 GB IDE MyEclipse 8.0

RAM 128 MB Server Apache Tomcat 6.x

PROCESSOR 1.6 GHz Front End Struts 2.1.5

OS WINDOWS 8 Back End Hibernate 4 +

Oracle 10G XE

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 72/73

Trainee At

• ROAD AHEAD TECHNOLOGIES, JAIPUR

• Mentor: Mr. Abhishek Jain

7/27/2019 Presentation on MVC and ORM

http://slidepdf.com/reader/full/presentation-on-mvc-and-orm 73/73

THANK YOU