SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Wrap your Database in Java 8
Per-Åke Minborg
Carina Dreifeldt
Malin Weiss
Emil Forslund
Speedment
Company
• Company started 2010
• Speedment customers:
Fintech, manufacturing, media,
telecom, transport, retail,
publishing and entertainment.
•Office
PaloAlto, California
Gothenburg, Sweden
Open Source Project
• Apache 2, started 2015
• Fully Java 8 compatible
• www.speedment.org, GitHub
Bio
Per-Åke Minborg
• Master of Science Sweden
• Inventor and Serial Entrepreneur
• Java >15 years
• Speaker at Meetups and Javaforums around
the globe, (Java-One 2015)
• Java 8 and OpenSource blogger
Speedment Started With A Problem
Do You Recognize the following?
• When coding it is complex to connect to a database…..
…then you use an ORM
Source: ZeroTurnaround
SOME PROS of Using an ORM:
• You can work with a relational database as if it were object oriented.
• Increased productivity.
• Provides a certain degree of abstraction (you can replace your
DBMS).
SOME CONS of Using an ORM:
• Slows down the application
• You must still write SQL, HQL, et. al
• You can not access all Java 8 features
How to skip these ORMs and work with
Pure Java 8
• Lambda expressions
• Stream API
• Optional
Lambda Expressions
• Anonymous methods can be expressed using the new ”->”
syntax
Deck deck = Deck.createShuffledDeck();
List<Card> cards = deck.findWhere(card ->
card.isHeart() &&
card.getValue() > 10
);
Lambda Expressions
• Any single-method interface can be implemented using lambda
• can be annoted with @FunctionalInterface to show this
@FunctionalInterface
interface VectorOperation {
Vector apply(Vector a, Vector b);
}
VectorOperation plus = (a, b) -> new Vector(
a.getX() + b.getX(),
a.getY() + b.getY()
);
Lambda Expressions
Functional pointers can also be used with the ”::” syntax
Set<Hero> warriors = typicalParty.where(Hero::isWarrior);
…
interface Hero {
boolean isWarrior();
}
…
class Party {
private Set<Hero> heroes;
public Set<Hero> select(Predicate<Hero> selector) { … }
}
Stream API
• Streams are a modern way of working with groups of elements
• Defining a stream is always an O(1)-operation
• The elements are only traversed when used
• Streams can often be executed in parallell
Stream API
• Example: Get the average strength of all warriors with axes in the
party
Set<Hero> party = … ;
int averageStrength = party.stream()
.filter(hero -> Archtype.WARRIOR == hero.getArchtype())
.filter(hero -> Weapon.AXE == hero.getWeapon())
.mapToInt(Hero::getStrength)
.average();
By replacing .stream() with .parallelStream() the operation can
be performed using multiple processors
Optional
• Null is often described as ”The Billion Dollar Mistake” of modern
programming languages
• Using the Optional-interface we can now describe a value that might or
might not be present in a null-safe way
String getEmailAddress() { // Is always defined
return this.emailAddress;
}
Optional<String> getFirstname() { // Might not exist
return Optional.ofNullable(
this.firstname
);
}
Optional
• You can work with Optionals in the same way you work with
streams
Optional<String> firstname = getFirstname()
.filter(fn -> fn.length() > 3)
.filter(fn -> fn.charAt(0) == 'A');
• When the value of an optional is retreived, you can handle every
case
String absoluteFirstname = firstname.getOrDefault("Anonymous");
Speedment API
Embrace Java 8 paradigm with stream(), filter(), sort(), limit() etc.
Forget about SQL, JQL
Focus on Business Logic
Focus on what is fun
Develop a Database app within hours
No Query API
Stick to Java 8
Initialization
Speedment speedment = new HelloSpeedment().build();
Manager<Hare> hares = speedment.managerOf(Hare.class);
Persistence
Hare spire = hares.newInstance()
.setName(“Spire")
.setColor(“Blue")
.setAge(1)
.persist();
Querying
List<Hare> oldHares = hares.stream()
.filter(h -> h.getAge() > 8)
.collect(toList());
Optimised Predicate Look-up
Optional<Hare> spire= hares.stream()
.filter(Hare.NAME.equal(“Spire"))
.findAny();
Entities are Linked
Optional<Carrot> carrot = hares.stream()
.filter(Hare.NAME.equal(“Spire”))
// Carrot is a foreign key.
.flatMap(Hare::findCarrots)
.findAny();
Multi-threading
hares.stream()
.parallel()
.filter(h -> humans.stream()
.filter(Human.NAME.equal(h.getName()))
.anyMatch()
).forEach(System.out::println);
Configuration
• Groovy script like Gradle
• Config file is placed relative to the POM
dbms {
schema {
table {
name = ”hare";
column {
name = "name";
}
}
}
}
Ease of use:
• Single Maven dependency in POM
• Maven plugin for code generation/GUI
• Maven targets
• Works with Gradle
• GUI to automatically derive the groovy config file from existing
databases
Conclusions
• Code generation, No boiler plate code
• Focus on the problem at hand!
• Forget about the database
• Use Java 8
Workshop: Social network
We will focus on the server-side
MySQL database
Server application
Client GUI
http
Workshop: Social Network
The goal is to add features:
• Register
• Login
• Upload pictures
Workshop: Social Network
Speedment: https://github.com/speedment/speedment
https://github.com/Pyknic/SocialPhotoNetworkClient
Social Network Lab :
https://github.com/Pyknic/SocialPhotoNetworkServer
Insane Mode...
Want fast development + super duper fast execution ?
Speedment Enterprise Solution provides extreme performance
We are Where You are!
• www.speedment.org
• GitHub: https://github.com/speedment/speedment
• Twitter: @Pminborg
• Mail: minborg@speedment.org
• Blog: minborgsjavapot.blogspot.com
• SiliconValley

Weitere ähnliche Inhalte

Was ist angesagt?

Streaming Aggregation in Solr - New Horizons for Search: Presented by Erick E...
Streaming Aggregation in Solr - New Horizons for Search: Presented by Erick E...Streaming Aggregation in Solr - New Horizons for Search: Presented by Erick E...
Streaming Aggregation in Solr - New Horizons for Search: Presented by Erick E...
Lucidworks
 

Was ist angesagt? (20)

Elasticsearch in Netflix
Elasticsearch in NetflixElasticsearch in Netflix
Elasticsearch in Netflix
 
Introduction to Apache Calcite
Introduction to Apache CalciteIntroduction to Apache Calcite
Introduction to Apache Calcite
 
Workshop: Learning Elasticsearch
Workshop: Learning ElasticsearchWorkshop: Learning Elasticsearch
Workshop: Learning Elasticsearch
 
State-of-the-Art Drupal Search with Apache Solr
State-of-the-Art Drupal Search with Apache SolrState-of-the-Art Drupal Search with Apache Solr
State-of-the-Art Drupal Search with Apache Solr
 
Speed Up Your APEX Apps with JSON and Handlebars
Speed Up Your APEX Apps with JSON and HandlebarsSpeed Up Your APEX Apps with JSON and Handlebars
Speed Up Your APEX Apps with JSON and Handlebars
 
Elasticsearch - Devoxx France 2012 - English version
Elasticsearch - Devoxx France 2012 - English versionElasticsearch - Devoxx France 2012 - English version
Elasticsearch - Devoxx France 2012 - English version
 
Data stax academy
Data stax academyData stax academy
Data stax academy
 
Rebuilding Solr 6 Examples - Layer by Layer: Presented by Alexandre Rafalovit...
Rebuilding Solr 6 Examples - Layer by Layer: Presented by Alexandre Rafalovit...Rebuilding Solr 6 Examples - Layer by Layer: Presented by Alexandre Rafalovit...
Rebuilding Solr 6 Examples - Layer by Layer: Presented by Alexandre Rafalovit...
 
Cool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearchCool bonsai cool - an introduction to ElasticSearch
Cool bonsai cool - an introduction to ElasticSearch
 
What's new in Elasticsearch v5
What's new in Elasticsearch v5What's new in Elasticsearch v5
What's new in Elasticsearch v5
 
Apache Calcite: One planner fits all
Apache Calcite: One planner fits allApache Calcite: One planner fits all
Apache Calcite: One planner fits all
 
Apache Spark v3.0.0
Apache Spark v3.0.0Apache Spark v3.0.0
Apache Spark v3.0.0
 
Introduction to Lucene & Solr and Usecases
Introduction to Lucene & Solr and UsecasesIntroduction to Lucene & Solr and Usecases
Introduction to Lucene & Solr and Usecases
 
Building a Large Scale SEO/SEM Application with Apache Solr
Building a Large Scale SEO/SEM Application with Apache SolrBuilding a Large Scale SEO/SEM Application with Apache Solr
Building a Large Scale SEO/SEM Application with Apache Solr
 
Introduction to Elasticsearch with basics of Lucene
Introduction to Elasticsearch with basics of LuceneIntroduction to Elasticsearch with basics of Lucene
Introduction to Elasticsearch with basics of Lucene
 
Sarine's Big Data Journey by Rostislav Aaronov
Sarine's Big Data Journey by Rostislav AaronovSarine's Big Data Journey by Rostislav Aaronov
Sarine's Big Data Journey by Rostislav Aaronov
 
A Smarter Pig: Building a SQL interface to Pig using Apache Calcite
A Smarter Pig: Building a SQL interface to Pig using Apache CalciteA Smarter Pig: Building a SQL interface to Pig using Apache Calcite
A Smarter Pig: Building a SQL interface to Pig using Apache Calcite
 
Solr JDBC: Presented by Kevin Risden, Avalon Consulting
Solr JDBC: Presented by Kevin Risden, Avalon ConsultingSolr JDBC: Presented by Kevin Risden, Avalon Consulting
Solr JDBC: Presented by Kevin Risden, Avalon Consulting
 
Streaming Aggregation in Solr - New Horizons for Search: Presented by Erick E...
Streaming Aggregation in Solr - New Horizons for Search: Presented by Erick E...Streaming Aggregation in Solr - New Horizons for Search: Presented by Erick E...
Streaming Aggregation in Solr - New Horizons for Search: Presented by Erick E...
 
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...
 

Andere mochten auch

Realtime statistics using Java, Kafka and Graphite
Realtime statistics using Java, Kafka and GraphiteRealtime statistics using Java, Kafka and Graphite
Realtime statistics using Java, Kafka and Graphite
Hung Nguyen
 
ConcurrentHashMap Code Reading
ConcurrentHashMap Code ReadingConcurrentHashMap Code Reading
ConcurrentHashMap Code Reading
Naoyuki Kakuda
 

Andere mochten auch (7)

Realtime statistics using Java, Kafka and Graphite
Realtime statistics using Java, Kafka and GraphiteRealtime statistics using Java, Kafka and Graphite
Realtime statistics using Java, Kafka and Graphite
 
Application Logging for large systems
Application Logging for large systemsApplication Logging for large systems
Application Logging for large systems
 
ConcurrentHashMap Code Reading
ConcurrentHashMap Code ReadingConcurrentHashMap Code Reading
ConcurrentHashMap Code Reading
 
37 Java Interview Questions
37 Java Interview Questions37 Java Interview Questions
37 Java Interview Questions
 
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
 
Click-Through Example for Flink’s KafkaConsumer Checkpointing
Click-Through Example for Flink’s KafkaConsumer CheckpointingClick-Through Example for Flink’s KafkaConsumer Checkpointing
Click-Through Example for Flink’s KafkaConsumer Checkpointing
 
What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)
 

Ähnlich wie eXtreme Tuesday Club at Pivotal Labs ft. Speemdnet / San Francisco - SEP 2015

Ähnlich wie eXtreme Tuesday Club at Pivotal Labs ft. Speemdnet / San Francisco - SEP 2015 (20)

Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript Everywhere
 
Introduction to Apache Flink - Fast and reliable big data processing
Introduction to Apache Flink - Fast and reliable big data processingIntroduction to Apache Flink - Fast and reliable big data processing
Introduction to Apache Flink - Fast and reliable big data processing
 
Java days gbg online
Java days gbg onlineJava days gbg online
Java days gbg online
 
Speedment - Reactive programming for Java8
Speedment - Reactive programming for Java8Speedment - Reactive programming for Java8
Speedment - Reactive programming for Java8
 
Introduction to Designing and Building Big Data Applications
Introduction to Designing and Building Big Data ApplicationsIntroduction to Designing and Building Big Data Applications
Introduction to Designing and Building Big Data Applications
 
DZone Java 8 Block Buster: Query Databases Using Streams
DZone Java 8 Block Buster: Query Databases Using StreamsDZone Java 8 Block Buster: Query Databases Using Streams
DZone Java 8 Block Buster: Query Databases Using Streams
 
Big data, just an introduction to Hadoop and Scripting Languages
Big data, just an introduction to Hadoop and Scripting LanguagesBig data, just an introduction to Hadoop and Scripting Languages
Big data, just an introduction to Hadoop and Scripting Languages
 
Spark sql meetup
Spark sql meetupSpark sql meetup
Spark sql meetup
 
Cassandra Summit 2014: Apache Spark - The SDK for All Big Data Platforms
Cassandra Summit 2014: Apache Spark - The SDK for All Big Data PlatformsCassandra Summit 2014: Apache Spark - The SDK for All Big Data Platforms
Cassandra Summit 2014: Apache Spark - The SDK for All Big Data Platforms
 
Osd ctw spark
Osd ctw sparkOsd ctw spark
Osd ctw spark
 
Advancing JavaScript with Libraries (Yahoo Tech Talk)
Advancing JavaScript with Libraries (Yahoo Tech Talk)Advancing JavaScript with Libraries (Yahoo Tech Talk)
Advancing JavaScript with Libraries (Yahoo Tech Talk)
 
Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2
 
4th Lecture: JSP and such
4th Lecture:  JSP and such4th Lecture:  JSP and such
4th Lecture: JSP and such
 
A brief tour of modern Java
A brief tour of modern JavaA brief tour of modern Java
A brief tour of modern Java
 
Utilizing the open ntf domino api
Utilizing the open ntf domino apiUtilizing the open ntf domino api
Utilizing the open ntf domino api
 
Essential Camel Components
Essential Camel ComponentsEssential Camel Components
Essential Camel Components
 
Avatar 2.0
Avatar 2.0Avatar 2.0
Avatar 2.0
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Python
 
Scala Introduction
Scala IntroductionScala Introduction
Scala Introduction
 
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
Reactive Java Programming: A new Asynchronous Database Access API by Kuassi M...
 

Mehr von Speedment, Inc.

Mehr von Speedment, Inc. (11)

How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
 
SenchaCon Roadshow Irvine 2017
SenchaCon Roadshow Irvine 2017SenchaCon Roadshow Irvine 2017
SenchaCon Roadshow Irvine 2017
 
SenchaCon 2016 - How to Auto Generate a Back-end in Minutes
SenchaCon 2016 - How to Auto Generate a Back-end in MinutesSenchaCon 2016 - How to Auto Generate a Back-end in Minutes
SenchaCon 2016 - How to Auto Generate a Back-end in Minutes
 
NYJavaSIG - Big Data Microservices w/ Speedment
NYJavaSIG - Big Data Microservices w/ SpeedmentNYJavaSIG - Big Data Microservices w/ Speedment
NYJavaSIG - Big Data Microservices w/ Speedment
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
 
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
 
Speed-up Your Big Data Applications with Sencha and Speedment
Speed-up Your Big Data Applications with Sencha and SpeedmentSpeed-up Your Big Data Applications with Sencha and Speedment
Speed-up Your Big Data Applications with Sencha and Speedment
 
Speedment & Sencha at Oracle Open World 2015
Speedment & Sencha at Oracle Open World 2015Speedment & Sencha at Oracle Open World 2015
Speedment & Sencha at Oracle Open World 2015
 
Java one2015 - Work With Hundreds of Hot Terabytes in JVMs
Java one2015 - Work With Hundreds of Hot Terabytes in JVMsJava one2015 - Work With Hundreds of Hot Terabytes in JVMs
Java one2015 - Work With Hundreds of Hot Terabytes in JVMs
 
SAP Open Source meetup/Speedment - Palo Alto 2015
SAP Open Source meetup/Speedment - Palo Alto 2015SAP Open Source meetup/Speedment - Palo Alto 2015
SAP Open Source meetup/Speedment - Palo Alto 2015
 

Kürzlich hochgeladen

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Kürzlich hochgeladen (20)

OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 

eXtreme Tuesday Club at Pivotal Labs ft. Speemdnet / San Francisco - SEP 2015

  • 1. Wrap your Database in Java 8 Per-Åke Minborg Carina Dreifeldt Malin Weiss Emil Forslund
  • 2. Speedment Company • Company started 2010 • Speedment customers: Fintech, manufacturing, media, telecom, transport, retail, publishing and entertainment. •Office PaloAlto, California Gothenburg, Sweden Open Source Project • Apache 2, started 2015 • Fully Java 8 compatible • www.speedment.org, GitHub
  • 3. Bio Per-Åke Minborg • Master of Science Sweden • Inventor and Serial Entrepreneur • Java >15 years • Speaker at Meetups and Javaforums around the globe, (Java-One 2015) • Java 8 and OpenSource blogger
  • 5. Do You Recognize the following? • When coding it is complex to connect to a database….. …then you use an ORM Source: ZeroTurnaround
  • 6. SOME PROS of Using an ORM: • You can work with a relational database as if it were object oriented. • Increased productivity. • Provides a certain degree of abstraction (you can replace your DBMS).
  • 7. SOME CONS of Using an ORM: • Slows down the application • You must still write SQL, HQL, et. al • You can not access all Java 8 features
  • 8. How to skip these ORMs and work with Pure Java 8 • Lambda expressions • Stream API • Optional
  • 9. Lambda Expressions • Anonymous methods can be expressed using the new ”->” syntax Deck deck = Deck.createShuffledDeck(); List<Card> cards = deck.findWhere(card -> card.isHeart() && card.getValue() > 10 );
  • 10. Lambda Expressions • Any single-method interface can be implemented using lambda • can be annoted with @FunctionalInterface to show this @FunctionalInterface interface VectorOperation { Vector apply(Vector a, Vector b); } VectorOperation plus = (a, b) -> new Vector( a.getX() + b.getX(), a.getY() + b.getY() );
  • 11. Lambda Expressions Functional pointers can also be used with the ”::” syntax Set<Hero> warriors = typicalParty.where(Hero::isWarrior); … interface Hero { boolean isWarrior(); } … class Party { private Set<Hero> heroes; public Set<Hero> select(Predicate<Hero> selector) { … } }
  • 12. Stream API • Streams are a modern way of working with groups of elements • Defining a stream is always an O(1)-operation • The elements are only traversed when used • Streams can often be executed in parallell
  • 13. Stream API • Example: Get the average strength of all warriors with axes in the party Set<Hero> party = … ; int averageStrength = party.stream() .filter(hero -> Archtype.WARRIOR == hero.getArchtype()) .filter(hero -> Weapon.AXE == hero.getWeapon()) .mapToInt(Hero::getStrength) .average(); By replacing .stream() with .parallelStream() the operation can be performed using multiple processors
  • 14. Optional • Null is often described as ”The Billion Dollar Mistake” of modern programming languages • Using the Optional-interface we can now describe a value that might or might not be present in a null-safe way String getEmailAddress() { // Is always defined return this.emailAddress; } Optional<String> getFirstname() { // Might not exist return Optional.ofNullable( this.firstname ); }
  • 15. Optional • You can work with Optionals in the same way you work with streams Optional<String> firstname = getFirstname() .filter(fn -> fn.length() > 3) .filter(fn -> fn.charAt(0) == 'A'); • When the value of an optional is retreived, you can handle every case String absoluteFirstname = firstname.getOrDefault("Anonymous");
  • 16. Speedment API Embrace Java 8 paradigm with stream(), filter(), sort(), limit() etc. Forget about SQL, JQL Focus on Business Logic Focus on what is fun Develop a Database app within hours No Query API Stick to Java 8
  • 17. Initialization Speedment speedment = new HelloSpeedment().build(); Manager<Hare> hares = speedment.managerOf(Hare.class);
  • 18. Persistence Hare spire = hares.newInstance() .setName(“Spire") .setColor(“Blue") .setAge(1) .persist();
  • 19. Querying List<Hare> oldHares = hares.stream() .filter(h -> h.getAge() > 8) .collect(toList());
  • 20. Optimised Predicate Look-up Optional<Hare> spire= hares.stream() .filter(Hare.NAME.equal(“Spire")) .findAny();
  • 21. Entities are Linked Optional<Carrot> carrot = hares.stream() .filter(Hare.NAME.equal(“Spire”)) // Carrot is a foreign key. .flatMap(Hare::findCarrots) .findAny();
  • 23. Configuration • Groovy script like Gradle • Config file is placed relative to the POM dbms { schema { table { name = ”hare"; column { name = "name"; } } } }
  • 24. Ease of use: • Single Maven dependency in POM • Maven plugin for code generation/GUI • Maven targets • Works with Gradle • GUI to automatically derive the groovy config file from existing databases
  • 25. Conclusions • Code generation, No boiler plate code • Focus on the problem at hand! • Forget about the database • Use Java 8
  • 26. Workshop: Social network We will focus on the server-side MySQL database Server application Client GUI http
  • 27. Workshop: Social Network The goal is to add features: • Register • Login • Upload pictures
  • 28. Workshop: Social Network Speedment: https://github.com/speedment/speedment https://github.com/Pyknic/SocialPhotoNetworkClient Social Network Lab : https://github.com/Pyknic/SocialPhotoNetworkServer
  • 29. Insane Mode... Want fast development + super duper fast execution ? Speedment Enterprise Solution provides extreme performance
  • 30. We are Where You are! • www.speedment.org • GitHub: https://github.com/speedment/speedment • Twitter: @Pminborg • Mail: minborg@speedment.org • Blog: minborgsjavapot.blogspot.com • SiliconValley