start = System.currentTimeMillis();
try {
// invoke underlying entity manager method and if not running in a tx
// return a Query wrapper around the result.
EntityManager entityManager = getEntityManager();
return detachQueryNonTxInvocation(entityManager, entityManager.createNamedQuery(name));
} finally {
if (isTraceEnabled) {
long elapsed = System.currentTimeMillis() - start;
ROOT_LOGGER.tracef("createNamedQuery name '%s' took %dms", name, elapsed);
}