JNoSQL is a framework and collection of tools that make integration between Java applications and NoSQL quick and easy—for developers as well as vendors. The API is easy to implement, so NoSQL vendors can quickly implement, test, and become compliant by themselves. And with its low learning curve and just a minimal set of artifacts, Java developers can start coding by worrying not about the complexity of specific NoSQL databases but only their core aspects (such as graph or document properties). Built with functional programming in mind, it leverages all the features of Java 8. This session covers how the API is structured, how it relates to the multiple NoSQL database types, and how you can get started and involved in this open source technology.
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [CON4954]
1. JNoSQL
#JavaOne #JNoSQL @JNoSQL @otaviojava @leomrlima
JNoSQL
The Definitive Solution for Java
and NoSQL Database
Leonardo Lima Otávio Santana
2. JNoSQL
#JavaOne #JNoSQL @JNoSQL @otaviojava @leomrlima
About the Speakers
Leonardo Lima
• Computer engineer, server & embedded sw developer
• From São Paulo, Brasil, currently in Austin, TX
• CTO at V2COM
• Spec Lead – JSR363 – Units of Measurement
• V2COM’s Representative at JCP Executive Committee
[about.me/leomrlima]
3. JNoSQL
#JavaOne #JNoSQL @JNoSQL @otaviojava @leomrlima
Otávio Santana
• Software engineer, Tomitribe
• From Salvador, Brazil
• Java Champion, SouJava JUG Leader
• Apache, Eclipse and OpenJDK Committer
• Expert Group member in many JSRs
• Representative at JCP EC for SouJava
About the Speakers
5. JNoSQL
#JavaOne #JNoSQL @JNoSQL @otaviojava @leomrlima
What defines NoSQL databases?
— No fixed data structure
— Not an ACID, but a BASE
— Five different types
◦ Key/Value
◦ Column Family
◦ Document
◦ Graph
◦ Multi-Model
6. JNoSQL
#JavaOne #JNoSQL @JNoSQL @otaviojava @leomrlima
ACID x BASE
Basically
Available,
Soft State,
Eventual consistency
Atomicity,
Consistency,
Isolation,
Durability
7. JNoSQL
#JavaOne #JNoSQL @JNoSQL @otaviojava @leomrlima
Key/Value
— AmazonDynamo
— AmazonS3
— Redis
— Scalaris
— Voldemort
— Couchbase
— Hazelcast
Apollo Sun
Aphrodite Love
Ares War
Light Music
Beauty
15. JNoSQL
#JavaOne #JNoSQL @JNoSQL @otaviojava @leomrlima
How Java application interact with…
SQL NoSQL
Logic
DAO
JPA
JDBC
JPA
JDBC
JPA
JDBC
Logic
DAO
16. JNoSQL
#JavaOne #JNoSQL @JNoSQL @otaviojava @leomrlima
For example: for a Document DB…
BaseDocument baseDocument = new BaseDocument();
baseDocument.addAttribute(name, value);
JsonObject jsonObject = JsonObject.create();
jsonObject.put(name, value);
Document document = new Document();
document.append(name, value);
ODocument document = new ODocument(“collection”);
document.field(name, value);
17. JNoSQL
#JavaOne #JNoSQL @JNoSQL @otaviojava @leomrlima
A first attempt on independence…
Logic
DAO
JPA
— Hibernate OGM
— Eclipse TopLink
18. JNoSQL
#JavaOne #JNoSQL @JNoSQL @otaviojava @leomrlima
… brings a bunch of issues!
— Can’t save asynchronously
◦ No callback
— Can’t define aTime to Live (TTL) for stored data
— Consistency Level choice on persist
— Not all DBs are SQL-based
— There are many NoSQL types
20. JNoSQL
#JavaOne #JNoSQL @JNoSQL @otaviojava @leomrlima
What is JNoSQL?
— Mapping API - Artemis
— Communication API - Diana
— No lock-in
— Divide and conquer
DAO
Communication
Mapping
JNoSQL
21. JNoSQL
#JavaOne #JNoSQL @JNoSQL @otaviojava @leomrlima
Eclipse JNoSQL
— Eclipse Foundation
— Apache v2 + EPL 1.0
— API to each NoSQL type
— Configurable
— Extensible Communication
Mapping
22. JNoSQL
#JavaOne #JNoSQL @JNoSQL @otaviojava @leomrlima
JNoSQL - Diana
— Communication layer API
— One API for each DB type
◦ Document
◦ Key-value
◦ Column
◦ Graph
28. JNoSQL
#JavaOne #JNoSQL @JNoSQL @otaviojava @leomrlima
Handling diversity (2)
//mutiple implementation
entityManager.insert(entity);
ColumnQuery query =
select().from(COLUMN_FAMILY).where(ColumnCondition.eq(id)).build();
Optional<ColumnEntity> result = entityManager.singleResult(query);
//cassandra only
List<ColumnEntity> entities = entityManagerCassandra
.cql("select * from newKeySpace.newColumnFamily where id=10;");
entityManagerCassandra.insert(entity, ConsistencyLevel.ALL);
29. JNoSQL
#JavaOne #JNoSQL @JNoSQL @otaviojava @leomrlima
JNoSQL - Artemis
— Based on CDI and Diana
— Heavy use of Annotations
— Events on Create, Update, Delete
— BeanValidation Support
— Configurable and Extensible
— “Query by Methods”