You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/**
* Base class for implementations of {@link EntityInformation}. Considers an entity to be new whenever
* {@link #getId(Object)} returns {@literal null}.
However, the implementation of the isNew(T entity) method also considers the object new if the object's id is set to 0:
public boolean isNew(T entity) {
ID id = getId(entity);
Class<ID> idType = getIdType();
if (!idType.isPrimitive()) {
return id == null;
}
if (id instanceof Number) {
return ((Number) id).longValue() == 0L;
}
throw new IllegalArgumentException(String.format("Unsupported primitive id type %s!", idType));
}
This has surfaced as a problem with a project I'm working on because the project's design relied upon 0 being considered a valid ID.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
The javadoc for the class reads as such:
However, the implementation of the
isNew(T entity)
method also considers the object new if the object's id is set to 0:This has surfaced as a problem with a project I'm working on because the project's design relied upon 0 being considered a valid ID.
The text was updated successfully, but these errors were encountered: