Root<User> u = criteria.from(User.class);
criteria.multiselect(
u.get("username"),
cb.selectCase()
.when(
cb.equal(
cb.length(u.get("homeAddress").<String>get("zipcode")), 5
), "Germany"
)
.when(
cb.equal(
cb.length(u.get("homeAddress").<String>get("zipcode")), 4
), "Switzerland"
)
.otherwise("Other")
);