mvc + orm (with project implementation)
DESCRIPTION
The presentation contains description about: Servlets Frameworks MVC architecture Struts2 ORM framework Hibernate framework snapshot of various projects developed by myself.TRANSCRIPT
![Page 1: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/1.jpg)
PROJECT ON
STUDENT INFORMATION
SYSTEMSubmitted by:Prateek Chauhan
![Page 2: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/2.jpg)
A STORY
![Page 3: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/3.jpg)
![Page 4: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/4.jpg)
![Page 5: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/5.jpg)
![Page 6: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/6.jpg)
![Page 7: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/7.jpg)
![Page 8: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/8.jpg)
![Page 9: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/9.jpg)
![Page 10: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/10.jpg)
![Page 11: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/11.jpg)
![Page 12: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/12.jpg)
![Page 13: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/13.jpg)
![Page 14: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/14.jpg)
![Page 15: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/15.jpg)
![Page 16: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/16.jpg)
![Page 17: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/17.jpg)
![Page 18: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/18.jpg)
![Page 19: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/19.jpg)
![Page 20: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/20.jpg)
![Page 21: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/21.jpg)
![Page 22: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/22.jpg)
![Page 23: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/23.jpg)
![Page 24: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/24.jpg)
![Page 25: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/25.jpg)
![Page 26: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/26.jpg)
![Page 27: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/27.jpg)
![Page 28: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/28.jpg)
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)
![Page 29: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/29.jpg)
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)
![Page 30: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/30.jpg)
MVC Frameworks
• Different MVC frameworks have different implementations of these concepts.
• They provide prebuilt classes.• They are extensible.
![Page 31: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/31.jpg)
Popular Java MVC frameworks
• Struts• Struts 2• Springs MVC• Play• JSF• Wicket• Many More
![Page 32: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/32.jpg)
![Page 33: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/33.jpg)
Pattern vs. Framework
• Pattern is a set of guidelines on how to architect the application
• When we implement a pattern we need to have some 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 and libraries are provided by the MVC framework.
• Framework provides foundation classes and libraries.
![Page 34: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/34.jpg)
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 world experience.
![Page 35: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/35.jpg)
JSPs
BUSINESS LOGIC
SERVLETS
![Page 36: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/36.jpg)
![Page 37: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/37.jpg)
![Page 38: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/38.jpg)
![Page 39: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/39.jpg)
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)
![Page 40: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/40.jpg)
STRUTS 2 DISPATCHER: web.xml– StrutsPrepareAndExecuteFilter
(org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter)
![Page 41: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/41.jpg)
STRUTS 2 MODEL and VIEW
![Page 42: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/42.jpg)
STRUTS 2 MODEL and VIEW
admin
![Page 43: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/43.jpg)
STRUTS 2 MODEL and VIEW
![Page 44: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/44.jpg)
STRUTS 2 MODEL and VIEW
![Page 45: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/45.jpg)
STRUTS 2 CONTROLLERS- struts.xml
![Page 46: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/46.jpg)
ABOUT STRUTS 2
• It’s an MVC framework• Version 2• Gives us prebuilt classes for MVC that we can
use / extend
![Page 47: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/47.jpg)
HIBERNATE: AN APPROACH OF ORM
![Page 48: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/48.jpg)
JDBC• Standard Java API for database-independent connectivity between
the 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.
![Page 49: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/49.jpg)
JDBC
Pros of JDBC• Clean and simple SQL
processing• Good performance with
small data• Very good for small
applications• Simple syntax so easy to
learn
Cons of JDBC• Complex if it is used in large
projects• Large programming
overhead• No encapsulation• Hard to implement MVC
concept• Query is DBMS specific
![Page 50: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/50.jpg)
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 any performance issues.
![Page 51: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/51.jpg)
The Problem
![Page 52: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/52.jpg)
The Problem
• Mapping member variables to columns • Mapping Relationships• Handling data types (esp. Boolean)
• Managing changes to object state
![Page 53: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/53.jpg)
The Problem
Object
Relational
Mapping!
![Page 54: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/54.jpg)
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
![Page 55: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/55.jpg)
JAVA ORM Frameworks
• Enterprise JavaBeans Entity Beans• Java Data Objects• Castor• TopLink• Springs DAO• Hibernate• Many More
![Page 56: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/56.jpg)
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
![Page 57: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/57.jpg)
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 !
![Page 58: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/58.jpg)
Supported Databases
• HSQL• DB2• MySQL• PostgreSQL• FrontBase• Oracle• H2• Sybase and many more
![Page 59: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/59.jpg)
Supported Technologies
• Xdoclet Spring• J2EE• Eclipse plug-ins• Maven
![Page 60: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/60.jpg)
Hibernate Architecture
![Page 61: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/61.jpg)
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
![Page 62: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/62.jpg)
![Page 63: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/63.jpg)
HIBERNATE show_sql
![Page 64: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/64.jpg)
Hibernate Mapping Resource
![Page 65: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/65.jpg)
Hibernate Table Creation
![Page 66: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/66.jpg)
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
![Page 67: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/67.jpg)
PROJECT MODULE:CONTACT MANAGER
![Page 68: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/68.jpg)
HOME PAGE
![Page 69: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/69.jpg)
Deleting a Record
![Page 70: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/70.jpg)
Deleting a Record
![Page 71: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/71.jpg)
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
![Page 72: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/72.jpg)
Trainee At
• ROAD AHEAD TECHNOLOGIES, JAIPUR• Mentor: Mr. Abhishek Jain
![Page 73: MVC + ORM (with project implementation)](https://reader033.vdocuments.net/reader033/viewer/2022061114/54625f15af7959ba618b4c97/html5/thumbnails/73.jpg)
THANK YOU