Spring Data JPA Postgres UUID @Id

I read lots of outdated info on this matter.

Using PostgreSQL v13+ there is a function called gen_random_uuid().
See the manual page of Postgres UUID.

Here’s an example entity called Page

As you see you can append the columnDefinition to the @Column annotation. “UUID default gen_random_uuid()”
This translates to following SQL

And you don’t have to worry about having an empty ID when inserting records.

Easily remember ManyToMany ManyToOne OneToMany

ManyToMany in a Person <> Blog Relationship
A Person can be a subscriber of many blogs.
A Blog can have many subscribers.

But since this is an inefficient way to manage usually a proxy table is used with [PersonID], [BlogID], aka the 2 related data models.

ManyToOne and OneToMany in a Person <> Blog Relationship
A Person can be the owner of many Blogs.
A Blog can have one owner Person.

In conclusion, ToMany means it’s an array, ToOne means it’s a single value.

Vue composition api: ensure variable is not null

I ran into a problem where I was loading data from the backend in App.vue and when loaded that data would be inserted into a vuex store and in another component queried.

However the loading took longer than expected and a data race happened. The route destination rendered faster than the backend could deliver data and it to be stored in the vuex store and returned.

Concretely I loaded a profile of the logged in user with vuex-orm and the axios plugin.
In order to grab the profile data I used

I wanted to update location data of that profile if it was different, which was done with a promise, because that’s how the cordova api works.
But profile was always null. And I tried ref() and reactive() but finally solved it with watch().

So whenever profile changes the location is updated. Of course I have checks to not update if it’s not required.

The initial state of profile is null, then it changes and updateProfile is called with the new value.

Upgrade Keycloak Standalone with Postgres from 16.1.0 to 17.0.0 with custom port behind nginx reverse proxy

What a nightmare.

You’re using keycloak and are upgrading from Wildfly 16.1.0 to Quarkus 17.0.0.
You’re also listening on a non-standard port, that isn’t 8080, but 23232.
You’re using a reverse proxy like nginx for TLS
and Keycloak is connected via plain http with nginx.

Grab your standalone.xml found in /standalone/configuration/standalone.xml
and find your postgres jdbc connection string as well as postgresql username and password.

edit conf/keycloak.conf

With this everything should work as before.

You also have to upgrade your Java version to be at least v11. Keycloak 17 won’t run with v8.