HHH-7861 EntityManager.find() should return null instead of EntityNotFoundException (message improvement)
This commit is contained in:
parent
2f0bd59431
commit
603682937c
|
@ -810,9 +810,11 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
||||||
catch ( EntityNotFoundException ignored ) {
|
catch ( EntityNotFoundException ignored ) {
|
||||||
// DefaultLoadEventListener.returnNarrowedProxy may throw ENFE (see HHH-7861 for details),
|
// DefaultLoadEventListener.returnNarrowedProxy may throw ENFE (see HHH-7861 for details),
|
||||||
// which find() should not throw. Find() should return null if the entity was not found.
|
// which find() should not throw. Find() should return null if the entity was not found.
|
||||||
if ( LOG.isDebugEnabled() ) {
|
if ( LOG.isDebugEnabled() ) {
|
||||||
LOG.ignoringEntityNotFound( entityClass != null ? entityClass.getName(): null, ignored );
|
String entityName = entityClass != null ? entityClass.getName(): null;
|
||||||
}
|
String identifierValue = primaryKey != null ? primaryKey.toString() : null ;
|
||||||
|
LOG.ignoringEntityNotFound( entityName, identifierValue );
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch ( ObjectDeletedException e ) {
|
catch ( ObjectDeletedException e ) {
|
||||||
|
|
|
@ -38,8 +38,6 @@ import static org.jboss.logging.Logger.Level.ERROR;
|
||||||
import static org.jboss.logging.Logger.Level.INFO;
|
import static org.jboss.logging.Logger.Level.INFO;
|
||||||
import static org.jboss.logging.Logger.Level.WARN;
|
import static org.jboss.logging.Logger.Level.WARN;
|
||||||
|
|
||||||
import javax.persistence.EntityNotFoundException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The jboss-logging {@link MessageLogger} for the hibernate-entitymanager module. It reserves message ids ranging from
|
* The jboss-logging {@link MessageLogger} for the hibernate-entitymanager module. It reserves message ids ranging from
|
||||||
* 15001 to 20000 inclusively.
|
* 15001 to 20000 inclusively.
|
||||||
|
@ -105,9 +103,9 @@ public interface EntityManagerMessageLogger extends CoreMessageLogger {
|
||||||
void usingProvidedDataSource();
|
void usingProvidedDataSource();
|
||||||
|
|
||||||
|
|
||||||
@LogMessage( level = DEBUG )
|
@LogMessage( level = DEBUG )
|
||||||
@Message( value = "Returning null (as required by JPA spec) rather than throwing EntityNotFoundException, " +
|
@Message( value = "Returning null (as required by JPA spec) rather than throwing EntityNotFoundException, " +
|
||||||
"as the entity (%s) does not exist", id = 15013 )
|
"as the entity (type=%s, id=%s) does not exist", id = 15013 )
|
||||||
void ignoringEntityNotFound( String entityName,
|
void ignoringEntityNotFound( String entityName, String identifier);
|
||||||
@Cause EntityNotFoundException e );
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue