SlideShare a Scribd company logo
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Get Back in Control of your SQL
SQL and Java could work
together so much better if
we only let them.
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
Me – @lukaseder
SQL is a device whose mystery
is only exceeded by its power!
- Founder and CEO at Data Geekery
- SQL Aficionado
- Java Aficionado
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
SQL – a corporate thing
THE FOLLOWING IS COMMUNICATED TO YOU
SOLELY FOR ENTERTAINMENT PURPOSES. NO
ONE SANE WOULD BELIEVE A GUY WHO CLAIMS
HE IS A SQL AFICIONADO OR WORSE WHO CLAIMS
THAT SQL IS ANYTHING NEAR BEAUTIFUL. IF YOU
STILL FIND THE FOLLOWING INTERESTING AND IF
YOU BASE YOUR PURCHASING DECISIONS UPON
THAT, YOU DEFINITELY NEED PROFESSIONAL HELP.
WE ACTUALLY PROVIDE SUCH HELP.
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
So, let’s talk about
SQL
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
SQL is Powerful!
My Reaction when I
forget the WHERE
clause on my DELETE
statement…
With autocommit
active
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
SQL and Java – in theory
Java SQL
In this metaphor, electricity is the data (SQL) that
flows into your appliance / application (Java)
one jack one plug
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
SQL and Java – in practice
Java SQL
Images from: http://en.wikipedia.org/wiki/AC_power_plugs_and_sockets. License: public domain
one jack lots of plugs
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
JDBC
PreparedStatement stmt = connection.prepareStatement(
"SELECT text FROM products WHERE cust_id = ? AND value < ?");
stmt.setInt(1, custID);
stmt.setBigDecimal(2, BigDecimal.ZERO);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
System.out.println(rs.getString("TEXT"));
}
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
JDBC – the naked truth
01: PreparedStatement stmt = connection.prepareStatement(
02: "SELECT p.text txt" +
03: (isAccount ? ", NVL(a.type, ?) " : "") +
04: "FROM products p " +
05: (isAccount ? " INNER JOIN accounts a USING (prod_id) " : "") +
06: " WHERE p.cust_id = ? AND p.value < ?" +
07: (isAccount ? " AND a.type LIKE '%" + type + "%'" : "");
08: stmt.setInt(1, defaultType);
09: stmt.setInt(2, custID);
10: stmt.setBigDecimal(3, BigDecimal.ZERO);
11: ResultSet rs = stmt.executeQuery();
12:
13: while (rs.next()) {
14: Clob clob = rs.getClob("TEXT");
15: System.out.println(clob.getSubString(1, (int) clob.length());
16: }
17:
18: rs.close();
19: stmt.close();
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
JDBC – the naked truth
01: PreparedStatement stmt = connection.prepareStatement( //
02: "SELECT p.text txt" + //
03: (isAccount ? ", NVL(a.type, ?) " : "") + //
04: "FROM products p " + // Syntax error when isAccount == false
05: (isAccount ? " INNER JOIN accounts a USING (prod_id) " : "") + //
06: " WHERE p.cust_id = ? AND p.value < ?" + //
07: (isAccount ? " AND a.type LIKE '%" + type + "%'" : ""); // Syntax error and SQL injection possible
08: stmt.setInt(1, defaultType); // Wrong bind index
09: stmt.setInt(2, custID); //
10: stmt.setBigDecimal(3, BigDecimal.ZERO); //
11: ResultSet rs = stmt.executeQuery(); //
12:
13: while (rs.next()) { //
14: Clob clob = rs.getClob("TEXT"); // Wrong column name
15: System.out.println(clob.getSubString(1, (int) clob.length()); // ojdbc6: clob.free() should be called
16: } //
17:
18: rs.close(); // close() not really in finally block
19: stmt.close(); //
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
What JDBC means for developers
Images from Flickr. To the left by: Matthew Straubmuller, Greg Grossmeier. License: CC BY SA 2.0. Electric Engineers to the right copyright by Marco Sarli, all rights reserved.
With JDBC, your developers have to do a lot of
manual, error-prone (dangerous) and inefficient work
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
EJB 2.0 EntityBeans
public interface CustomerRequest extends EJBObject {
BigInteger getId();
String getText();
void setText(String text);
@Override
void remove();
}
public interface CustomerRequestHome extends EJBHome {
CustomerRequest create(BigInteger id);
CustomerRequest find(BigInteger id);
}
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
EJB 2.0 – the naked truth
<weblogic-enterprise-bean>
<ejb-name>com.example.CustomerRequestHome</ejb-name>
<entity-descriptor>
<pool>
<max-beans-in-free-pool>100</max-beans-in-free-pool>
</pool>
<entity-cache>
<max-beans-in-cache>500</max-beans-in-cache>
<idle-timeout-seconds>10</idle-timeout-seconds>
<concurrency-strategy>Database</concurrency-strategy>
</entity-cache>
<persistence>
<delay-updates-until-end-of-tx>True</delay-updates-until-end-of-tx>
</persistence>
<entity-clustering>
<home-is-clusterable>False</home-is-clusterable>
<home-load-algorithm>round-robin</home-load-algorithm>
</entity-clustering>
</entity-descriptor>
<transaction-descriptor/>
<enable-call-by-reference>True</enable-call-by-reference>
<jndi-name>com.example.CustomerRequestHome</jndi-name>
</weblogic-enterprise-bean>
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
EJB 2.0 – the naked truth
<pool>
<max-beans-in-free-pool>100</max-beans-in-free-pool>
</pool>
<entity-cache>
<max-beans-in-cache>500</max-beans-in-cache>
<idle-timeout-seconds>10</idle-timeout-seconds>
<concurrency-strategy>Database</concurrency-strategy>
</entity-cache>
<persistence>
<delay-updates-until-end-of-tx>True</delay-updates-…>
</persistence>
o_O
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
EJB 2.0
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
JPA and EJB 3.0
EntityManager em = factory.createEntityManager();
em.getTransaction().begin();
em.persist(new Event("Conference", new Date());
em.persist(new Event("After Party", new Date());
List result = em.createQuery("from Event").getResultList();
for (Event event : (List<Event>) result) {
System.out.println("Event : " + event.getTitle());
}
em.getTransaction().commit();
em.close();
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
EJB 3.0 – the naked truth
@Entity @Table(name = "EVENTS")
public class Event {
private Long id;
private String title;
private Date date;
@Id @GeneratedValue(generator = "increment")
@GenericGenerator(name = "increment", strategy = "increment")
public Long getId() { /* … */ }
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "EVENT_DATE")
public Date getDate() { /* … */ }
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
EJB 3.0 – Yep, annotations!
@OneToMany(mappedBy = "destCustomerId")
@ManyToMany
@Fetch(FetchMode.SUBSELECT)
@JoinTable(
name = "customer_dealer_map",
joinColumns = {
@JoinColumn(name = "customer_id", referencedColumnName = "id")
},
inverseJoinColumns = {
@JoinColumn(name = "dealer_id", referencedColumnName = "id")
}
)
private Collection dealers;
Found at http://stackoverflow.com/q/17491912/521799
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
JPA 3.0 Preview – Annotatiomania™
@SeveralAndThenNothing @MaybeThisDoesSomething
@TweakThisWithThat(
tweak = {
@TweakID(name = "id", preferredValue = 1839),
@TweakID(name = "test", preferredValue = 839),
@TweakID(name = "test.old", preferredValue = 34),
},
inCaseOf = {
@ConditionalXMLFiltering(run = 5),
}
)
@OneToMany @OneToManyMore @AnyOne @AnyBody @DoesThisEvenMeanAnything @DoesAnyoneEvenReadThis
@ManyToMany @Many @AnnotationsTotallyRock @DeclarativeProgrammingRules @NoMoreExplicitAlgorithms
@Fetch @FetchMany @FetchWithDiscriminator(name = "no_name")
@JoinTable(joinColumns = {
@JoinColumn(name = "customer_id", referencedColumnName = "id")
})
@PrefetchJoinWithDiscriminator @JustTrollingYouKnow @LOL
@IfJoiningAvoidHashJoins @ButUseHashJoinsWhenMoreThan(records = 1000)
@XmlDataTransformable @SpringPrefechAdapter
private Collection employees;
Might not be true
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
JPA 4.0 Preview
var employees;
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
More information here
www.annotatiomania.com
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
What’s next?
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
What JPA means for developers…
Images from Wikimedia. License: public domain. High voltage power lines by Simon Koopmann. License: CC-BY SA 3.0
With JPA, your developers use a huge framework with
lots of complexity that can get hard to manage
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
… when developers actually wanted this
Java SQL
one jack one plug
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
Note, we’re talking about SQL. Not Persistence…
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
Note, we’re talking about SQL. Not Persistence…
FYI: Gavin King: Creator of Hibernate!
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
NoSQL?
…
… so, should we maybe abandon SQL?
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
NoSQL? Who said it?
Our service ran at 99.99 percent
uptime in the first quarter of 2009,
runs more than 200 million
transactions a day, and has subsecond
response time; and we are constantly
making advances to deliver it even
faster.
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
NoSQL? Marc Benioff – salesforce.com
Our service ran at 99.99 percent
uptime in the first quarter of 2009,
runs more than 200 million
transactions a day, and has subsecond
response time; and we are constantly
making advances to deliver it even
faster.
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
NoSQL? Marc Benioff – salesforce.com
He’s talking about
salesforce.com’s
Oracle database.
He “invented” the
cloud
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
NoSQL? Who said it?
• 300 TB of data files for production
DBs in total
• LHC logging database ~140TB,
expected growth up to ~70 TB /
year
• 13 Production experiments'
database ~120 TB in total
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
NoSQL? Collecting LHC data with Oracle Exadata
• 300 TB of data files for production
DBs in total
• LHC logging database ~140TB,
expected growth up to ~70 TB /
year
• 13 Production experiments'
database ~120 TB in total
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
NoSQL for Big Data?
- You’re giving up on ACID
- You’re giving up on type safety
- You’re giving up on standards
- You’re giving up on tooling
- You’re giving up on relational algebra
- You haven’t asked operations
- You don’t actually have «Big Data»
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
NoSQL for Big Data?
- You’re giving up on ACID
- You’re giving up on type safety
- You’re giving up on standards
- You’re giving up on tooling
- You’re giving up on relational algebra
- You haven’t asked operations
- You don’t actually have «Big Data»
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
Seen at the O’Reilly Strata Conf:
History of NoSQL by Mark Madsen. Picture published by Edd Dumbill
NoSQL? No, SQL!
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
NoSQL? No, SQL!
So, let’s talk about
SQL
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
Let’s calculate a running total
| ID | VALUE_DATE | AMOUNT |
|------|------------|--------|
| 9997 | 2014-03-18 | 99.17 |
| 9981 | 2014-03-16 | 71.44 |
| 9979 | 2014-03-16 | -94.60 |
| 9977 | 2014-03-16 | -6.96 |
| 9971 | 2014-03-15 | -65.95 |
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
Let’s calculate a running total
| ID | VALUE_DATE | AMOUNT | BALANCE |
|------|------------|--------|------------|
| 9997 | 2014-03-18 | 99.17 | 19985.81 |
| 9981 | 2014-03-16 | 71.44 | 19886.64 |
| 9979 | 2014-03-16 | -94.60 | 19815.20 |
| 9977 | 2014-03-16 | -6.96 | 19909.80 |
| 9971 | 2014-03-15 | -65.95 | 19916.76 |
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
Let’s calculate a running total
| ID | VALUE_DATE | AMOUNT | BALANCE |
|------|------------|--------|------------|
| 9997 | 2014-03-18 | +99.17 =19985.81 |
| 9981 | 2014-03-16 | 71.44 | +19886.64 |
| 9979 | 2014-03-16 | -94.60 | 19815.20 |
| 9977 | 2014-03-16 | -6.96 | 19909.80 |
| 9971 | 2014-03-15 | -65.95 | 19916.76 |
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
Let’s calculate a running total
| ID | VALUE_DATE | AMOUNT | BALANCE |
|------|------------|--------|------------|
| 9997 | 2014-03-18 | 99.17 | 19985.81 |
| 9981 | 2014-03-16 | +71.44 =19886.64 |
| 9979 | 2014-03-16 | -94.60 | +19815.20 |
| 9977 | 2014-03-16 | -6.96 | 19909.80 |
| 9971 | 2014-03-15 | -65.95 | 19916.76 |
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
Let’s calculate a running total
| ID | VALUE_DATE | AMOUNT | BALANCE |
|------|------------|--------|------------|
| 9997 | 2014-03-18 | 99.17 | 19985.81 |
| 9981 | 2014-03-16 | +71.44 =19886.64 | n
| 9979 | 2014-03-16 | -94.60 | +19815.20 | n+1
| 9977 | 2014-03-16 | -6.96 | 19909.80 |
| 9971 | 2014-03-15 | -65.95 | 19916.76 |BALANCE(ROWn) = BALANCE(ROWn+1) + AMOUNT(ROWn)
BALANCE(ROWn+1) = BALANCE(ROWn) – AMOUNT(ROWn)
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
SELECT
t.*,
t.current_balance - NVL(
SUM(t.amount) OVER (
PARTITION BY t.account_id
ORDER BY t.value_date DESC,
t.id DESC
ROWS BETWEEN UNBOUNDED PRECEDING
AND 1 PRECEDING
),
0) AS balance
FROM v_transactions t
WHERE t.account_id = 1
ORDER BY t.value_date DESC,
t.id DESC
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
SUM(t.amount) OVER (
PARTITION BY t.account_id
ORDER BY t.value_date DESC,
t.id DESC
ROWS BETWEEN UNBOUNDED PRECEDING
AND 1 PRECEDING
)
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
SUM(t.amount) OVER (
PARTITION BY t.account_id
ORDER BY t.value_date DESC,
t.id DESC
ROWS BETWEEN UNBOUNDED PRECEDING
AND 1 PRECEDING
)
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
SUM(t.amount) OVER (
PARTITION BY t.account_id
ORDER BY t.value_date DESC,
t.id DESC
ROWS BETWEEN UNBOUNDED PRECEDING
AND 1 PRECEDING
)
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
SUM(t.amount) OVER (
PARTITION BY t.account_id
ORDER BY t.value_date DESC,
t.id DESC
ROWS BETWEEN UNBOUNDED PRECEDING
AND 1 PRECEDING
)
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
SUM(t.amount) OVER (
PARTITION BY t.account_id
ORDER BY t.value_date DESC,
t.id DESC
ROWS BETWEEN UNBOUNDED PRECEDING
AND 1 PRECEDING
)
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
| ID | VALUE_DATE | AMOUNT | BALANCE |
|------|------------|--------|------------|
| 9997 | 2014-03-18 -(99.17)| +19985.81 |
| 9981 | 2014-03-16 -(71.44)| 19886.64 |
| 9979 | 2014-03-16 -(-94.60)| 19815.20 |
| 9977 | 2014-03-16 | -6.96 | =19909.80 |
| 9971 | 2014-03-15 | -65.95 | 19916.76 |
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
Don’t you think that’s beautiful?
Stockholm Syndrome:
We love COBOL SQL
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
Winston Churchill
SQL is the worst
form of database
querying, except
for all the other
forms.
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
More SQL Calculations
| TEXT | VOTES | RANK | PERCENT |
|-------------|-------|------------|---------|
| jOOQ | 1383 | 1 | 32 % |
| Hibernate | 1029 | 2 | 23 % |
| EclipseLink | 881 | 3 | 20 % |
| JDBC | 533 | 4 | 12 % |
| Spring JDBC | 451 | 5 | 10 % |
Data may not be accurate…
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
More SQL Calculations
SELECT p.text,
p.votes,
DENSE_RANK() OVER (ORDER BY p.votes DESC) AS "rank",
LPAD(
(p.votes * 100 / SUM(p.votes) OVER ()) || ' %',
4, ' '
) AS "percent"
FROM poll_options p
WHERE p.poll_id = 12
ORDER BY p.votes DESC
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
The same with jOOQ
select (p.TEXT,
p.VOTES,
denseRank().over().orderBy(p.VOTES.desc()).as("rank"),
lpad(
p.VOTES.mul(100).div(sum(p.VOTES).over()).concat(" %"),
4, " "
).as("percent"))
.from (POLL_OPTIONS.as("p"))
.where (p.POLL_ID.eq(12))
.orderBy(p.VOTES.desc());
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
The same with jOOQ in Scala (!)
select (p.TEXT,
p.VOTES,
denseRank() over() orderBy(p.VOTES desc) as "rank",
lpad(
(p.VOTES * 100) / (sum(p.VOTES) over()) || " %",
4, " "
) as "percent")
from (POLL_OPTIONS as "p")
where (p.POLL_ID === 12)
orderBy (p.VOTES desc)
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
What jOOQ means for developers
Java SQL
one jack all plugs
jOOQ
one adaptor
With jOOQ, Java plugs into SQL intuitively, letting
your developers focus on business-logic again.
Images from Wikimedia. License: public domain. Travel converter by Cephira. License: CC-BY SA 3.0
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
What jOOQ means for developers
Java SQL
one jack all plugs
jOOQ
one adaptor
Images from Wikimedia. License: public domain. Travel converter by Cephira. License: CC-BY SA 3.0
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
Examples
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
Marc Benioff from salesforce
All companies
benefit when they
can afford to focus
on innovation
rather than
infrastructure
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
A vision of a better SQL application
- Database first
- Performance
- Type safe JDBC
- Code Generation
- Active Records
- Stored Procedures
- SQL Transformation
- SQL Standardisation
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
«jOOQ» 10% discount code
And a shameless book recommendation
Markus Winand from
Use-The-Index-Luke.com
ROI north of 83’174%
Achieve proper indexing and
performance in popular RDBMS
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
And a shameless tool recommendation
Open source databases:
- Free / Apache license
Commercial databases:
- Commercial license
Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
Intro SQL and Java jOOQ Examples
That’s it folks
More free Java / SQL knowledge on:
• Blog: http://blog.jooq.org
• Twitter: @JavaOOQ / @lukaseder
• Newsletter: http://www.jooq.org

More Related Content

What's hot

Scala and Spring
Scala and SpringScala and Spring
Scala and Spring
Eberhard Wolff
 
Get Back in Control of Your SQL with jOOQ at #Java2Days
Get Back in Control of Your SQL with jOOQ at #Java2DaysGet Back in Control of Your SQL with jOOQ at #Java2Days
Get Back in Control of Your SQL with jOOQ at #Java2Days
Lukas Eder
 
10 Reasons Why we Love Some APIs and Why we Hate Some Others
10 Reasons Why we Love Some APIs and Why we Hate Some Others10 Reasons Why we Love Some APIs and Why we Hate Some Others
10 Reasons Why we Love Some APIs and Why we Hate Some Others
Lukas Eder
 
Eddystone Beacons - Physical Web - Giving a URL to All Objects
Eddystone Beacons - Physical Web - Giving a URL to All ObjectsEddystone Beacons - Physical Web - Giving a URL to All Objects
Eddystone Beacons - Physical Web - Giving a URL to All Objects
Jeff Prestes
 
Physical web
Physical webPhysical web
Physical web
Jeff Prestes
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForce
Ciklum Ukraine
 
Extending spring
Extending springExtending spring
Extending spring
Joshua Long
 
JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개
Reagan Hwang
 
Vavr Java User Group Rheinland
Vavr Java User Group RheinlandVavr Java User Group Rheinland
Vavr Java User Group Rheinland
David Schmitz
 
Questioning the status quo
Questioning the status quoQuestioning the status quo
Questioning the status quo
Ivano Pagano
 
Java Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJava Configuration Deep Dive with Spring
Java Configuration Deep Dive with Spring
Joshua Long
 
There's more than web
There's more than webThere's more than web
There's more than web
Matt Evans
 
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New WorldJavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
Robert Nyman
 
Industrializing the creation of machine images and Docker containers for clou...
Industrializing the creation of machine images and Docker containers for clou...Industrializing the creation of machine images and Docker containers for clou...
Industrializing the creation of machine images and Docker containers for clou...
OW2
 
Praktik Pengembangan Konten E-Learning HTML5 Sederhana
Praktik Pengembangan Konten E-Learning HTML5 SederhanaPraktik Pengembangan Konten E-Learning HTML5 Sederhana
Praktik Pengembangan Konten E-Learning HTML5 Sederhana
Muhammad Yusuf
 
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 202010 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
Matt Raible
 

What's hot (16)

Scala and Spring
Scala and SpringScala and Spring
Scala and Spring
 
Get Back in Control of Your SQL with jOOQ at #Java2Days
Get Back in Control of Your SQL with jOOQ at #Java2DaysGet Back in Control of Your SQL with jOOQ at #Java2Days
Get Back in Control of Your SQL with jOOQ at #Java2Days
 
10 Reasons Why we Love Some APIs and Why we Hate Some Others
10 Reasons Why we Love Some APIs and Why we Hate Some Others10 Reasons Why we Love Some APIs and Why we Hate Some Others
10 Reasons Why we Love Some APIs and Why we Hate Some Others
 
Eddystone Beacons - Physical Web - Giving a URL to All Objects
Eddystone Beacons - Physical Web - Giving a URL to All ObjectsEddystone Beacons - Physical Web - Giving a URL to All Objects
Eddystone Beacons - Physical Web - Giving a URL to All Objects
 
Physical web
Physical webPhysical web
Physical web
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForce
 
Extending spring
Extending springExtending spring
Extending spring
 
JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개
 
Vavr Java User Group Rheinland
Vavr Java User Group RheinlandVavr Java User Group Rheinland
Vavr Java User Group Rheinland
 
Questioning the status quo
Questioning the status quoQuestioning the status quo
Questioning the status quo
 
Java Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJava Configuration Deep Dive with Spring
Java Configuration Deep Dive with Spring
 
There's more than web
There's more than webThere's more than web
There's more than web
 
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New WorldJavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
 
Industrializing the creation of machine images and Docker containers for clou...
Industrializing the creation of machine images and Docker containers for clou...Industrializing the creation of machine images and Docker containers for clou...
Industrializing the creation of machine images and Docker containers for clou...
 
Praktik Pengembangan Konten E-Learning HTML5 Sederhana
Praktik Pengembangan Konten E-Learning HTML5 SederhanaPraktik Pengembangan Konten E-Learning HTML5 Sederhana
Praktik Pengembangan Konten E-Learning HTML5 Sederhana
 
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 202010 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
 

Viewers also liked

Neoliberalismo y perdida de la soberanía alimentaria: cuando el maná se convi...
Neoliberalismo y perdida de la soberanía alimentaria: cuando el maná se convi...Neoliberalismo y perdida de la soberanía alimentaria: cuando el maná se convi...
Neoliberalismo y perdida de la soberanía alimentaria: cuando el maná se convi...
FLOR KAREN ARIANA GONZALES ZUÑIGA
 
How can we rise in the world again
How can we rise in the world againHow can we rise in the world again
How can we rise in the world again
syed mohammad kashaf qaiser
 
Building collaborative workflows for scientific data
Building collaborative workflows for scientific dataBuilding collaborative workflows for scientific data
Building collaborative workflows for scientific data
Bruno Vieira
 
Rubrica de Clase Semestre 2015 - I, UNCP
Rubrica de Clase Semestre 2015 - I, UNCPRubrica de Clase Semestre 2015 - I, UNCP
Rubrica de Clase Semestre 2015 - I, UNCP
Gusstock Concha Flores
 
An Introduction to jOOQ
An Introduction to jOOQAn Introduction to jOOQ
An Introduction to jOOQ
Steve Pember
 
DESIGN OF SUBSURFACE DRAINAGE SYSTEM
DESIGN OF SUBSURFACE DRAINAGE SYSTEMDESIGN OF SUBSURFACE DRAINAGE SYSTEM
DESIGN OF SUBSURFACE DRAINAGE SYSTEM
Namitha M R
 

Viewers also liked (7)

Open and Flexible Studies
Open and Flexible StudiesOpen and Flexible Studies
Open and Flexible Studies
 
Neoliberalismo y perdida de la soberanía alimentaria: cuando el maná se convi...
Neoliberalismo y perdida de la soberanía alimentaria: cuando el maná se convi...Neoliberalismo y perdida de la soberanía alimentaria: cuando el maná se convi...
Neoliberalismo y perdida de la soberanía alimentaria: cuando el maná se convi...
 
How can we rise in the world again
How can we rise in the world againHow can we rise in the world again
How can we rise in the world again
 
Building collaborative workflows for scientific data
Building collaborative workflows for scientific dataBuilding collaborative workflows for scientific data
Building collaborative workflows for scientific data
 
Rubrica de Clase Semestre 2015 - I, UNCP
Rubrica de Clase Semestre 2015 - I, UNCPRubrica de Clase Semestre 2015 - I, UNCP
Rubrica de Clase Semestre 2015 - I, UNCP
 
An Introduction to jOOQ
An Introduction to jOOQAn Introduction to jOOQ
An Introduction to jOOQ
 
DESIGN OF SUBSURFACE DRAINAGE SYSTEM
DESIGN OF SUBSURFACE DRAINAGE SYSTEMDESIGN OF SUBSURFACE DRAINAGE SYSTEM
DESIGN OF SUBSURFACE DRAINAGE SYSTEM
 

Similar to The vJUG talk about jOOQ: Get Back in Control of Your SQL

Get Back in Control of your SQL
Get Back in Control of your SQLGet Back in Control of your SQL
Get Back in Control of your SQL
Java Usergroup Berlin-Brandenburg
 
Best Way to Write SQL in Java
Best Way to Write SQL in JavaBest Way to Write SQL in Java
Best Way to Write SQL in Java
Gerger
 
2000 lines of java or 50 lines of sql the choice is yours - Lukas Eder
2000 lines of java or 50 lines of sql the choice is yours - Lukas Eder2000 lines of java or 50 lines of sql the choice is yours - Lukas Eder
2000 lines of java or 50 lines of sql the choice is yours - Lukas Eder
JAXLondon_Conference
 
สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1
ทวิร พานิชสมบัติ
 
Going Offline with Gears And GWT
Going Offline with Gears And GWTGoing Offline with Gears And GWT
Going Offline with Gears And GWT
tom.peck
 
Bkbiet day2 & 3
Bkbiet day2 & 3Bkbiet day2 & 3
Bkbiet day2 & 3
mihirio
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
Igor Bronovskyy
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security Vulnerabilities
Carol McDonald
 
PHPUG Presentation
PHPUG PresentationPHPUG Presentation
PHPUG Presentation
Damon Cortesi
 
10 SQL Tricks that You Didn't Think Were Possible
10 SQL Tricks that You Didn't Think Were Possible10 SQL Tricks that You Didn't Think Were Possible
10 SQL Tricks that You Didn't Think Were Possible
Lukas Eder
 
NoSQL? No, SQL! – How to Calculate Running Totals - Our Talk at the JUGS Bern
NoSQL? No, SQL! – How to Calculate Running Totals - Our Talk at the JUGS BernNoSQL? No, SQL! – How to Calculate Running Totals - Our Talk at the JUGS Bern
NoSQL? No, SQL! – How to Calculate Running Totals - Our Talk at the JUGS Bern
DataGeekery
 
Rails and security
Rails and securityRails and security
Rails and security
Andrey Tokarchuk
 
2009 Barcamp Nashville Web Security 101
2009 Barcamp Nashville   Web Security 1012009 Barcamp Nashville   Web Security 101
2009 Barcamp Nashville Web Security 101
brian_dailey
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
 
Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)
Tom Diederich
 
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009
mirahman
 
SQL Injection in PHP
SQL Injection in PHPSQL Injection in PHP
SQL Injection in PHP
Dave Ross
 
Spca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_librariesSpca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_libraries
NCCOMMS
 
PHP Secure Programming
PHP Secure ProgrammingPHP Secure Programming
PHP Secure Programming
Balavignesh Kasinathan
 
Sql Injection V.2
Sql Injection V.2Sql Injection V.2
Sql Injection V.2
Tjylen Veselyj
 

Similar to The vJUG talk about jOOQ: Get Back in Control of Your SQL (20)

Get Back in Control of your SQL
Get Back in Control of your SQLGet Back in Control of your SQL
Get Back in Control of your SQL
 
Best Way to Write SQL in Java
Best Way to Write SQL in JavaBest Way to Write SQL in Java
Best Way to Write SQL in Java
 
2000 lines of java or 50 lines of sql the choice is yours - Lukas Eder
2000 lines of java or 50 lines of sql the choice is yours - Lukas Eder2000 lines of java or 50 lines of sql the choice is yours - Lukas Eder
2000 lines of java or 50 lines of sql the choice is yours - Lukas Eder
 
สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1
 
Going Offline with Gears And GWT
Going Offline with Gears And GWTGoing Offline with Gears And GWT
Going Offline with Gears And GWT
 
Bkbiet day2 & 3
Bkbiet day2 & 3Bkbiet day2 & 3
Bkbiet day2 & 3
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security Vulnerabilities
 
PHPUG Presentation
PHPUG PresentationPHPUG Presentation
PHPUG Presentation
 
10 SQL Tricks that You Didn't Think Were Possible
10 SQL Tricks that You Didn't Think Were Possible10 SQL Tricks that You Didn't Think Were Possible
10 SQL Tricks that You Didn't Think Were Possible
 
NoSQL? No, SQL! – How to Calculate Running Totals - Our Talk at the JUGS Bern
NoSQL? No, SQL! – How to Calculate Running Totals - Our Talk at the JUGS BernNoSQL? No, SQL! – How to Calculate Running Totals - Our Talk at the JUGS Bern
NoSQL? No, SQL! – How to Calculate Running Totals - Our Talk at the JUGS Bern
 
Rails and security
Rails and securityRails and security
Rails and security
 
2009 Barcamp Nashville Web Security 101
2009 Barcamp Nashville   Web Security 1012009 Barcamp Nashville   Web Security 101
2009 Barcamp Nashville Web Security 101
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)
 
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009
 
SQL Injection in PHP
SQL Injection in PHPSQL Injection in PHP
SQL Injection in PHP
 
Spca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_librariesSpca2014 hillier 3rd party_javascript_libraries
Spca2014 hillier 3rd party_javascript_libraries
 
PHP Secure Programming
PHP Secure ProgrammingPHP Secure Programming
PHP Secure Programming
 
Sql Injection V.2
Sql Injection V.2Sql Injection V.2
Sql Injection V.2
 

Recently uploaded

GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
christinelarrosa
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
DanBrown980551
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)
HarpalGohil4
 
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Ukraine
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
christinelarrosa
 
Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...
Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...
Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...
manji sharman06
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
FilipTomaszewski5
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's TipsGetting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
ScyllaDB
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
christinelarrosa
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
DianaGray10
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Neo4j
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 

Recently uploaded (20)

GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)
 
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
 
Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...
Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...
Call Girls Chandigarh🔥7023059433🔥Agency Profile Escorts in Chandigarh Availab...
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's TipsGetting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 

The vJUG talk about jOOQ: Get Back in Control of Your SQL

  • 1. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Get Back in Control of your SQL SQL and Java could work together so much better if we only let them.
  • 2. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples Me – @lukaseder SQL is a device whose mystery is only exceeded by its power! - Founder and CEO at Data Geekery - SQL Aficionado - Java Aficionado
  • 3. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples SQL – a corporate thing THE FOLLOWING IS COMMUNICATED TO YOU SOLELY FOR ENTERTAINMENT PURPOSES. NO ONE SANE WOULD BELIEVE A GUY WHO CLAIMS HE IS A SQL AFICIONADO OR WORSE WHO CLAIMS THAT SQL IS ANYTHING NEAR BEAUTIFUL. IF YOU STILL FIND THE FOLLOWING INTERESTING AND IF YOU BASE YOUR PURCHASING DECISIONS UPON THAT, YOU DEFINITELY NEED PROFESSIONAL HELP. WE ACTUALLY PROVIDE SUCH HELP.
  • 4. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples So, let’s talk about SQL
  • 5. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples SQL is Powerful! My Reaction when I forget the WHERE clause on my DELETE statement… With autocommit active
  • 6. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples SQL and Java – in theory Java SQL In this metaphor, electricity is the data (SQL) that flows into your appliance / application (Java) one jack one plug
  • 7. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples SQL and Java – in practice Java SQL Images from: http://en.wikipedia.org/wiki/AC_power_plugs_and_sockets. License: public domain one jack lots of plugs
  • 8. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples JDBC PreparedStatement stmt = connection.prepareStatement( "SELECT text FROM products WHERE cust_id = ? AND value < ?"); stmt.setInt(1, custID); stmt.setBigDecimal(2, BigDecimal.ZERO); ResultSet rs = stmt.executeQuery(); while (rs.next()) { System.out.println(rs.getString("TEXT")); }
  • 9. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples JDBC – the naked truth 01: PreparedStatement stmt = connection.prepareStatement( 02: "SELECT p.text txt" + 03: (isAccount ? ", NVL(a.type, ?) " : "") + 04: "FROM products p " + 05: (isAccount ? " INNER JOIN accounts a USING (prod_id) " : "") + 06: " WHERE p.cust_id = ? AND p.value < ?" + 07: (isAccount ? " AND a.type LIKE '%" + type + "%'" : ""); 08: stmt.setInt(1, defaultType); 09: stmt.setInt(2, custID); 10: stmt.setBigDecimal(3, BigDecimal.ZERO); 11: ResultSet rs = stmt.executeQuery(); 12: 13: while (rs.next()) { 14: Clob clob = rs.getClob("TEXT"); 15: System.out.println(clob.getSubString(1, (int) clob.length()); 16: } 17: 18: rs.close(); 19: stmt.close();
  • 10. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples JDBC – the naked truth 01: PreparedStatement stmt = connection.prepareStatement( // 02: "SELECT p.text txt" + // 03: (isAccount ? ", NVL(a.type, ?) " : "") + // 04: "FROM products p " + // Syntax error when isAccount == false 05: (isAccount ? " INNER JOIN accounts a USING (prod_id) " : "") + // 06: " WHERE p.cust_id = ? AND p.value < ?" + // 07: (isAccount ? " AND a.type LIKE '%" + type + "%'" : ""); // Syntax error and SQL injection possible 08: stmt.setInt(1, defaultType); // Wrong bind index 09: stmt.setInt(2, custID); // 10: stmt.setBigDecimal(3, BigDecimal.ZERO); // 11: ResultSet rs = stmt.executeQuery(); // 12: 13: while (rs.next()) { // 14: Clob clob = rs.getClob("TEXT"); // Wrong column name 15: System.out.println(clob.getSubString(1, (int) clob.length()); // ojdbc6: clob.free() should be called 16: } // 17: 18: rs.close(); // close() not really in finally block 19: stmt.close(); //
  • 11. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples What JDBC means for developers Images from Flickr. To the left by: Matthew Straubmuller, Greg Grossmeier. License: CC BY SA 2.0. Electric Engineers to the right copyright by Marco Sarli, all rights reserved. With JDBC, your developers have to do a lot of manual, error-prone (dangerous) and inefficient work
  • 12. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples EJB 2.0 EntityBeans public interface CustomerRequest extends EJBObject { BigInteger getId(); String getText(); void setText(String text); @Override void remove(); } public interface CustomerRequestHome extends EJBHome { CustomerRequest create(BigInteger id); CustomerRequest find(BigInteger id); }
  • 13. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples EJB 2.0 – the naked truth <weblogic-enterprise-bean> <ejb-name>com.example.CustomerRequestHome</ejb-name> <entity-descriptor> <pool> <max-beans-in-free-pool>100</max-beans-in-free-pool> </pool> <entity-cache> <max-beans-in-cache>500</max-beans-in-cache> <idle-timeout-seconds>10</idle-timeout-seconds> <concurrency-strategy>Database</concurrency-strategy> </entity-cache> <persistence> <delay-updates-until-end-of-tx>True</delay-updates-until-end-of-tx> </persistence> <entity-clustering> <home-is-clusterable>False</home-is-clusterable> <home-load-algorithm>round-robin</home-load-algorithm> </entity-clustering> </entity-descriptor> <transaction-descriptor/> <enable-call-by-reference>True</enable-call-by-reference> <jndi-name>com.example.CustomerRequestHome</jndi-name> </weblogic-enterprise-bean>
  • 14. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples EJB 2.0 – the naked truth <pool> <max-beans-in-free-pool>100</max-beans-in-free-pool> </pool> <entity-cache> <max-beans-in-cache>500</max-beans-in-cache> <idle-timeout-seconds>10</idle-timeout-seconds> <concurrency-strategy>Database</concurrency-strategy> </entity-cache> <persistence> <delay-updates-until-end-of-tx>True</delay-updates-…> </persistence> o_O
  • 15. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples EJB 2.0
  • 16. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples JPA and EJB 3.0 EntityManager em = factory.createEntityManager(); em.getTransaction().begin(); em.persist(new Event("Conference", new Date()); em.persist(new Event("After Party", new Date()); List result = em.createQuery("from Event").getResultList(); for (Event event : (List<Event>) result) { System.out.println("Event : " + event.getTitle()); } em.getTransaction().commit(); em.close();
  • 17. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples EJB 3.0 – the naked truth @Entity @Table(name = "EVENTS") public class Event { private Long id; private String title; private Date date; @Id @GeneratedValue(generator = "increment") @GenericGenerator(name = "increment", strategy = "increment") public Long getId() { /* … */ } @Temporal(TemporalType.TIMESTAMP) @Column(name = "EVENT_DATE") public Date getDate() { /* … */ }
  • 18. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples EJB 3.0 – Yep, annotations! @OneToMany(mappedBy = "destCustomerId") @ManyToMany @Fetch(FetchMode.SUBSELECT) @JoinTable( name = "customer_dealer_map", joinColumns = { @JoinColumn(name = "customer_id", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "dealer_id", referencedColumnName = "id") } ) private Collection dealers; Found at http://stackoverflow.com/q/17491912/521799
  • 19. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples JPA 3.0 Preview – Annotatiomania™ @SeveralAndThenNothing @MaybeThisDoesSomething @TweakThisWithThat( tweak = { @TweakID(name = "id", preferredValue = 1839), @TweakID(name = "test", preferredValue = 839), @TweakID(name = "test.old", preferredValue = 34), }, inCaseOf = { @ConditionalXMLFiltering(run = 5), } ) @OneToMany @OneToManyMore @AnyOne @AnyBody @DoesThisEvenMeanAnything @DoesAnyoneEvenReadThis @ManyToMany @Many @AnnotationsTotallyRock @DeclarativeProgrammingRules @NoMoreExplicitAlgorithms @Fetch @FetchMany @FetchWithDiscriminator(name = "no_name") @JoinTable(joinColumns = { @JoinColumn(name = "customer_id", referencedColumnName = "id") }) @PrefetchJoinWithDiscriminator @JustTrollingYouKnow @LOL @IfJoiningAvoidHashJoins @ButUseHashJoinsWhenMoreThan(records = 1000) @XmlDataTransformable @SpringPrefechAdapter private Collection employees; Might not be true
  • 20. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples JPA 4.0 Preview var employees;
  • 21. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples More information here www.annotatiomania.com
  • 22. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples What’s next?
  • 23. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples What JPA means for developers… Images from Wikimedia. License: public domain. High voltage power lines by Simon Koopmann. License: CC-BY SA 3.0 With JPA, your developers use a huge framework with lots of complexity that can get hard to manage
  • 24. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples … when developers actually wanted this Java SQL one jack one plug
  • 25. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples Note, we’re talking about SQL. Not Persistence…
  • 26. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples Note, we’re talking about SQL. Not Persistence… FYI: Gavin King: Creator of Hibernate!
  • 27. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples NoSQL? … … so, should we maybe abandon SQL?
  • 28. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples NoSQL? Who said it? Our service ran at 99.99 percent uptime in the first quarter of 2009, runs more than 200 million transactions a day, and has subsecond response time; and we are constantly making advances to deliver it even faster.
  • 29. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples NoSQL? Marc Benioff – salesforce.com Our service ran at 99.99 percent uptime in the first quarter of 2009, runs more than 200 million transactions a day, and has subsecond response time; and we are constantly making advances to deliver it even faster.
  • 30. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples NoSQL? Marc Benioff – salesforce.com He’s talking about salesforce.com’s Oracle database. He “invented” the cloud
  • 31. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples NoSQL? Who said it? • 300 TB of data files for production DBs in total • LHC logging database ~140TB, expected growth up to ~70 TB / year • 13 Production experiments' database ~120 TB in total
  • 32. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples NoSQL? Collecting LHC data with Oracle Exadata • 300 TB of data files for production DBs in total • LHC logging database ~140TB, expected growth up to ~70 TB / year • 13 Production experiments' database ~120 TB in total
  • 33. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples NoSQL for Big Data? - You’re giving up on ACID - You’re giving up on type safety - You’re giving up on standards - You’re giving up on tooling - You’re giving up on relational algebra - You haven’t asked operations - You don’t actually have «Big Data»
  • 34. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples NoSQL for Big Data? - You’re giving up on ACID - You’re giving up on type safety - You’re giving up on standards - You’re giving up on tooling - You’re giving up on relational algebra - You haven’t asked operations - You don’t actually have «Big Data»
  • 35. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples Seen at the O’Reilly Strata Conf: History of NoSQL by Mark Madsen. Picture published by Edd Dumbill NoSQL? No, SQL!
  • 36. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples NoSQL? No, SQL! So, let’s talk about SQL
  • 37. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples Let’s calculate a running total | ID | VALUE_DATE | AMOUNT | |------|------------|--------| | 9997 | 2014-03-18 | 99.17 | | 9981 | 2014-03-16 | 71.44 | | 9979 | 2014-03-16 | -94.60 | | 9977 | 2014-03-16 | -6.96 | | 9971 | 2014-03-15 | -65.95 |
  • 38. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples Let’s calculate a running total | ID | VALUE_DATE | AMOUNT | BALANCE | |------|------------|--------|------------| | 9997 | 2014-03-18 | 99.17 | 19985.81 | | 9981 | 2014-03-16 | 71.44 | 19886.64 | | 9979 | 2014-03-16 | -94.60 | 19815.20 | | 9977 | 2014-03-16 | -6.96 | 19909.80 | | 9971 | 2014-03-15 | -65.95 | 19916.76 |
  • 39. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples Let’s calculate a running total | ID | VALUE_DATE | AMOUNT | BALANCE | |------|------------|--------|------------| | 9997 | 2014-03-18 | +99.17 =19985.81 | | 9981 | 2014-03-16 | 71.44 | +19886.64 | | 9979 | 2014-03-16 | -94.60 | 19815.20 | | 9977 | 2014-03-16 | -6.96 | 19909.80 | | 9971 | 2014-03-15 | -65.95 | 19916.76 |
  • 40. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples Let’s calculate a running total | ID | VALUE_DATE | AMOUNT | BALANCE | |------|------------|--------|------------| | 9997 | 2014-03-18 | 99.17 | 19985.81 | | 9981 | 2014-03-16 | +71.44 =19886.64 | | 9979 | 2014-03-16 | -94.60 | +19815.20 | | 9977 | 2014-03-16 | -6.96 | 19909.80 | | 9971 | 2014-03-15 | -65.95 | 19916.76 |
  • 41. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples Let’s calculate a running total | ID | VALUE_DATE | AMOUNT | BALANCE | |------|------------|--------|------------| | 9997 | 2014-03-18 | 99.17 | 19985.81 | | 9981 | 2014-03-16 | +71.44 =19886.64 | n | 9979 | 2014-03-16 | -94.60 | +19815.20 | n+1 | 9977 | 2014-03-16 | -6.96 | 19909.80 | | 9971 | 2014-03-15 | -65.95 | 19916.76 |BALANCE(ROWn) = BALANCE(ROWn+1) + AMOUNT(ROWn) BALANCE(ROWn+1) = BALANCE(ROWn) – AMOUNT(ROWn)
  • 42. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 SELECT t.*, t.current_balance - NVL( SUM(t.amount) OVER ( PARTITION BY t.account_id ORDER BY t.value_date DESC, t.id DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING ), 0) AS balance FROM v_transactions t WHERE t.account_id = 1 ORDER BY t.value_date DESC, t.id DESC
  • 43. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 SUM(t.amount) OVER ( PARTITION BY t.account_id ORDER BY t.value_date DESC, t.id DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING )
  • 44. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 SUM(t.amount) OVER ( PARTITION BY t.account_id ORDER BY t.value_date DESC, t.id DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING )
  • 45. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 SUM(t.amount) OVER ( PARTITION BY t.account_id ORDER BY t.value_date DESC, t.id DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING )
  • 46. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 SUM(t.amount) OVER ( PARTITION BY t.account_id ORDER BY t.value_date DESC, t.id DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING )
  • 47. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 SUM(t.amount) OVER ( PARTITION BY t.account_id ORDER BY t.value_date DESC, t.id DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING )
  • 48. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples | ID | VALUE_DATE | AMOUNT | BALANCE | |------|------------|--------|------------| | 9997 | 2014-03-18 -(99.17)| +19985.81 | | 9981 | 2014-03-16 -(71.44)| 19886.64 | | 9979 | 2014-03-16 -(-94.60)| 19815.20 | | 9977 | 2014-03-16 | -6.96 | =19909.80 | | 9971 | 2014-03-15 | -65.95 | 19916.76 |
  • 49. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples Don’t you think that’s beautiful? Stockholm Syndrome: We love COBOL SQL
  • 50. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples Winston Churchill SQL is the worst form of database querying, except for all the other forms.
  • 51. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples More SQL Calculations | TEXT | VOTES | RANK | PERCENT | |-------------|-------|------------|---------| | jOOQ | 1383 | 1 | 32 % | | Hibernate | 1029 | 2 | 23 % | | EclipseLink | 881 | 3 | 20 % | | JDBC | 533 | 4 | 12 % | | Spring JDBC | 451 | 5 | 10 % | Data may not be accurate…
  • 52. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples More SQL Calculations SELECT p.text, p.votes, DENSE_RANK() OVER (ORDER BY p.votes DESC) AS "rank", LPAD( (p.votes * 100 / SUM(p.votes) OVER ()) || ' %', 4, ' ' ) AS "percent" FROM poll_options p WHERE p.poll_id = 12 ORDER BY p.votes DESC
  • 53. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples The same with jOOQ select (p.TEXT, p.VOTES, denseRank().over().orderBy(p.VOTES.desc()).as("rank"), lpad( p.VOTES.mul(100).div(sum(p.VOTES).over()).concat(" %"), 4, " " ).as("percent")) .from (POLL_OPTIONS.as("p")) .where (p.POLL_ID.eq(12)) .orderBy(p.VOTES.desc());
  • 54. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples The same with jOOQ in Scala (!) select (p.TEXT, p.VOTES, denseRank() over() orderBy(p.VOTES desc) as "rank", lpad( (p.VOTES * 100) / (sum(p.VOTES) over()) || " %", 4, " " ) as "percent") from (POLL_OPTIONS as "p") where (p.POLL_ID === 12) orderBy (p.VOTES desc)
  • 55. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples What jOOQ means for developers Java SQL one jack all plugs jOOQ one adaptor With jOOQ, Java plugs into SQL intuitively, letting your developers focus on business-logic again. Images from Wikimedia. License: public domain. Travel converter by Cephira. License: CC-BY SA 3.0
  • 56. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples What jOOQ means for developers Java SQL one jack all plugs jOOQ one adaptor Images from Wikimedia. License: public domain. Travel converter by Cephira. License: CC-BY SA 3.0
  • 57. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples Examples
  • 58. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples Marc Benioff from salesforce All companies benefit when they can afford to focus on innovation rather than infrastructure
  • 59. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples A vision of a better SQL application - Database first - Performance - Type safe JDBC - Code Generation - Active Records - Stored Procedures - SQL Transformation - SQL Standardisation
  • 60. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples «jOOQ» 10% discount code And a shameless book recommendation Markus Winand from Use-The-Index-Luke.com ROI north of 83’174% Achieve proper indexing and performance in popular RDBMS
  • 61. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples And a shameless tool recommendation Open source databases: - Free / Apache license Commercial databases: - Commercial license
  • 62. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0 Intro SQL and Java jOOQ Examples That’s it folks More free Java / SQL knowledge on: • Blog: http://blog.jooq.org • Twitter: @JavaOOQ / @lukaseder • Newsletter: http://www.jooq.org