Presentation On MVC and ORM
Presentation On MVC and ORM
Presentation On MVC and ORM
A STORY
MVC
Model- Entity solely concerned with getting the
data, providing the data and being the data itself. (The role of cook)
Why MVC
Controller is separated from Model. (Concept of
multiple cooks)
MVC Frameworks
Different MVC frameworks have different implementations of these concepts. They provide prebuilt classes. They are extensible.
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.
BUSINESS LOGIC
SERVLETS
JSPs
admin
ABOUT STRUTS 2
Its an MVC framework Version 2 Gives us prebuilt classes for MVC that we can use / extend
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.
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
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.
The Problem
The Problem
Mapping member variables to columns Mapping Relationships Handling data types (esp. Boolean) Managing changes to object state
The Problem
Relational
Object
Mapping!
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
Supported Databases
HSQL DB2 MySQL PostgreSQL FrontBase Oracle H2 Sybase and many more
Supported Technologies
Xdoclet Spring J2EE Eclipse plug-ins Maven
Hibernate Architecture
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
HIBERNATE show_sql
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
HOME PAGE
Deleting a Record
Deleting a Record
PROJECT SUMMARY
OS
WINDOWS 8
Back End
Trainee At
ROAD AHEAD TECHNOLOGIES, JAIPUR Mentor: Mr. Abhishek Jain
THANK YOU