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

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 

Dernier (20)

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 

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