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 →
Arguably the most popular version control system is Git. Many developers use the command-line version alongside
a Git plugin in their favorite IDE. Now those work just fine, but did you know there is also a very nice
TUI (Text-based User Interface, alternately Terminal User Interface) for Git called Lazygit.
It is a very cool tool. Read on for more information.
Continue reading →
This blog briefly describes theoretically how Public Key Infrastructure (PKI) works.
It also introduces the key concepts used in PKI.
This is done by describing encryption, decryption, hashing, signing, and authentication using mathematical notations.
Continue reading →
The purpose of Open Authorization 2.0 (OAuth 2.0) is to give an application (the "Client") limited access to your data at
another service (the "Resource Server"), without having to give your password to that application. When OIDC is added
Single Sign-On (SSO) is supported as well. The flow of these protocols can nicely be shown in a UML Sequence Diagram.
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 →
Did you know that you can include LaTeX snippets in Markdown and AsciiDoc documents?
For writing a scientific or technical document pure LaTeX is still the best choice.
But if you want to write a Markdown or AsciiDoc document that needs to contain some math snippets, you can.
Here is how.
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 →