public Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException {
Class<?> clazz;
try {
clazz = Class.forName(entityName);
} catch (ClassNotFoundException e) {
throw new CallbackException(String.format("Unable to load class for %s", entityName), e);
}
if (EntityResolver.generatesImplementation(clazz))
return getInstance(GeneratedClassFactory.getGeneratedClass(clazz));
else if (EntityResolver.isGeneratedImplementation(clazz)) {
Class generatingClass = Filter.grepSingle(new Predicate<Class>() {