SlideShare a Scribd company logo
SQLITE
Object Relational Mapping for SQLite in Java
Quick Introduction
By:
Morteza Zakeri
Fall 2016
Why using OO Programing?
Why using ORM?
Advantages and Disadvantages?
SQLite ORM
Installation
Connection
Create V.S. Relational Creation
Read V.S. Relational Read
Update V.S. Relational Creation
Delete V.S. Relational Creation
2
Agenda
Why using OO programing?
 Because OOP insists that you think about what you expose to the outside
world, it lets you change the implementation of an object without affecting
any other code. (Encapsulation)
 Because it allows you to have many different functions, all with the same
name, all doing the same job, but on different data. (Polymorphism)
 Because it lets you write generic code: which will work with a range of data,
so you don't have to write basic stuff over, and over again. (Generics)
 Because it lets you write a set of functions, then expand them in different
direction without changing or copying them in any way. (Inheritance)
3
Why using ORM?
ORM...
Performs Object-Relational Mapping. The idea is that Objects come first, and the
fact that they're persisted in relational databases happens to be what they do.
Often, such mappers might as well persist objects into non-relational data stores,
such as MongoDB.
SQL...
Does the inverse. It is designed to take full advantage of the relational data
model and has nothing to do with object-oriented design. You may, of course,
still map relational data (result sets, tuples, records, etc.) onto objects if you
wish.
4
Advantages
 1.Speeds-up Development
 2. Reduces Development Time
 3. Reduces Development Costs
 4.Code Reuse
 5.Application Design
 6.Application Maintainability
5
Disadvantages
1. ORM makes life easier but developers will eventually skip
learning SQL and database internals.
2. There will be some overhead involved using ORM. If the
database is accessed directly then developers are having
some control and they could fine tune its performance.
6
SQLite ORM
 SQLite is an in-process library that implements a self-contained,
serverless, zero-configuration, transactional SQL database engine. It is
the one database, which is zero-configured, that means like other
database you do not need to configure it in your system.
7
Installation
 Download core and java jars file from:
http://repo1.maven.org/maven2/com/j256/ormlite/
Copy jars into libs folder
 Right click on each jar file and choose “add as library”
 Usage in source code
8
Connection
 DataConnectionManager.init("database/test.db");
9
Create in SQLite
 CREATE TABLE table_name
(
column_name1 data_type(size),
column_name2 data_type(size),
column_name3 data_type(size),
....
);
10
Create in SQL
 public class User {
@AutoIncrement
@PrimaryKey
int id;
String username;
String password;
Select
 SQLite ORM:
User u = SqlStatement.select(User.class).
where(“username”).eq(username).getList()
11
• SQL:
Select *
From user
Where username =“username”
Update
 SQLite ORM:
public void update password (string user name,string password) {
User u = null ;
u = Sql Statement.select(User . class).where(“username”).
eq (username).get First();
u. set Password(password);
SqlStatement.update(u).execute();
}
12
Update in SQL
Update user
Set password=“zxc23”
Where username=“ali”
13
Delete in Sqlite ORM
Public void deleteuser(string username){
SqlStatement.delete(User.class).where (“username”).
eq(username).execute();
}
14
Delete From user
Where username=“username”
Delete in SQL
Thank you for your attention

More Related Content

PPTX
9-roslyn-guidelines
PPTX
7-clean-code
PPTX
PDF
PRIME OOPSLA12 paper
PPTX
Terry Reese - Real-world data editing with MarcEdit
PPTX
ExSchema
DOCX
C# Unit5 Notes
PDF
GENERIC CODE CLONING METHOD FOR DETECTION OF CLONE CODE IN SOFTWARE DEVELOPMENT
9-roslyn-guidelines
7-clean-code
PRIME OOPSLA12 paper
Terry Reese - Real-world data editing with MarcEdit
ExSchema
C# Unit5 Notes
GENERIC CODE CLONING METHOD FOR DETECTION OF CLONE CODE IN SOFTWARE DEVELOPMENT

Similar to SQLite and object-relational mapping in Java (20)

PPTX
JAVA_VR23_OOPS THROUGH JAVA PPT UNIT-1.pptx
PPT
Fundamentals of JAVA
PDF
What is Object-Oriented Programming (OOP) and Why Do We Need It?
PPT
10 interesting things about java
PDF
Linux Assignment 3
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Presentation5
PPTX
java slides
PDF
Spring Framework Tutorial | VirtualNuggets
DOCX
Codeigniter
PPT
Os Owens
PDF
Java Developer Roadmap PDF By ScholarHat
PPTX
Java-Development-A-Comprehensive-Guide.pptx
PPS
Jump start to OOP, OOAD, and Design Pattern
PPT
Jump Start To Ooad And Design Patterns
PDF
Node.js Development Tools
PPTX
Industrial training
PDF
Jooq java object oriented querying
PDF
Getting Started with Sql Server Compact Edition
PDF
Getting Started with SQL Server Compact Edition 3.51
JAVA_VR23_OOPS THROUGH JAVA PPT UNIT-1.pptx
Fundamentals of JAVA
What is Object-Oriented Programming (OOP) and Why Do We Need It?
10 interesting things about java
Linux Assignment 3
OOP with Java - Java Introduction (Basics)
Presentation5
java slides
Spring Framework Tutorial | VirtualNuggets
Codeigniter
Os Owens
Java Developer Roadmap PDF By ScholarHat
Java-Development-A-Comprehensive-Guide.pptx
Jump start to OOP, OOAD, and Design Pattern
Jump Start To Ooad And Design Patterns
Node.js Development Tools
Industrial training
Jooq java object oriented querying
Getting Started with Sql Server Compact Edition
Getting Started with SQL Server Compact Edition 3.51
Ad

More from Morteza Zakeri (20)

PPTX
Antlr part3 getting_started_in_c_sharp
PPTX
Antlr part1 introduction
PPTX
Antlr part2 getting_started_in_java
PPTX
8-bad-smells
PPTX
3-use-casemodelling
PPTX
5-modular-design
PPTX
4-architectural-views
PPTX
2-requirements-modelling
PPTX
1-requirements-elicitation
PDF
Analysis of Social Phenomena Using Machine Learning Techniques: A Mixed Resea...
PDF
Internet of Things: Middle-ware Platforms, Security, and Intrusion Detection
PDF
Community Detection with Genetic Algorithm
PPTX
SpotifyX Architectural Review
PDF
An overview of anomaly detection techniques
PPTX
Apache Mesos: Architecture, Design and Code Review
PPTX
یادگیری توالی به توالی با شبکه های عصبی
PDF
Sequence to sequence learning with neural networks
PDF
Bridge Management System Using NoSQL Solutions
PDF
Extracting architectural model of software from source code
PDF
Software Fault Avoidance in Implementation
Antlr part3 getting_started_in_c_sharp
Antlr part1 introduction
Antlr part2 getting_started_in_java
8-bad-smells
3-use-casemodelling
5-modular-design
4-architectural-views
2-requirements-modelling
1-requirements-elicitation
Analysis of Social Phenomena Using Machine Learning Techniques: A Mixed Resea...
Internet of Things: Middle-ware Platforms, Security, and Intrusion Detection
Community Detection with Genetic Algorithm
SpotifyX Architectural Review
An overview of anomaly detection techniques
Apache Mesos: Architecture, Design and Code Review
یادگیری توالی به توالی با شبکه های عصبی
Sequence to sequence learning with neural networks
Bridge Management System Using NoSQL Solutions
Extracting architectural model of software from source code
Software Fault Avoidance in Implementation
Ad

Recently uploaded (20)

PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Transform Your Business with a Software ERP System
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
AI in Product Development-omnex systems
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Understanding Forklifts - TECH EHS Solution
PDF
top salesforce developer skills in 2025.pdf
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
How Creative Agencies Leverage Project Management Software.pdf
Reimagine Home Health with the Power of Agentic AI​
wealthsignaloriginal-com-DS-text-... (1).pdf
PTS Company Brochure 2025 (1).pdf.......
Transform Your Business with a Software ERP System
Odoo POS Development Services by CandidRoot Solutions
AI in Product Development-omnex systems
Wondershare Filmora 15 Crack With Activation Key [2025
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
2025 Textile ERP Trends: SAP, Odoo & Oracle
How to Migrate SBCGlobal Email to Yahoo Easily
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Odoo Companies in India – Driving Business Transformation.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Understanding Forklifts - TECH EHS Solution
top salesforce developer skills in 2025.pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...

SQLite and object-relational mapping in Java

  • 1. SQLITE Object Relational Mapping for SQLite in Java Quick Introduction By: Morteza Zakeri Fall 2016
  • 2. Why using OO Programing? Why using ORM? Advantages and Disadvantages? SQLite ORM Installation Connection Create V.S. Relational Creation Read V.S. Relational Read Update V.S. Relational Creation Delete V.S. Relational Creation 2 Agenda
  • 3. Why using OO programing?  Because OOP insists that you think about what you expose to the outside world, it lets you change the implementation of an object without affecting any other code. (Encapsulation)  Because it allows you to have many different functions, all with the same name, all doing the same job, but on different data. (Polymorphism)  Because it lets you write generic code: which will work with a range of data, so you don't have to write basic stuff over, and over again. (Generics)  Because it lets you write a set of functions, then expand them in different direction without changing or copying them in any way. (Inheritance) 3
  • 4. Why using ORM? ORM... Performs Object-Relational Mapping. The idea is that Objects come first, and the fact that they're persisted in relational databases happens to be what they do. Often, such mappers might as well persist objects into non-relational data stores, such as MongoDB. SQL... Does the inverse. It is designed to take full advantage of the relational data model and has nothing to do with object-oriented design. You may, of course, still map relational data (result sets, tuples, records, etc.) onto objects if you wish. 4
  • 5. Advantages  1.Speeds-up Development  2. Reduces Development Time  3. Reduces Development Costs  4.Code Reuse  5.Application Design  6.Application Maintainability 5
  • 6. Disadvantages 1. ORM makes life easier but developers will eventually skip learning SQL and database internals. 2. There will be some overhead involved using ORM. If the database is accessed directly then developers are having some control and they could fine tune its performance. 6
  • 7. SQLite ORM  SQLite is an in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. It is the one database, which is zero-configured, that means like other database you do not need to configure it in your system. 7
  • 8. Installation  Download core and java jars file from: http://repo1.maven.org/maven2/com/j256/ormlite/ Copy jars into libs folder  Right click on each jar file and choose “add as library”  Usage in source code 8
  • 10. Create in SQLite  CREATE TABLE table_name ( column_name1 data_type(size), column_name2 data_type(size), column_name3 data_type(size), .... ); 10 Create in SQL  public class User { @AutoIncrement @PrimaryKey int id; String username; String password;
  • 11. Select  SQLite ORM: User u = SqlStatement.select(User.class). where(“username”).eq(username).getList() 11 • SQL: Select * From user Where username =“username”
  • 12. Update  SQLite ORM: public void update password (string user name,string password) { User u = null ; u = Sql Statement.select(User . class).where(“username”). eq (username).get First(); u. set Password(password); SqlStatement.update(u).execute(); } 12
  • 13. Update in SQL Update user Set password=“zxc23” Where username=“ali” 13
  • 14. Delete in Sqlite ORM Public void deleteuser(string username){ SqlStatement.delete(User.class).where (“username”). eq(username).execute(); } 14 Delete From user Where username=“username” Delete in SQL
  • 15. Thank you for your attention