When adding/removing entities to/from a collection in Hibernate one may easily run into annoying
TransientObjectException or TransientPropertyValueException exceptions.
This blog uses a simple example to describes how to avoid these issues.
Continue reading →
A common practice with Hibernate is to give each entity an id field to store its primary key.
This field is generally managed by Hibernate.
When the entity has not been saved yet, the field is null, which is also how Hibernate detects the object has not been saved yet.
Once it is saved, Hibernate sets the value of the id to the generated value.
Since the value of the id field changes, it is not suited to base your equals and hashCode methods on.
Which is a bit counter-intuitive, because it corresponds to the primary key in the database.
The solution is to use Business Keys.
Continue reading →
How to represent datetimes in APIs, the code, and the database is always tricky. Most people I have worked with struggled with this.
The main mistake is omitting the time zone based on the false assumption that defaults are uniform across systems. They are not.
As a result timestamps carried across systems get weird time jumps.
This blog gives some rules to avoid these mistakes and gives a clean set up.
Continue reading →
Discover how to build your own, offline "LocalStack" for Google APIs using WireMock
and TestContainers. In this post, I will show you how to set up a two-purpose
mocking strategy. By writing your JSON mock responses just once, you can reuse them
to power automated integration tests and spin up a standalone mock server for
local (UI) development. No more production data and sharing of google keys between
developers, no more 403 User Rate Limit Exceeded.
Continue reading →
Over the past few weeks, I’ve been on a rewarding journey.
As a Managing Director who is no longer a full-time software developer,
finding the time to code and keep up with the relentless pace of new
technologies is a real challenge. While my colleagues are experimenting
with the latest frameworks and tools daily, I know I’m not alone in
feeling that the tech landscape evolves faster than the hours in a
day allow — or faster than what client projects typically permit you
to explore.
That’s why I cherish internal projects. Earlier this year I posted about
Posting
our blog feed to social networks using Slack. And recently I set out
to build a couple of internal tools for our Google Workspace
environments, but I decided to try something different than what
maybe most developers would do.
Instead of relying solely on traditional documentation or enabling
an autopilot AI assistant directly inside my IDE or terminal
(like a Claude Code subscription), I used the standard Google
Gemini web client. It comes included with our company’s Google
Workspace account — proving that you don’t need expensive
premium subscriptions or complex local LLMs to get value.
Continue reading →
Sometimes when you upgrade your application the new version does not work correctly, and you need to downgrade. When you are unlucky you did some changes in your
database that cannot be undone. In that case you need to restore the database from a backup, which is usually quite cumbersome and time-consuming.
How nice would it be if you could just run an undo script which is much more light weight. This blog describes how you can do that using Flyway.
Continue reading →
AsciiDoc and UML are two well known technologies for software design.
A very nice way of creating beautiful PDF documents is to combine both by embedding PlantUML in your AsciiDoc.
Generating the PDF can be a bit cumbersome, but with the following Maven setup it is quick and easy.
Continue reading →
Some people think GUIs have replaced the command-line. But they have not, they are complementary.
Some things can still be done better and easier in the command-line, for example scripting, and to servers one usually has access via an SSH terminal only.
But there is more!
This blog will describe a few very convenient commands for software developers.
All of it works in the Bash shell (common on Linux), but most of it works in the Z shell (zsh) as well (common on Mac).
Continue reading →
The ultimate way to get rid of versioning administration is to use CI/CD (Continuous Integration/Continuous Deployment).
However, in many cases CD is not possible. For example when creating libraries, or software requiring versions for compliance reasons.
Versioning is then still needed. This should be easy, but it turns out that without a proper procedure it can become very messy very fast.
This blog will describe a simple set up of such a procedure based on trunk-based development
and Semantic Versioning.
Continue reading →
Flyway is convenient tool to manage your database changes.
You can use it to create and populate your database from scratch, or to manage changes on a pre-existing database.
You can add it to your application so that when it starts up it invokes Flyway, or you can use the command-line version.
This blog describes a convenient way of using the Flyway command-line version.
Continue reading →
In production the log level should be INFO. However, in many cases it is set to DEBUG because otherwise critical message are missed.
This is unfortunate, because it usually leads to a lot of log file pollution.
And it should not have been needed, had the developers followed the following rules.
Continue reading →
Hibernate is a great Object Relational Mapping (ORM) library for accessing data in a relational database.
It is one of the leading implementations of Java Persistence (formerly known as JPA).
Using JPQL (based on HQL,
which is still a nice syntax guide) one can access and update the data in the database through your ORM objects in a simplified SQL way.
However, when implemented incorrectly one can run into serious performance problems.
They can all be avoided though.
Here are some important things to consider to make your queries performant.
Continue reading →