MyBatis’ Wicked Statement Builders

Now here's one of the most wicked API's I've seen in a while! MyBatis is well-known as a database abstraction framework on top of JDBC, allowing for externalising SQL into files, loading them at appropriate places in your Java code. For those of you who like this approach, you may be used to statements similar … Continue reading MyBatis’ Wicked Statement Builders

FOR UPDATE simulation in SQL Server and CUBRID

Pessimistic locking is useful every now and then when you explicitly want to lock a given set of rows for a subsequent UPDATE, or for database-based inter-process synchronisation and locking. Normally, you would use the SQL Standard FOR UPDATE clause, which is supported in most databases. A SQL standard example -- This statement will produce … Continue reading FOR UPDATE simulation in SQL Server and CUBRID

OneWebSQL™: Another competitor in the SQL schema generation “business”

I've been observing OneWebSQL™ for a year now, impatiently expecting its first public version and official go-live. I first discovered it during my regular jOOQ marketing work. I'm always closely observing competition for several reasons: It shows that the market is alive and active, which helps making jOOQ even more relevant jOOQ can incorporate the … Continue reading OneWebSQL™: Another competitor in the SQL schema generation “business”

Simulation of TRUNC() in Derby

Derby is missing out a lot of functions from the set of functions that other databases usually provide. One example is the TRUNC(value, decimals) function. According to the Wikipedia, truncation can be achieved as such: -- trunc(x, n) CASE WHEN x > 0 THEN floor(power(10, n) * x) / power(10, n) ELSE ceil(power(10, n) * … Continue reading Simulation of TRUNC() in Derby

How to simulate MySQL’s INSERT statement extensions

I have previously posted about the SQL MERGE statement, and how powerful it is here: https://blog.jooq.org/arcane-magic-with-the-sql2003-merge-statement/ Unfortunately, not all databases support this statement. Also, very often it is quite a bit of overkill, when what you want to do is to simply INSERT or UPDATE a single record, depending on whether it already exists. MySQL's … Continue reading How to simulate MySQL’s INSERT statement extensions