SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
JSON, SQLite & Persistence

    Daniel Oskarsson   Know IT
Preface


24 slides and Netbeans Demo

Contents are more towards avoiding pitfalls than learning the
basics.
"Simplicity"
JSON

json.org
http://www.json.org
+             -



json     size       validation




xml    validation     size
JAX-RS                                   JAX-WS



public class Tv {
  @GET
  @Path("/tv/")
  @Produces({"application/json"})
  public List<Channel> getChannels() {
    List<Channel> channels = getChannels();
    return channels;
  }
}
JAX-B

@XmlRootElement
public class Channel {
  public Channel() {}
  @XmlElement
  private String id;
  @XmlElement
  private String name;
  @XmlElement
  public String getLogo() {
    return String.format(path, id);
  }
  @XmlElement
  public List<Program> getPrograms() {
    return getPrograms();
  }
}
{
    "channel":[
      {
          "id":"svt1.svt.se",
          "name":"SVT1",
          "logo":"svt1.svt.se.png",
          "programs":[
              {
                   "name":"Kulturnyheterna",
                   "start":"2011-11-23T18:00:00Z",
                   "stop":"2011-11-23T18:15:00Z"
              },
              {
                   "name":"Regionala nyheter",
                   "start":"2011-11-23T18:15:00Z",
                   "stop":"2011-11-23T18:30:00Z"
              }
          ]
}]}
SQLite

sqlite.org
SQLite

"SQLite is a software library that implements a self-contained,
server-less, zero-configuration, transactional SQL database
engine"

"SQLite does not have a separate server process"

"SQLite reads and writes directly to ordinary disk files"

"Think of SQLite not as a replacement for Oracle but as a
replacement for fopen()"



                                   http://www.sqlite.org/about.html
Storage Classes

Values are one of the following storage classes:

  INTEGER (signed)
  REAL
  TEXT (UTF)
  NULL
  BLOB

BOOL (INTEGER 0 or INTEGER 1)
DATE (ISO8601 TEXT or Unix Time INTEGER or Julian days)
TIME (ISO8601 TEXT or Unix Time INTEGER or Julian days)


                            http://www.sqlite.org/datatype3.html
Type Affinity

Columns are one the following type affinities:

INTEGER
REAL
NUMERIC
TEXT (NULL, BLOB)
NONE

Internally values may be casted before stored




                            http://www.sqlite.org/datatype3.html
http://www.sqlite.org/lang_createtable.html
Foreign keys

"Foreign key constraints are disabled by default (for backwards
compatibility), so must be enabled separately for each
database connection separately." (http://www.sqlite.
org/foreignkeys.html)
Class.forName("org.sqlite.JDBC");
final String url = "jdbc:sqlite:json.db";

SQLiteConfig config = new SQLiteConfig();
config.enforceForeignKeys(true);

Connection connection = DriverManager.getConnection(url,
config.toProperties());
As an in-memory-database

Class.forName("org.sqlite.JDBC");
final String url = "jdbc:sqlite::memory:";
Connection connection = DriverManager.getConnection(url);
JDBC

http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC

<dependency>
  <groupId>org.xerial</groupId>
  <artifactId>sqlite-jdbc</artifactId>
</dependency>
1+1=3
JSON Persistence Framework

github.com/danieloskarsson/json-persistence
Characteristics

Key-value-based persistence

Zero configuration
  No database setup
  No mappings

No modifications of domain objects
  No serializable
  No annotations

Apache 2.0 License
Design decisions

Serialization & Deserialization
  JSON Serialization and Deserialization is NOT provided
  The user selects their favorite JSON library for the task

Versioning is NOT supported
  Some JSON libraries support versioning
  Some JSON libraries navigates the tree of the desired type
     As opposed to navigating the tree of the input

  The data type is used as the key / id
  E.g. tv.domain.Channel[] or tv.domain.Channel
  Multiple instance of the same class must be in a list
  JSON should be parsed before it is persisted
A perfect match with Smartphones
SmartPhones often...

Comes bundled with support for JSON
Comes bundled with support for SQLite
Receive JSON data from a REST call


JSON Persistence Framework is forthcoming on
  Android
  iOS
  Windows Phone
github.com/danieloskarsson

   linkedin.com/in/danieloskarsson

Contenu connexe

Tendances

Php update and delet operation
Php update and delet operationPhp update and delet operation
Php update and delet operationsyeda zoya mehdi
 
Intro to HTML5 Web Storage
Intro to HTML5 Web StorageIntro to HTML5 Web Storage
Intro to HTML5 Web Storagedylanks
 
UKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File Server
UKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File ServerUKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File Server
UKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File ServerMarco Gralike
 
How to search extracted data
How to search extracted dataHow to search extracted data
How to search extracted dataJavier Collado
 
JDBC - JPA - Spring Data
JDBC - JPA - Spring DataJDBC - JPA - Spring Data
JDBC - JPA - Spring DataArturs Drozdovs
 
.Net Project Portfolio for Roger Loving
.Net Project Portfolio for Roger Loving.Net Project Portfolio for Roger Loving
.Net Project Portfolio for Roger Lovingrloving10
 
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
 
Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Scott Leberknight
 
Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...
Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...
Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...Marco Gralike
 
XML and Web Services
XML and Web ServicesXML and Web Services
XML and Web ServicesHenry Osborne
 

Tendances (20)

Xml 2
Xml  2 Xml  2
Xml 2
 
JAXP
JAXPJAXP
JAXP
 
Php update and delet operation
Php update and delet operationPhp update and delet operation
Php update and delet operation
 
Intro to HTML5 Web Storage
Intro to HTML5 Web StorageIntro to HTML5 Web Storage
Intro to HTML5 Web Storage
 
Java and XML
Java and XMLJava and XML
Java and XML
 
UKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File Server
UKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File ServerUKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File Server
UKOUG 2011 - Drag, Drop and other Stuff. Using your Database as a File Server
 
Parsing XML Data
Parsing XML DataParsing XML Data
Parsing XML Data
 
How to search extracted data
How to search extracted dataHow to search extracted data
How to search extracted data
 
JDBC - JPA - Spring Data
JDBC - JPA - Spring DataJDBC - JPA - Spring Data
JDBC - JPA - Spring Data
 
Simple Jdbc With Spring 2.5
Simple Jdbc With Spring 2.5Simple Jdbc With Spring 2.5
Simple Jdbc With Spring 2.5
 
PHP with MYSQL
PHP with MYSQLPHP with MYSQL
PHP with MYSQL
 
.Net Project Portfolio for Roger Loving
.Net Project Portfolio for Roger Loving.Net Project Portfolio for Roger Loving
.Net Project Portfolio for Roger Loving
 
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...
 
Php summary
Php summaryPhp summary
Php summary
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
XSLT
XSLTXSLT
XSLT
 
Sequel
SequelSequel
Sequel
 
Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0
 
Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...
Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...
Oracle Developer Day, 20 October 2009, Oracle De Meern, Holland: Oracle Datab...
 
XML and Web Services
XML and Web ServicesXML and Web Services
XML and Web Services
 

Similaire à Json Persistence Framework

Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCpootsbook
 
OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)
OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)
OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)Pat Patterson
 
OrientDB introduction - NoSQL
OrientDB introduction - NoSQLOrientDB introduction - NoSQL
OrientDB introduction - NoSQLLuca Garulli
 
Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityWashington Botelho
 
ElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersBen van Mol
 
Windows Azure and a little SQL Data Services
Windows Azure and a little SQL Data ServicesWindows Azure and a little SQL Data Services
Windows Azure and a little SQL Data Servicesukdpe
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBantoinegirbal
 
2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introduction2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introductionantoinegirbal
 
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
 
RESTful web service with JBoss Fuse
RESTful web service with JBoss FuseRESTful web service with JBoss Fuse
RESTful web service with JBoss Fuseejlp12
 
112815 java ee8_davidd
112815 java ee8_davidd112815 java ee8_davidd
112815 java ee8_daviddTakashi Ito
 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Red Hat Developers
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jerseyb_kathir
 
NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020Thodoris Bais
 

Similaire à Json Persistence Framework (20)

Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)
OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)
OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)
 
Practical OData
Practical ODataPractical OData
Practical OData
 
OrientDB introduction - NoSQL
OrientDB introduction - NoSQLOrientDB introduction - NoSQL
OrientDB introduction - NoSQL
 
Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrity
 
treeview
treeviewtreeview
treeview
 
treeview
treeviewtreeview
treeview
 
ElasticSearch for .NET Developers
ElasticSearch for .NET DevelopersElasticSearch for .NET Developers
ElasticSearch for .NET Developers
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
Windows Azure and a little SQL Data Services
Windows Azure and a little SQL Data ServicesWindows Azure and a little SQL Data Services
Windows Azure and a little SQL Data Services
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introduction2011 Mongo FR - MongoDB introduction
2011 Mongo FR - MongoDB introduction
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 
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...
 
RESTful web service with JBoss Fuse
RESTful web service with JBoss FuseRESTful web service with JBoss Fuse
RESTful web service with JBoss Fuse
 
112815 java ee8_davidd
112815 java ee8_davidd112815 java ee8_davidd
112815 java ee8_davidd
 
Lobos Introduction
Lobos IntroductionLobos Introduction
Lobos Introduction
 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
 
NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020
 

Dernier

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 

Dernier (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 

Json Persistence Framework

  • 1. JSON, SQLite & Persistence Daniel Oskarsson Know IT
  • 2. Preface 24 slides and Netbeans Demo Contents are more towards avoiding pitfalls than learning the basics.
  • 6. + - json size validation xml validation size
  • 7. JAX-RS JAX-WS public class Tv { @GET @Path("/tv/") @Produces({"application/json"}) public List<Channel> getChannels() { List<Channel> channels = getChannels(); return channels; } }
  • 8. JAX-B @XmlRootElement public class Channel { public Channel() {} @XmlElement private String id; @XmlElement private String name; @XmlElement public String getLogo() { return String.format(path, id); } @XmlElement public List<Program> getPrograms() { return getPrograms(); } }
  • 9. { "channel":[ { "id":"svt1.svt.se", "name":"SVT1", "logo":"svt1.svt.se.png", "programs":[ { "name":"Kulturnyheterna", "start":"2011-11-23T18:00:00Z", "stop":"2011-11-23T18:15:00Z" }, { "name":"Regionala nyheter", "start":"2011-11-23T18:15:00Z", "stop":"2011-11-23T18:30:00Z" } ] }]}
  • 11. SQLite "SQLite is a software library that implements a self-contained, server-less, zero-configuration, transactional SQL database engine" "SQLite does not have a separate server process" "SQLite reads and writes directly to ordinary disk files" "Think of SQLite not as a replacement for Oracle but as a replacement for fopen()" http://www.sqlite.org/about.html
  • 12. Storage Classes Values are one of the following storage classes: INTEGER (signed) REAL TEXT (UTF) NULL BLOB BOOL (INTEGER 0 or INTEGER 1) DATE (ISO8601 TEXT or Unix Time INTEGER or Julian days) TIME (ISO8601 TEXT or Unix Time INTEGER or Julian days) http://www.sqlite.org/datatype3.html
  • 13. Type Affinity Columns are one the following type affinities: INTEGER REAL NUMERIC TEXT (NULL, BLOB) NONE Internally values may be casted before stored http://www.sqlite.org/datatype3.html
  • 15. Foreign keys "Foreign key constraints are disabled by default (for backwards compatibility), so must be enabled separately for each database connection separately." (http://www.sqlite. org/foreignkeys.html) Class.forName("org.sqlite.JDBC"); final String url = "jdbc:sqlite:json.db"; SQLiteConfig config = new SQLiteConfig(); config.enforceForeignKeys(true); Connection connection = DriverManager.getConnection(url, config.toProperties());
  • 16. As an in-memory-database Class.forName("org.sqlite.JDBC"); final String url = "jdbc:sqlite::memory:"; Connection connection = DriverManager.getConnection(url);
  • 18. 1+1=3
  • 20. Characteristics Key-value-based persistence Zero configuration No database setup No mappings No modifications of domain objects No serializable No annotations Apache 2.0 License
  • 21. Design decisions Serialization & Deserialization JSON Serialization and Deserialization is NOT provided The user selects their favorite JSON library for the task Versioning is NOT supported Some JSON libraries support versioning Some JSON libraries navigates the tree of the desired type As opposed to navigating the tree of the input The data type is used as the key / id E.g. tv.domain.Channel[] or tv.domain.Channel Multiple instance of the same class must be in a list JSON should be parsed before it is persisted
  • 22. A perfect match with Smartphones
  • 23. SmartPhones often... Comes bundled with support for JSON Comes bundled with support for SQLite Receive JSON data from a REST call JSON Persistence Framework is forthcoming on Android iOS Windows Phone
  • 24. github.com/danieloskarsson linkedin.com/in/danieloskarsson