コード例 #1
0
 @Override
 public boolean saveEntity(Class<Entity> entityClass, Map<String, Object> map) {
   BaseDao<Entity> dao = new BaseDaoImpl<Entity>(entityClass, entityManager);
   Object obj = map.get("id");
   Entity entity = null;
   if (obj != null && !"".equals(obj)) {
     entity = dao.findOne(Long.valueOf(map.get("id").toString()));
   } else {
     try {
       entity = entityClass.newInstance();
     } catch (InstantiationException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (IllegalAccessException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   BeanUtil.copyProperties(entity, map);
   dao.saveAndFlush(entity);
   return true;
 }
コード例 #2
0
 /*
  * (non-Javadoc)
  *
  * @see com.gls.framework.master.dao.MasterDao#loadDatagridData(java.lang. Class, java.lang.Integer, java.lang.Integer)
  */
 @Override
 public Page<Entity> loadDatagridData(Class<Entity> entityClass, Integer page, Integer rows) {
   BaseDao<Entity> dao = new BaseDaoImpl<Entity>(entityClass, entityManager);
   Page<Entity> pageEntity = dao.findAll(new PageRequest(page - 1, rows));
   return pageEntity;
 }