Home » Archives for Vlad Mihalcea

Author Archives: Vlad Mihalcea

Vlad Mihalcea is a software architect passionate about software integration, high scalability and concurrency challenges.

How to map PostgreSQL Enums to JPA entity properties using Hibernate

Introduction The open-source hibernate-types project allows you to map JSON, ARRAY, YearMonth, Month or database-specific columns (e.g. INET addresses). In this article, we are going to see how you can map a PostgreSQL Enum type to a Java array when using JPA and Hibernate. Maven dependency First of all, you need to set up the following Maven dependency in your ...

Read More »

A beginner’s guide to read and write skew phenomena

Introduction In my article about ACID and database transactions, I introduced the three phenomena described by the SQL standard: dirty read non-repeatable read phantom read While these are good to differentiate the four isolation levels (Read Uncommitted, Read Committed, Repeatable Read and Serializable), in reality, there are more phenomena to take into consideration as well. The 1995 paper (A Critique ...

Read More »

How does the MySQL JDBC driver handle prepared statements

Prepared statement types While researching for the Statement Caching chapter in my High-Performance Java Persistence book, I got the chance to compare how Oracle, SQL Server, PostgreSQL and MySQL handle prepare statements. Thanks to Jess Balint (MySQL JDBC driver contributor), who gave a wonderful answer on StackOverflow, I managed to get a better understanding of how MySQL handles prepared statements ...

Read More »

A paranoid’s guide to backing up a working folder

Oops time Leanpub supports multiple storage engines and a private GitHub repository is probably the safest way to the backing up your working folder. I chose Dropbox as I didn’t envision anything wrong with the automatic synchronization mechanism. While working on my book, I accidentally managed to wipe-out half of my diagrams and all changes were instantly synchronized by Dropbox. ...

Read More »

How does FlexyPool support both Connection proxies and decorators

java-interview-questions-answers

Proxies FlexyPool monitors connection pool usage and so it needs to intercept the connection close method call. For simplicity sake, the first version was relying on dynamic proxies for this purpose: private static class ConnectionInvocationHandler implements InvocationHandler { public static final String CLOSE_METHOD_NAME = "close"; private final Connection target; private final ConnectionCallback callback; public ConnectionInvocationHandler( Connection target, ConnectionCallback callback) { ...

Read More »

Why you should always use connection pooling with Oracle XE

java-interview-questions-answers

Introduction Oracle Express Edition is the free version of Oracle Enterprise Edition and its smaller size makes it very convenient for testing various Oracle functionalities. According to Oracle documentation, the Express Edition can use at most one CPU and 1 GB of RAM, but in reality there are other limitations that are not always obvious. Database connection handling anomaly The ...

Read More »

How does FlexyPool support the Dropwizard Metrics package renaming

java-interview-questions-answers

Introduction FlexyPool relies heavily on Dropwizard (previously Codahale) Metrics for monitoring the connection pool usage. Being integrated into Dropwizard, the package name was bound to be renamed. So instead of com.codahale.metrics the 4.0.0 release will use the io.dropwizard.metrics package name. The challenge Apart from the obvious backward incompatibility, the most challenging aspect of this change is that the Maven dependency ...

Read More »

How to monitor a Java EE DataSource

java-interview-questions-answers

Introduction FlexyPool is an open-source framework that can monitor a DataSource connection usage. This tool come out of necessity, since we previously lacked support for provisioning connection pools. FlexyPool was initially designed for stand-alone environments and the DataSource proxy configuration was done programmatically. Using Spring bean aliases, we could even substitute an already configured DataSource with the FlexyPool Metrics-aware proxy ...

Read More »

How does Hibernate Query Cache work

Introduction Now that I covered both Entity and Collection caching, it’s time to investigate how Query Caching works. The Query Cache is strictly related to Entities and it draws an association between a search criteria and the Entities fulfilling that specific query filter. Like other Hibernate features, the Query Cache is not as trivial as one might think. Entity model ...

Read More »