Serguey Asael Shinder: Objects.hash of one field is not that field's hashCode, and the javadoc says so
Objects.hash is the convenient way to write a hashCode() over several fields, and its javadoc gives exactly that example: return Objects.hash(x, y, z);. The trap is the one-field case, and the same javadoc carries a warning about it that is easy to scroll past:
Warning: When a single object reference is supplied, the returned value does not equal the hash code of that object reference. This value can be computed by calling hashCode(Object).
The reason is in the first sentence of the method's description. Objects.hash(Object... values) is varargs, and the hash code "is generated as if all the input values were placed into an array, and that array were hashed by calling Arrays.hashCode(Object[])". Arrays.hashCode is defined to return the same value as Arrays.asList(a).hashCode(), and List.hashCode() is specified as:
int hashCode = 1;
for (E e : list)
hashCode = 31*hashCode + (e==null ? 0 : e.hashCode());

So for a single non-null argument the loop runs once and the result is 31 + x.hashCode():
String id = "order-42";
Objects.hash(id) == id.hashCode(); // false
Objects.hash(id) == 31 + id.hashCode(); // true
Objects.hashCode(id) == id.hashCode(); // true
Usually nobody notices, because nothing compares the two numbers. It matters when something does: a wrapper type whose hashCode() is documented as "the hash of the wrapped id" so it can be looked up alongside the raw id, a test that asserts wrapper.hashCode() == id.hashCode(), or a cache key computed once from the field and once from the object. The two sides then disagree by exactly 31 — never by chance, every time.
The fix is the method the warning names. For one field, write Objects.hashCode(id), which returns id.hashCode() for a non-null argument and 0 for null. Keep Objects.hash for two or more fields, where there is no "the field's hash" to match. There is also a small cost difference: Objects.hash is varargs, so each call builds an array, while Objects.hashCode does not — irrelevant in most code, measurable in a hot HashMap key.
Source: java.util.Objects javadoc, Java SE 25 — https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/Objects.html , with List.hashCode() at https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/List.html .