So the problem was that I was using spring-boot-devtools which has a restart function. The restart class loader couldn't find the classes.
I got the hint when I tried to make a temporary workaround to cast the content of the Tuple to the correct type.
private <T> T getObject(Tuple tuple, T c) {
return (T) tuple.get(0);
}
Then I used it like this
var customer = session.createQuery("FROM Customer", Tuple.class).getSingleResultOrNull();
return getObject(customer, new Customer());
Which threw a class loader exception which then led me to the following post with the solution.
Class loader error - unnamed module of loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader
Disabling the restart function didn't work for me so I simply removed devtools from Maven.