%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
The Awesome jOOQ JavaOne Talk
1. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0GetBack in ControlofyourSQLSQL andJava couldworktogetherso muchbetterifweonlyletthem.
2. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0IntroSQL andJava jOOQ ExamplesMe –@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.0IntroSQL andJava jOOQ ExamplesLegal Disclaimer
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.0Intro SQL andJava jOOQ ExamplesSQL andJava –in theory
Java
SQL
In thismetaphor, electricityisthedata(SQL) thatflowsintoyourappliance/ application(Java)
onejack
oneplug
5. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesSQL andJava –in practice
Java
SQL
Images from: http://en.wikipedia.org/wiki/AC_power_plugs_and_sockets.License: public domain
onejack
lots ofplugs
6. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesJDBC
PreparedStatementstmt= connection.prepareStatement(
"SELECT textFROM productsWHERE cust_id= ? AND value< ?");
stmt.setInt(1, custID);
stmt.setBigDecimal(2, BigDecimal.ZERO);
ResultSetrs= stmt.executeQuery();
while(rs.next()) {
System.out.println(rs.getString("TEXT"));
}
7. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesJDBC –thenakedtruth
01: PreparedStatementstmt= connection.prepareStatement(
02:"SELECT p.texttxt" +
03:(isAccount? ", NVL(a.type, ?) " :"") +
04:"FROM productsp " +
05:(isAccount? " INNER JOIN accountsa USING (prod_id) ": "") +
06:" WHERE p.cust_id= ? AND p.value< ?"+
07:(isAccount? "AND a.typeLIKE '%"+ type + "%'": "");
08: stmt.setInt(1, defaultType);
09: stmt.setInt(2, custID);
10: stmt.setBigDecimal(3, BigDecimal.ZERO);
11: ResultSetrs= stmt.executeQuery();
12:
13: while(rs.next()) {
14:Clobclob= rs.getClob("TEXT");
15:System.out.println(clob.getSubString(1, (int) clob.length());
16: }
17:
18: rs.close();
19: stmt.close();
9. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesWhatJDBC meansfordevelopers
Images fromFlickr. Totheleftby: Matthew Straubmuller, Greg Grossmeier. License:CC BY SA 2.0. Electric Engineers to the right copyright by Marco Sarli, all rights reserved.
WithJDBC, yourdevelopershavetodo a lotofmanual, error-prone(dangerous) andinefficientwork
10. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesEJB 2.0 EntityBeans
publicinterfaceCustomerRequestextendsEJBObject{
BigIntegergetId();
String getText();
voidsetText(String text);
@Override
voidremove();
}
publicinterfaceCustomerRequestHomeextendsEJBHome{
CustomerRequestcreate(BigIntegerid);
CustomerRequestfind(BigIntegerid);
}
11. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesEJB 2.0 –thenakedtruth
<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>
12. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesEJB 2.0 –thenakedtruth
<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
13. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesEJB 2.0
14. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesJPA andEJB 3.0
EntityManagerem= factory.createEntityManager();
em.getTransaction().begin();
em.persist(newEvent("Conference", newDate());
em.persist(newEvent("After Party", newDate());
List result= em.createQuery("fromEvent").getResultList();
for(Event event: (List<Event>) result) {
System.out.println("Event : "+ event.getTitle());
}
em.getTransaction().commit();
em.close();
15. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesEJB 3.0 –thenakedtruth
@Entity @Table(name = "EVENTS")
public classEvent {
privateLong id;
privateString title;
privateDate date;
@Id @GeneratedValue(generator = "increment")
@GenericGenerator(name = "increment", strategy = "increment")
publicLong getId() { /* … */ }
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "EVENT_DATE")
publicDate getDate() { /* … */ }
16. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesEJB 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")
}
)
privateCollection dealers;
Found at http://stackoverflow.com/q/17491912/521799
17. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesJPA 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
privateCollection employees;
Might not be true
18. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesWhat’s next?
19. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesWhatJPA meansfordevelopers…
Images fromWikimedia. License: publicdomain. High voltagepower linesbySimon Koopmann. License: CC-BY SA 3.0
WithJPA, yourdevelopersusea hugeframeworkwithlots ofcomplexitythatcangethardtomanage
20. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ Examples… whendevelopersactuallywantedthis
Java
SQL
onejack
oneplug
21. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesNote, we’retalkingaboutSQL. Not Persistence…
22. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesNote, we’retalkingaboutSQL. Not Persistence…
FYI: Gavin King: CreatorofHibernate!
23. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesNoSQL?
…
… so, shouldwemaybeabandonSQL?
24. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesNoSQL? 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 subsecondresponse time; and we are constantly making advances to deliver it even faster.
25. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesNoSQL? 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 subsecondresponse time; and we are constantly making advances to deliver it even faster.
26. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesNoSQL? Marc Benioff–salesforce.com
He’s talking about salesforce.com’sOracle database.
He “invented” the cloud
27. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesNoSQL? 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
28. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesNoSQL? CERN, collecting LHC data
•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
29. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesNoSQLfor Big Data?
-You’re giving up on ACID
-You’re giving up on type safety
-You’regivingupon standards
-You’regivingupon tooling
-You’regivingupon relational algebra
-Youhaven’taskedoperations
-Youdon’tactuallyhave«Big Data»
30. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesNoSQLfor Big Data?
-You’re giving up on ACID
-You’re giving up on type safety
-You’regivingupon standards
-You’regivingupon tooling
-You’regivingupon relational algebra
-Youhaven’taskedoperations
-Youdon’tactuallyhave«Big Data»
31. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ Examples
Seen at the O’Reilly Strata Conf:
History of NoSQLbyMark Madsen. Picture published byEddDumbillNoSQL? No, SQL!
32. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamplesLet’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 |
33. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamplesLet’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 |
34. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamplesLet’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 |
35. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamplesLet’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 |
36. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamplesLet’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)
37. 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(
PARTITIONBYt.account_id
ORDERBYt.value_dateDESC,
t.id DESC
ROWSBETWEENUNBOUNDEDPRECEDING
AND1 PRECEDING
),
0) ASbalance
FROM v_transactionst
WHERE t.account_id= 1
ORDERBY t.value_dateDESC,
t.id DESC
38. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
SUM(t.amount) OVER(
PARTITIONBYt.account_id
ORDERBYt.value_dateDESC,
t.id DESC
ROWSBETWEENUNBOUNDEDPRECEDING
AND1 PRECEDING
)
39. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
SUM(t.amount) OVER(
PARTITIONBYt.account_id
ORDERBYt.value_dateDESC,
t.id DESC
ROWSBETWEENUNBOUNDEDPRECEDING
AND1 PRECEDING
)
40. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
SUM(t.amount) OVER(
PARTITIONBYt.account_id
ORDERBYt.value_dateDESC,
t.id DESC
ROWSBETWEENUNBOUNDEDPRECEDING
AND1 PRECEDING
)
41. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
SUM(t.amount) OVER(
PARTITIONBYt.account_id
ORDERBYt.value_dateDESC,
t.id DESC
ROWSBETWEENUNBOUNDEDPRECEDING
AND1 PRECEDING
)
42. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0
SUM(t.amount) OVER(
PARTITIONBYt.account_id
ORDERBYt.value_dateDESC,
t.id DESC
ROWSBETWEENUNBOUNDEDPRECEDING
AND1 PRECEDING
)
43. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava 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 |
44. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamplesDon’t you think that’s beautiful?
Stockholm Syndrome:
WeloveCOBOLSQL
45. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamplesWinston Churchill
SQL is the worst form of database querying, except for all the other forms.
46. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamplesMore SQL Calculations
| TEXT | VOTES |RANK | PERCENT |
|-------------|-------|------------|---------|
| Hibernate | 1383 |1 | 32 % |
| jOOQ | 1029 |2 | 23 % |
| EclipseLink| 881 |3 | 20 % |
| JDBC | 533 |4 | 12 % |
| Spring JDBC | 451 |5 | 10 % |
Data may not be accurate…
47. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamplesMore SQL Calculations
SELECT p.text,
p.votes,
DENSE_RANK()OVER (ORDER BY p.votesDESC)AS "rank",
LPAD(
(p.votes* 100 /SUM(p.votes)OVER ())||' %',
4, ' '
)AS "percent"
FROM poll_optionsp
WHERE p.poll_id= 12
ORDER BY p.votesDESC
48. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamplesThe same withjOOQ
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());
49. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamplesThe same withjOOQ in Scala (!)
select (p.TEXT,
p.VOTES,
denseRank() over() orderBy(p.VOTESdesc) 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.VOTESdesc)
50. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamplesWhatjOOQmeansfordevelopers
Java
SQL
onejack
all plugs
jOOQ
oneadaptor
WithjOOQ, Java plugsintoSQL intuitively, lettingyourdevelopersfocuson business-logicagain.
Images fromWikimedia. License: publicdomain. Travel converterbyCephira. License: CC-BY SA 3.0
51. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamplesJust to be sure you get the message
jOOQis the best way to write SQL in Java
52. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQ ExamplesExamples
53. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamples
Who saidit?
All companiesbenefitwhentheycanaffordtofocuson innovationratherthaninfrastructure
54. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamples
Marc Benioff:
All companiesbenefitwhentheycanaffordtofocuson innovationratherthaninfrastructure
55. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamples
«jOOQ» 10% discountcodeAnd a shameless book recommendation
Markus Winand fromUse-The-Index-Luke.com
ROI north of 83’174%
Achieve proper indexing and performance in popular RDBMS
56. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamplesAnd a shameless tool recommendation
Open source databases:
-Free / Apache license
Commercial databases:
-Commercial license
57. Copyright (c) 2009-2014 by Data Geekery GmbH. Slides licensed under CC BY SA 3.0Intro SQL andJava jOOQExamples
That’s it folks
More freeJava / SQL knowledgeon:
•Blog: http://blog.jooq.org
•Twitter: @JavaOOQ/ @lukaseder
•Newsletter: http://www.jooq.org