@Override @Transactional public People findById(int id) throws ObjectNotFoundException{ People people = null; people = peopleDao.findById(id); if(people == null){ throw new ObjectNotFoundException("Couldn't find a People object with id " + id); } return people; }
/** * Return an object not found exception containing nested exceptions * for all of the given failed objects. */ private static ObjectNotFoundException newObjectNotFoundException (Collection failed) { Throwable[] t = new Throwable[failed.size()]; int idx = 0; for (Iterator itr = failed.iterator(); itr.hasNext(); idx++) t[idx] = new ObjectNotFoundException(itr.next()); return new ObjectNotFoundException(failed, t); }
/** * Return an object not found exception containing nested exceptions * for all of the given failed objects. */ private static ObjectNotFoundException newObjectNotFoundException (Collection failed) { Throwable[] t = new Throwable[failed.size()]; int idx = 0; for (Iterator<?> itr = failed.iterator(); itr.hasNext(); idx++) t[idx] = new ObjectNotFoundException(itr.next()); return new ObjectNotFoundException(failed, t); }
/** * Return an object not found exception containing nested exceptions * for all of the given failed objects. */ private static ObjectNotFoundException newObjectNotFoundException (Collection failed) { Throwable[] t = new Throwable[failed.size()]; int idx = 0; for (Iterator<?> itr = failed.iterator(); itr.hasNext(); idx++) t[idx] = new ObjectNotFoundException(itr.next()); return new ObjectNotFoundException(failed, t); }
/** * Return an object not found exception containing nested exceptions * for all of the given failed objects. */ private static ObjectNotFoundException newObjectNotFoundException (Collection failed) { Throwable[] t = new Throwable[failed.size()]; int idx = 0; for (Iterator<?> itr = failed.iterator(); itr.hasNext(); idx++) t[idx] = new ObjectNotFoundException(itr.next()); return new ObjectNotFoundException(failed, t); }
/** * Return an object not found exception containing nested exceptions * for all of the given failed objects. */ private static ObjectNotFoundException newObjectNotFoundException (Collection failed) { Throwable[] t = new Throwable[failed.size()]; int idx = 0; for (Iterator<?> itr = failed.iterator(); itr.hasNext(); idx++) t[idx] = new ObjectNotFoundException(itr.next()); return new ObjectNotFoundException(failed, t); }
public Object orphan(Object oid, OpenJPAStateManager sm, ValueMetaData vmd) { throw new ObjectNotFoundException(_loc.get("orphaned-key", oid, vmd)); } }
/** * Return the result object based on its cached oid. */ private static Object fromObjectId(Object oid, StoreContext sctx, FetchConfiguration fc) { if (oid == null) return null; Object obj = sctx.find(oid, fc, null, null, 0); if (obj == null) throw new ObjectNotFoundException(oid); return obj; }
public Object orphan(Object oid, OpenJPAStateManager sm, ValueMetaData vmd) { throw new ObjectNotFoundException(_loc.get("orphaned-key", oid, vmd)); } }
public class MyDao { public Entity getMyEntity(int id) throws ObjectNotFoundException, PersistenceException { try { // code to get Entity // if entity not found then throw new ObjectNotFoundException("Entity with id : " + id + "Not found."); } catch(Exception e) { // you can catch the generic exception like HibernateException for hibernate throw new PersistenceException("error message", e); } } }
/** * Return the result object based on its cached oid. */ private static Object fromObjectId(Object oid, StoreContext sctx) { if (oid == null) return null; Object obj = sctx.find(oid, null, null, null, 0); if (obj == null) throw new ObjectNotFoundException(oid); return obj; }
/** * Return the result object based on its cached oid. */ private static Object fromObjectId(Object oid, StoreContext sctx) { if (oid == null) return null; Object obj = sctx.find(oid, null, null, null, 0); if (obj == null) throw new ObjectNotFoundException(oid); return obj; }
public Object orphan(Object oid, OpenJPAStateManager sm, ValueMetaData vmd) { throw new ObjectNotFoundException(_loc.get("orphaned-key", oid, vmd)); } }
/** * Return the result object based on its cached oid. */ private static Object fromObjectId(Object oid, StoreContext sctx, FetchConfiguration fc) { if (oid == null) return null; Object obj = sctx.find(oid, fc, null, null, 0); if (obj == null) throw new ObjectNotFoundException(oid); return obj; }
public Object orphan(Object oid, OpenJPAStateManager sm, ValueMetaData vmd) { throw new ObjectNotFoundException(_loc.get("orphaned-key", oid, vmd)); } }
/** * Return the result object based on its cached oid. */ private static Object fromObjectId(Object oid, StoreContext sctx) { if (oid == null) return null; Object obj = sctx.find(oid, null, null, null, 0); if (obj == null) throw new ObjectNotFoundException(oid); return obj; }
public Object orphan(Object oid, OpenJPAStateManager sm, ValueMetaData vmd) { throw new ObjectNotFoundException(_loc.get("orphaned-key", oid, vmd)); } }
public Object getResultObject() throws Exception { Class type = getPCType(); MetaDataRepository repos = ctx.getConfiguration(). getMetaDataRepositoryInstance(); ClassMetaData meta = repos.getMetaData (type, ctx.getClassLoader(), true); Object oid = getObjectId(meta); Object res = ctx.find(oid, null, null, this, 0); if (res == null) throw new ObjectNotFoundException(oid); return res; }
public Object getResultObject() throws Exception { Class type = getPCType(); MetaDataRepository repos = ctx.getConfiguration(). getMetaDataRepositoryInstance(); ClassMetaData meta = repos.getMetaData (type, ctx.getClassLoader(), true); Object oid = getObjectId(meta); Object res = ctx.find(oid, null, null, this, 0); if (res == null) throw new ObjectNotFoundException(oid); return res; }
public Object getResultObject() throws Exception { Class type = getPCType(); MetaDataRepository repos = ctx.getConfiguration(). getMetaDataRepositoryInstance(); ClassMetaData meta = repos.getMetaData (type, ctx.getClassLoader(), true); Object oid = getObjectId(meta); Object res = ctx.find(oid, null, null, this, 0); if (res == null) throw new ObjectNotFoundException(oid); return res; }