Tweet of the Day
Our customers, users, and followers are sharing their love for jOOQ to the world. Here are:
Thanks for the shouts, guys! It looks our attempts to make our users competent and enthusiast SQL aficionados are effective. If you, our customers, are productive with Java and SQL, then we did our job right. Last but not least:
Want awesome free jOOQ stickers yourself? Contact us!.
Book Promotion - 10% off SQL Performance Explained
This book is a must-read for every SQL developer! Invest a very reasonable amount of money and around six hours of quality reading time, and you'll stop wasting days and days of confused SQL tuning guesswork, because once you understand indexes, you are able to solve 90% of your performance issues.
Get your copy of SQL Performance Explained now! Use the limited-time "jOOQ" coupon to get a 10% partner discount:
Community Zone - The jOOQ aficionados have been active!
In last week's newsletter, we've praised Petri Kainulainen's latest piece of work, his jOOQ / Spring / CRUD tutorial:
But that was not his last shout. He's already promised another tutorial explaining how to do sorting and pagination with jOOQ:
Luckily for us Markus Winand - our SQL Performance Partner jumped in and reminded us of the difference between OFFSET pagination and KEYSET pagination. More details about these tools in his book - see above.
Michael Hughes from codinginthetrenches.com has also been discovering the benefits of using a SQL DSL, which he has explained in his article here. We always like it when jOOQ users realise the power of using jOOQ with stored procedures. You will be indefinitely more efficient compared to the standards JDBC or JPA.
Krisztian Horvath from SequenceIQ has published a post about using jOOQ with HBase - why not? If you're restricting yourself to using plain SQL, you can use the jOOQ Open Source Edition with a lot of databases, although you're going to be missing out on the coolest features and productivity boosters, of course.
Harmeet Singh appreciates the jOOQ code generator in his introductory blog post, an important point to mention. jOOQ's code generator has helped our customers avoid so many errors already at compile-time, instead of waiting for them to appear in production, at runtime.
SQL Zone - When to use views
There are a couple of great reasons why you should occasionally (or systematically) use views instead of tables. These reasons include:
See the relevant Stack Overflow question here.
- Views provide abstraction over tables. You can add/remove fields easily in a view without modifying your underlying schema.
- Views can model complex joins easily.
- Views can hide database-specific stuff from you, e.g. using Oracle's SYS_CONTEXT for security checks.
- Views can be useful for managing GRANTS, and thus hiding tables from you.
- Views can help you with backwards compatibility when you change the underlying schema, but leave the (versioned) views in place.
- Views can implement an additional security layer, e.g. by using Oracle's WITH CHECK OPTION directly in the view.
SQL Zone - Calculating a running total
We've said it before. Use your database for your calculations, when this is reasonable. And by this, we don't just mean simple COUNT(*) or SUM(AMOUNT) calls. We cannot stress the fact that you should be using window functions enough.
Imagine you want to do something fancy like calculating a balance value on every bank transaction based on the current balance and each transaction's amount:
| 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 |
You can do this in SQL! Check out our recent blog post about how to calculate a SQL standard running total directly in SQL!
The next weeks are a bit quiet, but we're going to be active again in May and June! Have you missed any of our previous jOOQ talks? Soon you'll get another chance to hear us talk about jOOQ or SQL in general in any of these upcoming events:
Stay informed about 2014 events on www.jooq.org/news.