SlideShare a Scribd company logo
ORM
ORM
Object-relational mapping products integrate objectObject-relational mapping products integrate object
programming language capabilities with relationalprogramming language capabilities with relational
databasesdatabases
What is ORMLiteWhat is ORMLite
• Object Relational Mapping Lite (ORM Lite)Object Relational Mapping Lite (ORM Lite)
provides some lightweight functionality forprovides some lightweight functionality for
persisting Java objects to SQL databasespersisting Java objects to SQL databases
while avoiding the complexity and overheadwhile avoiding the complexity and overhead
of more standard ORM packages.of more standard ORM packages.
Features of ORMLiteFeatures of ORMLite
• Setup your classes by simply adding JavaSetup your classes by simply adding Java
annotations.annotations.
• EgEg @DatabaseTable(tableName =@DatabaseTable(tableName = "Contato""Contato"))
• Powerful abstract Database Access ObjectPowerful abstract Database Access Object
(DAO) classes(DAO) classes
• Flexible QueryBuilder to easily constructFlexible QueryBuilder to easily construct
simple and complex queries.simple and complex queries.
• Basic support for database transactions.Basic support for database transactions.
• Auto generates SQL to create and dropAuto generates SQL to create and drop
database tables.database tables.
Simple ExampleSimple Example
• @DatabaseTable(tableName =@DatabaseTable(tableName = "Contato""Contato")//table name)//table name
public classpublic class ContatoEntity {ContatoEntity {
@DatabaseField(generatedId =@DatabaseField(generatedId = truetrue))public int idpublic int id; //field name; //field name
@DatabaseField@DatabaseField public staticpublic static StringString discricodiscrico;;
@DatabaseField@DatabaseField publicpublic StringString ddiddi;;
@DatabaseField@DatabaseField publicpublic StringString dddddd;;
@DatabaseField@DatabaseField publicpublic StringString timeStamptimeStamp;;
publicpublic ContatoEntity() {ContatoEntity() {
}}
}}
• table name Contatotable name Contato
id discrico ddi ddd time Stamp
ORMLiteHelperClassORMLiteHelperClass
• public class ORMLiteSqliteOpenHelper extends OrmLiteSqliteOpenHelper {public class ORMLiteSqliteOpenHelper extends OrmLiteSqliteOpenHelper {
• public ORMLiteSqliteOpenHelper(Context context) {public ORMLiteSqliteOpenHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);super(context, DATABASE_NAME, null, DATABASE_VERSION);
}}
@Override@Override
public void onCreate(SQLiteDatabase sqLiteDatabase, ConnectionSourcepublic void onCreate(SQLiteDatabase sqLiteDatabase, ConnectionSource
connectionSource) {connectionSource) {
TableUtils.createTable(connectionSource, ContatoEntity.class);TableUtils.createTable(connectionSource, ContatoEntity.class);
}}
@Override@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, ConnectionSourcepublic void onUpgrade(SQLiteDatabase sqLiteDatabase, ConnectionSource
connectionSource, int i, int i1) {connectionSource, int i, int i1) {
TableUtils.dropTable(connectionSource,ContatoEntity.class,true);TableUtils.dropTable(connectionSource,ContatoEntity.class,true);
}}
@Override@Override
public void close() {public void close() {
super.close();super.close();
}}
}}
DAO CreationDAO Creation
• publicpublic Dao<ContatoEntity, Integer>Dao<ContatoEntity, Integer> contatoEntitiesDaocontatoEntitiesDao;;
• contatoEntitiesDaocontatoEntitiesDao==ormLiteSqliteOpenHelperormLiteSqliteOpenHelper.getDao(.getDao(ContatoEntity.ContatoEntity.classclass););
Table ClassTable Class
NameName
we can give this two line where ever we needwe can give this two line where ever we need
in our activitys or any other classin our activitys or any other class
Insertion into the tableInsertion into the table
• ContatoEntity contatoEntity=ContatoEntity contatoEntity=newnew ContatoEntity();ContatoEntity();
contatoEntity.contatoEntity.dddddd=="one""one";;
contatoEntity.contatoEntity.ddiddi=="two""two";;
contatoEntity.contatoEntity.discricodiscrico=="threee""threee";;
contatoEntity.contatoEntity.timeStamptimeStamp=String.=String.valueOfvalueOf(System.(System.currentTimeMilliscurrentTimeMillis());());
contatoEntitiesDao.contatoEntitiesDao.createcreate(contatoEntity(contatoEntity););//row is inserted into the table//row is inserted into the table
Retrive from the Database in the form javaRetrive from the Database in the form java
objectsobjects
• List<ContatoEntity>List<ContatoEntity>
demo=queryBuilder.selectColumns(demo=queryBuilder.selectColumns("discrico""discrico").query();).query();
• forfor((intint rowCount=0;rowCount<demo.size();rowCount++)rowCount=0;rowCount<demo.size();rowCount++)
{{
ContatoEntity contatoEntity1=demo.get(rowCount);//gettingContatoEntity contatoEntity1=demo.get(rowCount);//getting
in the form java object of the TableTypein the form java object of the TableType
Log.Log.ee(MainActivity.(MainActivity.classclass.getName(),.getName(), "discrico:"discrico:
""+contatoEntity1.+contatoEntity1.discricodiscrico ););
}}
AdvantagesAdvantages
• Use for complicated databaseUse for complicated database
operationsoperations
• No need to remember to SQL queriesNo need to remember to SQL queries
• Prefer for big size applicationPrefer for big size application
•Use for complicated
database operations
•No need to remember to
SQL queries
•Prefer for big size
application
•Poor performance and
scalability compared to other
data storage methods.
•Unnecessarily increase size
of application
•Little bit slow with compare
to greenDao(another ORM)
AdvantagesAdvantages
DisadvantagesDisadvantages

More Related Content

What's hot

Sql Summit Clr, Service Broker And Xml
Sql Summit   Clr, Service Broker And XmlSql Summit   Clr, Service Broker And Xml
Sql Summit Clr, Service Broker And Xml
David Truxall
 
Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...
Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...
Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...
Michael Rys
 
Database programming
Database programmingDatabase programming
Oracle Database 11g Release 2 - XMLDB New Features
Oracle Database 11g Release 2 - XMLDB New FeaturesOracle Database 11g Release 2 - XMLDB New Features
Oracle Database 11g Release 2 - XMLDB New Features
Marco Gralike
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code first
Confiz
 
Killer Scenarios with Data Lake in Azure with U-SQL
Killer Scenarios with Data Lake in Azure with U-SQLKiller Scenarios with Data Lake in Azure with U-SQL
Killer Scenarios with Data Lake in Azure with U-SQL
Michael Rys
 
Introducing Entity Framework 4.0
Introducing Entity Framework 4.0Introducing Entity Framework 4.0
Introducing Entity Framework 4.0
Bishoy Demian
 
Oak Lucene Indexes
Oak Lucene IndexesOak Lucene Indexes
Oak Lucene Indexes
Chetan Mehrotra
 
Client Server Communication on iOS
Client Server Communication on iOSClient Server Communication on iOS
Client Server Communication on iOS
Make School
 
A Step by Step Introduction to the MySQL Document Store
A Step by Step Introduction to the MySQL Document StoreA Step by Step Introduction to the MySQL Document Store
A Step by Step Introduction to the MySQL Document Store
Dave Stokes
 
cPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven FeaturescPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven Features
Dave Stokes
 
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScriptJavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
Dave Stokes
 
Persitance Data with sqlite
Persitance Data with sqlitePersitance Data with sqlite
Persitance Data with sqlite
Arif Huda
 
CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...
CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...
CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...
smn-automate
 
Advanced Core Data
Advanced Core DataAdvanced Core Data
Advanced Core Data
Make School
 
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
Marco Gralike
 
New Persistence Features in Spring Roo 1.1
New Persistence Features in Spring Roo 1.1New Persistence Features in Spring Roo 1.1
New Persistence Features in Spring Roo 1.1
Stefan Schmidt
 
Ado.Net Tutorial
Ado.Net TutorialAdo.Net Tutorial
Ado.Net Tutorial
prabhu rajendran
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursors
info_zybotech
 
ADO.NET -database connection
ADO.NET -database connectionADO.NET -database connection
ADO.NET -database connection
Anekwong Yoddumnern
 

What's hot (20)

Sql Summit Clr, Service Broker And Xml
Sql Summit   Clr, Service Broker And XmlSql Summit   Clr, Service Broker And Xml
Sql Summit Clr, Service Broker And Xml
 
Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...
Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...
Bring your code to explore the Azure Data Lake: Execute your .NET/Python/R co...
 
Database programming
Database programmingDatabase programming
Database programming
 
Oracle Database 11g Release 2 - XMLDB New Features
Oracle Database 11g Release 2 - XMLDB New FeaturesOracle Database 11g Release 2 - XMLDB New Features
Oracle Database 11g Release 2 - XMLDB New Features
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code first
 
Killer Scenarios with Data Lake in Azure with U-SQL
Killer Scenarios with Data Lake in Azure with U-SQLKiller Scenarios with Data Lake in Azure with U-SQL
Killer Scenarios with Data Lake in Azure with U-SQL
 
Introducing Entity Framework 4.0
Introducing Entity Framework 4.0Introducing Entity Framework 4.0
Introducing Entity Framework 4.0
 
Oak Lucene Indexes
Oak Lucene IndexesOak Lucene Indexes
Oak Lucene Indexes
 
Client Server Communication on iOS
Client Server Communication on iOSClient Server Communication on iOS
Client Server Communication on iOS
 
A Step by Step Introduction to the MySQL Document Store
A Step by Step Introduction to the MySQL Document StoreA Step by Step Introduction to the MySQL Document Store
A Step by Step Introduction to the MySQL Document Store
 
cPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven FeaturescPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven Features
 
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScriptJavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
 
Persitance Data with sqlite
Persitance Data with sqlitePersitance Data with sqlite
Persitance Data with sqlite
 
CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...
CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...
CocoaHeads PDX 2014 01 23 : CoreData and iCloud Improvements iOS7 / OSX Maver...
 
Advanced Core Data
Advanced Core DataAdvanced Core Data
Advanced Core Data
 
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
 
New Persistence Features in Spring Roo 1.1
New Persistence Features in Spring Roo 1.1New Persistence Features in Spring Roo 1.1
New Persistence Features in Spring Roo 1.1
 
Ado.Net Tutorial
Ado.Net TutorialAdo.Net Tutorial
Ado.Net Tutorial
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursors
 
ADO.NET -database connection
ADO.NET -database connectionADO.NET -database connection
ADO.NET -database connection
 

Viewers also liked

#jd12nl Seblod 2
#jd12nl  Seblod 2#jd12nl  Seblod 2
#jd12nl Seblod 2
Herman Peeren
 
Doctrine 2 - Introduction
Doctrine 2 - IntroductionDoctrine 2 - Introduction
Doctrine 2 - Introduction
Diego Lewin
 
Jooctrine - Doctrine ORM in Joomla!
Jooctrine - Doctrine ORM in Joomla!Jooctrine - Doctrine ORM in Joomla!
Jooctrine - Doctrine ORM in Joomla!
Herman Peeren
 
How Pony ORM translates Python generators to SQL queries
How Pony ORM translates Python generators to SQL queriesHow Pony ORM translates Python generators to SQL queries
How Pony ORM translates Python generators to SQL queries
ponyorm
 
Yaazli International AngularJS 5 Training
Yaazli International AngularJS 5 TrainingYaazli International AngularJS 5 Training
Yaazli International AngularJS 5 Training
Arjun Sridhar U R
 
02basics
02basics02basics
02basics
Waheed Warraich
 
Non ieee dot net projects list
Non  ieee dot net projects list Non  ieee dot net projects list
Non ieee dot net projects list
Mumbai Academisc
 
Yaazli International Hibernate Training
Yaazli International Hibernate TrainingYaazli International Hibernate Training
Yaazli International Hibernate Training
Arjun Sridhar U R
 
09events
09events09events
09events
Waheed Warraich
 
Toolbarexample
ToolbarexampleToolbarexample
Toolbarexample
yugandhar vadlamudi
 
Yaazli International Spring Training
Yaazli International Spring Training Yaazli International Spring Training
Yaazli International Spring Training
Arjun Sridhar U R
 
Savr
SavrSavr
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
Garuda Trainings
 
Yaazli International Web Project Workshop
Yaazli International Web Project WorkshopYaazli International Web Project Workshop
Yaazli International Web Project Workshop
Arjun Sridhar U R
 
Exception handling in java
Exception handling in java Exception handling in java
Exception handling in java
yugandhar vadlamudi
 
For Loops and Variables in Java
For Loops and Variables in JavaFor Loops and Variables in Java
For Loops and Variables in Java
Pokequesthero
 
Core java online training
Core java online trainingCore java online training
Core java online training
Glory IT Technologies Pvt. Ltd.
 
Java quick reference v2
Java quick reference v2Java quick reference v2
Java quick reference v2
Christopher Akinlade
 
Singleton pattern
Singleton patternSingleton pattern
Singleton pattern
yugandhar vadlamudi
 
Java Basic Operators
Java Basic OperatorsJava Basic Operators
Java Basic Operators
Shahid Rasheed
 

Viewers also liked (20)

#jd12nl Seblod 2
#jd12nl  Seblod 2#jd12nl  Seblod 2
#jd12nl Seblod 2
 
Doctrine 2 - Introduction
Doctrine 2 - IntroductionDoctrine 2 - Introduction
Doctrine 2 - Introduction
 
Jooctrine - Doctrine ORM in Joomla!
Jooctrine - Doctrine ORM in Joomla!Jooctrine - Doctrine ORM in Joomla!
Jooctrine - Doctrine ORM in Joomla!
 
How Pony ORM translates Python generators to SQL queries
How Pony ORM translates Python generators to SQL queriesHow Pony ORM translates Python generators to SQL queries
How Pony ORM translates Python generators to SQL queries
 
Yaazli International AngularJS 5 Training
Yaazli International AngularJS 5 TrainingYaazli International AngularJS 5 Training
Yaazli International AngularJS 5 Training
 
02basics
02basics02basics
02basics
 
Non ieee dot net projects list
Non  ieee dot net projects list Non  ieee dot net projects list
Non ieee dot net projects list
 
Yaazli International Hibernate Training
Yaazli International Hibernate TrainingYaazli International Hibernate Training
Yaazli International Hibernate Training
 
09events
09events09events
09events
 
Toolbarexample
ToolbarexampleToolbarexample
Toolbarexample
 
Yaazli International Spring Training
Yaazli International Spring Training Yaazli International Spring Training
Yaazli International Spring Training
 
Savr
SavrSavr
Savr
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Yaazli International Web Project Workshop
Yaazli International Web Project WorkshopYaazli International Web Project Workshop
Yaazli International Web Project Workshop
 
Exception handling in java
Exception handling in java Exception handling in java
Exception handling in java
 
For Loops and Variables in Java
For Loops and Variables in JavaFor Loops and Variables in Java
For Loops and Variables in Java
 
Core java online training
Core java online trainingCore java online training
Core java online training
 
Java quick reference v2
Java quick reference v2Java quick reference v2
Java quick reference v2
 
Singleton pattern
Singleton patternSingleton pattern
Singleton pattern
 
Java Basic Operators
Java Basic OperatorsJava Basic Operators
Java Basic Operators
 

Similar to Object Relational model for SQLIite in android

Life outside WO
Life outside WOLife outside WO
Life outside WO
WO Community
 
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres OpenMichael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
PostgresOpen
 
android sqlite
android sqliteandroid sqlite
android sqlite
Deepa Rani
 
Android Database
Android DatabaseAndroid Database
Android Database
Rashad Aliyev
 
Introducing U-SQL (SQLPASS 2016)
Introducing U-SQL (SQLPASS 2016)Introducing U-SQL (SQLPASS 2016)
Introducing U-SQL (SQLPASS 2016)
Michael Rys
 
Alternatives of JPA/Hibernate
Alternatives of JPA/HibernateAlternatives of JPA/Hibernate
Alternatives of JPA/Hibernate
Sunghyouk Bae
 
Rajab Davudov - Android Database
Rajab Davudov - Android DatabaseRajab Davudov - Android Database
Rajab Davudov - Android Database
Rashad Aliyev
 
NoSQL Endgame Percona Live Online 2020
NoSQL Endgame Percona Live Online 2020NoSQL Endgame Percona Live Online 2020
NoSQL Endgame Percona Live Online 2020
Thodoris Bais
 
Shshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptx
Shshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptxShshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptx
Shshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptx
086ChintanPatel1
 
Painless Persistence in a Disconnected World
Painless Persistence in a Disconnected WorldPainless Persistence in a Disconnected World
Painless Persistence in a Disconnected World
Christian Melchior
 
Database Programming Techniques
Database Programming TechniquesDatabase Programming Techniques
Database Programming Techniques
Raji Ghawi
 
Json Persistence Framework
Json Persistence FrameworkJson Persistence Framework
Json Persistence Framework
danieloskarsson
 
Android sq lite-chapter 22
Android sq lite-chapter 22Android sq lite-chapter 22
Android sq lite-chapter 22
Dr. Ramkumar Lakshminarayanan
 
Using existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analyticsUsing existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analytics
Microsoft Tech Community
 
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
Marco Gralike
 
Entity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsEntity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic Unicorns
Richie Rump
 
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami
 
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
NoSQLmatters
 
NoSQL Endgame LWJUG 2021
NoSQL Endgame LWJUG 2021NoSQL Endgame LWJUG 2021
NoSQL Endgame LWJUG 2021
Thodoris Bais
 
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Marco Gralike
 

Similar to Object Relational model for SQLIite in android (20)

Life outside WO
Life outside WOLife outside WO
Life outside WO
 
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres OpenMichael Bayer Introduction to SQLAlchemy @ Postgres Open
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
 
android sqlite
android sqliteandroid sqlite
android sqlite
 
Android Database
Android DatabaseAndroid Database
Android Database
 
Introducing U-SQL (SQLPASS 2016)
Introducing U-SQL (SQLPASS 2016)Introducing U-SQL (SQLPASS 2016)
Introducing U-SQL (SQLPASS 2016)
 
Alternatives of JPA/Hibernate
Alternatives of JPA/HibernateAlternatives of JPA/Hibernate
Alternatives of JPA/Hibernate
 
Rajab Davudov - Android Database
Rajab Davudov - Android DatabaseRajab Davudov - Android Database
Rajab Davudov - Android Database
 
NoSQL Endgame Percona Live Online 2020
NoSQL Endgame Percona Live Online 2020NoSQL Endgame Percona Live Online 2020
NoSQL Endgame Percona Live Online 2020
 
Shshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptx
Shshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptxShshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptx
Shshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptx
 
Painless Persistence in a Disconnected World
Painless Persistence in a Disconnected WorldPainless Persistence in a Disconnected World
Painless Persistence in a Disconnected World
 
Database Programming Techniques
Database Programming TechniquesDatabase Programming Techniques
Database Programming Techniques
 
Json Persistence Framework
Json Persistence FrameworkJson Persistence Framework
Json Persistence Framework
 
Android sq lite-chapter 22
Android sq lite-chapter 22Android sq lite-chapter 22
Android sq lite-chapter 22
 
Using existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analyticsUsing existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analytics
 
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
 
Entity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsEntity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic Unicorns
 
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
 
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
Simon Elliston Ball – When to NoSQL and When to Know SQL - NoSQL matters Barc...
 
NoSQL Endgame LWJUG 2021
NoSQL Endgame LWJUG 2021NoSQL Endgame LWJUG 2021
NoSQL Endgame LWJUG 2021
 
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
 

More from yugandhar vadlamudi

JButton in Java Swing example
JButton in Java Swing example JButton in Java Swing example
JButton in Java Swing example
yugandhar vadlamudi
 
Collections framework in java
Collections framework in javaCollections framework in java
Collections framework in java
yugandhar vadlamudi
 
Packaes & interfaces
Packaes & interfacesPackaes & interfaces
Packaes & interfaces
yugandhar vadlamudi
 
JMenu Creation in Java Swing
JMenu Creation in Java SwingJMenu Creation in Java Swing
JMenu Creation in Java Swing
yugandhar vadlamudi
 
Adding a action listener to button
Adding a action listener to buttonAdding a action listener to button
Adding a action listener to button
yugandhar vadlamudi
 
Dynamic method dispatch
Dynamic method dispatchDynamic method dispatch
Dynamic method dispatch
yugandhar vadlamudi
 
Operators in java
Operators in javaOperators in java
Operators in java
yugandhar vadlamudi
 
Inheritance
InheritanceInheritance
Inheritance
yugandhar vadlamudi
 
Control flow statements in java
Control flow statements in javaControl flow statements in java
Control flow statements in java
yugandhar vadlamudi
 
Closer look at classes
Closer look at classesCloser look at classes
Closer look at classes
yugandhar vadlamudi
 
java Applet Introduction
java Applet Introductionjava Applet Introduction
java Applet Introduction
yugandhar vadlamudi
 
Class introduction in java
Class introduction in javaClass introduction in java
Class introduction in java
yugandhar vadlamudi
 

More from yugandhar vadlamudi (12)

JButton in Java Swing example
JButton in Java Swing example JButton in Java Swing example
JButton in Java Swing example
 
Collections framework in java
Collections framework in javaCollections framework in java
Collections framework in java
 
Packaes & interfaces
Packaes & interfacesPackaes & interfaces
Packaes & interfaces
 
JMenu Creation in Java Swing
JMenu Creation in Java SwingJMenu Creation in Java Swing
JMenu Creation in Java Swing
 
Adding a action listener to button
Adding a action listener to buttonAdding a action listener to button
Adding a action listener to button
 
Dynamic method dispatch
Dynamic method dispatchDynamic method dispatch
Dynamic method dispatch
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Inheritance
InheritanceInheritance
Inheritance
 
Control flow statements in java
Control flow statements in javaControl flow statements in java
Control flow statements in java
 
Closer look at classes
Closer look at classesCloser look at classes
Closer look at classes
 
java Applet Introduction
java Applet Introductionjava Applet Introduction
java Applet Introduction
 
Class introduction in java
Class introduction in javaClass introduction in java
Class introduction in java
 

Recently uploaded

Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Ashish Kohli
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 

Recently uploaded (20)

Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 

Object Relational model for SQLIite in android

  • 1. ORM
  • 2. ORM Object-relational mapping products integrate objectObject-relational mapping products integrate object programming language capabilities with relationalprogramming language capabilities with relational databasesdatabases
  • 3. What is ORMLiteWhat is ORMLite • Object Relational Mapping Lite (ORM Lite)Object Relational Mapping Lite (ORM Lite) provides some lightweight functionality forprovides some lightweight functionality for persisting Java objects to SQL databasespersisting Java objects to SQL databases while avoiding the complexity and overheadwhile avoiding the complexity and overhead of more standard ORM packages.of more standard ORM packages.
  • 4. Features of ORMLiteFeatures of ORMLite • Setup your classes by simply adding JavaSetup your classes by simply adding Java annotations.annotations. • EgEg @DatabaseTable(tableName =@DatabaseTable(tableName = "Contato""Contato")) • Powerful abstract Database Access ObjectPowerful abstract Database Access Object (DAO) classes(DAO) classes • Flexible QueryBuilder to easily constructFlexible QueryBuilder to easily construct simple and complex queries.simple and complex queries. • Basic support for database transactions.Basic support for database transactions. • Auto generates SQL to create and dropAuto generates SQL to create and drop database tables.database tables.
  • 5. Simple ExampleSimple Example • @DatabaseTable(tableName =@DatabaseTable(tableName = "Contato""Contato")//table name)//table name public classpublic class ContatoEntity {ContatoEntity { @DatabaseField(generatedId =@DatabaseField(generatedId = truetrue))public int idpublic int id; //field name; //field name @DatabaseField@DatabaseField public staticpublic static StringString discricodiscrico;; @DatabaseField@DatabaseField publicpublic StringString ddiddi;; @DatabaseField@DatabaseField publicpublic StringString dddddd;; @DatabaseField@DatabaseField publicpublic StringString timeStamptimeStamp;; publicpublic ContatoEntity() {ContatoEntity() { }} }} • table name Contatotable name Contato id discrico ddi ddd time Stamp
  • 6. ORMLiteHelperClassORMLiteHelperClass • public class ORMLiteSqliteOpenHelper extends OrmLiteSqliteOpenHelper {public class ORMLiteSqliteOpenHelper extends OrmLiteSqliteOpenHelper { • public ORMLiteSqliteOpenHelper(Context context) {public ORMLiteSqliteOpenHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION);super(context, DATABASE_NAME, null, DATABASE_VERSION); }} @Override@Override public void onCreate(SQLiteDatabase sqLiteDatabase, ConnectionSourcepublic void onCreate(SQLiteDatabase sqLiteDatabase, ConnectionSource connectionSource) {connectionSource) { TableUtils.createTable(connectionSource, ContatoEntity.class);TableUtils.createTable(connectionSource, ContatoEntity.class); }} @Override@Override public void onUpgrade(SQLiteDatabase sqLiteDatabase, ConnectionSourcepublic void onUpgrade(SQLiteDatabase sqLiteDatabase, ConnectionSource connectionSource, int i, int i1) {connectionSource, int i, int i1) { TableUtils.dropTable(connectionSource,ContatoEntity.class,true);TableUtils.dropTable(connectionSource,ContatoEntity.class,true); }} @Override@Override public void close() {public void close() { super.close();super.close(); }} }}
  • 7. DAO CreationDAO Creation • publicpublic Dao<ContatoEntity, Integer>Dao<ContatoEntity, Integer> contatoEntitiesDaocontatoEntitiesDao;; • contatoEntitiesDaocontatoEntitiesDao==ormLiteSqliteOpenHelperormLiteSqliteOpenHelper.getDao(.getDao(ContatoEntity.ContatoEntity.classclass);); Table ClassTable Class NameName we can give this two line where ever we needwe can give this two line where ever we need in our activitys or any other classin our activitys or any other class
  • 8. Insertion into the tableInsertion into the table • ContatoEntity contatoEntity=ContatoEntity contatoEntity=newnew ContatoEntity();ContatoEntity(); contatoEntity.contatoEntity.dddddd=="one""one";; contatoEntity.contatoEntity.ddiddi=="two""two";; contatoEntity.contatoEntity.discricodiscrico=="threee""threee";; contatoEntity.contatoEntity.timeStamptimeStamp=String.=String.valueOfvalueOf(System.(System.currentTimeMilliscurrentTimeMillis());()); contatoEntitiesDao.contatoEntitiesDao.createcreate(contatoEntity(contatoEntity););//row is inserted into the table//row is inserted into the table
  • 9. Retrive from the Database in the form javaRetrive from the Database in the form java objectsobjects • List<ContatoEntity>List<ContatoEntity> demo=queryBuilder.selectColumns(demo=queryBuilder.selectColumns("discrico""discrico").query();).query(); • forfor((intint rowCount=0;rowCount<demo.size();rowCount++)rowCount=0;rowCount<demo.size();rowCount++) {{ ContatoEntity contatoEntity1=demo.get(rowCount);//gettingContatoEntity contatoEntity1=demo.get(rowCount);//getting in the form java object of the TableTypein the form java object of the TableType Log.Log.ee(MainActivity.(MainActivity.classclass.getName(),.getName(), "discrico:"discrico: ""+contatoEntity1.+contatoEntity1.discricodiscrico );); }}
  • 10. AdvantagesAdvantages • Use for complicated databaseUse for complicated database operationsoperations • No need to remember to SQL queriesNo need to remember to SQL queries • Prefer for big size applicationPrefer for big size application
  • 11. •Use for complicated database operations •No need to remember to SQL queries •Prefer for big size application •Poor performance and scalability compared to other data storage methods. •Unnecessarily increase size of application •Little bit slow with compare to greenDao(another ORM) AdvantagesAdvantages DisadvantagesDisadvantages