コード例 #1
0
ファイル: FlotaHome.java プロジェクト: nackd/gofleet
  @SuppressWarnings("unchecked")
  @Transactional(
      propagation = Propagation.REQUIRES_NEW,
      readOnly = true,
      rollbackFor = Throwable.class)
  public List<Flota> getByFilter(Flota f) {
    List<Flota> res = new ArrayList<Flota>(0);
    try {
      Session currentSession = getSession();
      currentSession.clear();
      Criteria criteria =
          currentSession.createCriteria(Flota.class).add(Restrictions.eq("habilitada", true));

      if (f.getInfoAdicional() != null)
        criteria =
            criteria.add(
                Restrictions.ilike(
                    "infoAdicional", LogicConstants.getGenericString(f.getInfoAdicional())));
      if (f.getNombre() != null)
        criteria =
            criteria.add(
                Restrictions.ilike("nombre", LogicConstants.getGenericString(f.getNombre())));
      if (f.getHabilitada() != null)
        criteria = criteria.add(Restrictions.eq("habilitada", f.getHabilitada()));
      if (f.getJuegoIconos() != null)
        criteria =
            criteria.add(
                Restrictions.ilike(
                    "juegoIconos", LogicConstants.getGenericString(f.getJuegoIconos())));
      res =
          criteria
              .addOrder(Order.asc("nombre"))
              .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
              .list();

      for (Flota fl : res)
        if (fl != null) {
          if (fl.getRoles() != null) for (Rol r : fl.getRoles()) r.getId();
        }
    } catch (Throwable t) {
      log.error(t, t);
    }
    return res;
  }
コード例 #2
0
ファイル: FlotaHome.java プロジェクト: nackd/gofleet
 @Transactional(propagation = Propagation.REQUIRED, readOnly = true, rollbackFor = Throwable.class)
 public Flota find(Long id) {
   Session currentSession = getSession();
   currentSession.clear();
   final Flota uniqueResult =
       (Flota)
           currentSession
               .createCriteria(Flota.class)
               .add(Restrictions.eq("id", id))
               .uniqueResult();
   if (uniqueResult != null) {
     uniqueResult.getJuegoIconos();
   }
   return uniqueResult;
 }