@SuppressWarnings("unchecked")
 public <T> T getReference(Class<T> entityClass, Object primaryKey) {
   try {
     return (T) getSession().load(entityClass, (Serializable) primaryKey);
   } catch (MappingException e) {
     throw new IllegalArgumentException(e.getMessage(), e);
   } catch (TypeMismatchException e) {
     throw new IllegalArgumentException(e.getMessage(), e);
   } catch (ClassCastException e) {
     throw new IllegalArgumentException(e.getMessage(), e);
   } catch (HibernateException he) {
     throw convert(he);
   }
 }
 public <A> A find(
     Class<A> entityClass,
     Object primaryKey,
     LockModeType lockModeType,
     Map<String, Object> properties) {
   CacheMode previousCacheMode = getSession().getCacheMode();
   CacheMode cacheMode = determineAppropriateLocalCacheMode(properties);
   LockOptions lockOptions = null;
   try {
     getSession().setCacheMode(cacheMode);
     if (lockModeType != null) {
       return (A)
           getSession()
               .get(
                   entityClass,
                   (Serializable) primaryKey,
                   getLockRequest(lockModeType, properties));
     } else {
       return (A) getSession().get(entityClass, (Serializable) primaryKey);
     }
   } catch (ObjectDeletedException e) {
     // the spec is silent about people doing remove() find() on the same PC
     return null;
   } catch (ObjectNotFoundException e) {
     // should not happen on the entity itself with get
     throw new IllegalArgumentException(e.getMessage(), e);
   } catch (MappingException e) {
     throw new IllegalArgumentException(e.getMessage(), e);
   } catch (TypeMismatchException e) {
     throw new IllegalArgumentException(e.getMessage(), e);
   } catch (ClassCastException e) {
     throw new IllegalArgumentException(e.getMessage(), e);
   } catch (HibernateException he) {
     throw convert(he, lockOptions);
   } finally {
     getSession().setCacheMode(previousCacheMode);
   }
 }