/** @see com.g4g.services.GameOptionService#getList() */
 @SuppressWarnings(UNCHECKED)
 public List<GameoptionsDTO> getList() throws HibernateException {
   AuditUtil.getInstance()
       .writeLog(
           AuditUtil.FILE_TYPE_G4G,
           new StringBuffer(this.getClass().getName())
               .append(COLON_WITH_SPACES)
               .append(CALLINGMETHOD)
               .append(DataUtil.getCallingMethod())
               .append(CURRENTMETHOD)
               .append(DataUtil.getCurrentMethod())
               .append(DASHES)
               .append(STARTED)
               .append(DASHES)
               .append(PARAMETERS)
               .append(GAMEID_DB)
               .toString(),
           Level.INFO);
   Session session = HibernateUtil.getSession();
   Query query =
       session.createQuery(
           new StringBuffer(G4GConstants.FROM)
               .append(G4GConstants.BLANK)
               .append(G4GConstants.GAME_OPTION_DTO)
               .toString());
   Transaction transaction = session.beginTransaction();
   List<GameoptionsDTO> list = query.list();
   transaction.commit();
   HibernateUtil.closeSession();
   AuditUtil.getInstance()
       .writeLog(
           AuditUtil.FILE_TYPE_G4G,
           new StringBuffer(this.getClass().getName())
               .append(COLON_WITH_SPACES)
               .append(CALLINGMETHOD)
               .append(DataUtil.getCallingMethod())
               .append(CURRENTMETHOD)
               .append(DataUtil.getCurrentMethod())
               .append(DASHES)
               .append(GAME_OPTIONS_LIST_SIZE)
               .append(list.size())
               .toString(),
           Level.INFO);
   AuditUtil.getInstance()
       .writeLog(
           AuditUtil.FILE_TYPE_G4G,
           new StringBuffer(this.getClass().getName())
               .append(COLON_WITH_SPACES)
               .append(CALLINGMETHOD)
               .append(DataUtil.getCallingMethod())
               .append(CURRENTMETHOD)
               .append(DataUtil.getCurrentMethod())
               .append(DASHES)
               .append(ENDED)
               .toString(),
           Level.INFO);
   return list;
 }
  /** @see com.g4g.services.GameOptionService#getGame(com.g4g.dto.GameoptionsDTO) */
  public GameoptionsDTO getGame(GameoptionsDTO dto) throws HibernateException {
    AuditUtil.getInstance()
        .writeLog(
            AuditUtil.FILE_TYPE_G4G,
            new StringBuffer(this.getClass().getName())
                .append(COLON_WITH_SPACES)
                .append(CALLINGMETHOD)
                .append(DataUtil.getCallingMethod())
                .append(CURRENTMETHOD)
                .append(DataUtil.getCurrentMethod())
                .append(DASHES)
                .append(STARTED)
                .append(DASHES)
                .append(PARAMETERS)
                .append(GAME_OPTION_DTO)
                .toString(),
            Level.INFO);
    Session session = HibernateUtil.getSession();
    Transaction transaction = session.beginTransaction();
    dto = (GameoptionsDTO) session.get(GameoptionsDTO.class, dto);
    transaction.commit();
    HibernateUtil.closeSession();
    AuditUtil.getInstance()
        .writeLog(
            AuditUtil.FILE_TYPE_G4G,
            new StringBuffer(this.getClass().getName())
                .append(DASHES)
                .append(GET_GAME_OF_ID)
                .toString(),
            Level.INFO);
    AuditUtil.getInstance()
        .writeLog(
            AuditUtil.FILE_TYPE_G4G,
            new StringBuffer(this.getClass().getName())
                .append(COLON_WITH_SPACES)
                .append(CALLINGMETHOD)
                .append(DataUtil.getCallingMethod())
                .append(CURRENTMETHOD)
                .append(DataUtil.getCurrentMethod())
                .append(DASHES)
                .append(ENDED)
                .toString(),
            Level.INFO);

    return dto;
  }
 /** @see com.g4g.services.GameOptionService#add(com.g4g.dto.GameoptionsDTO) */
 public GameoptionsDTO add(GameoptionsDTO dto) throws HibernateException {
   AuditUtil.getInstance()
       .writeLog(
           AuditUtil.FILE_TYPE_G4G,
           new StringBuffer(this.getClass().getName())
               .append(COLON_WITH_SPACES)
               .append(CALLINGMETHOD)
               .append(DataUtil.getCallingMethod())
               .append(CURRENTMETHOD)
               .append(DataUtil.getCurrentMethod())
               .append(DASHES)
               .append(STARTED)
               .toString(),
           Level.INFO);
   Session session = HibernateUtil.getSession();
   Transaction transaction = session.beginTransaction();
   try {
     session.save(dto);
     transaction.commit();
     session.flush();
     HibernateUtil.closeSession();
     AuditUtil.getInstance()
         .writeLog(
             AuditUtil.FILE_TYPE_G4G,
             new StringBuffer(this.getClass().getName())
                 .append(COLON_WITH_SPACES)
                 .append(CALLINGMETHOD)
                 .append(DataUtil.getCallingMethod())
                 .append(CURRENTMETHOD)
                 .append(DataUtil.getCurrentMethod())
                 .append(DASHES)
                 .append(RECORD_ADDED)
                 .toString(),
             Level.INFO);
   } catch (HibernateException e) {
     transaction.rollback();
     HibernateUtil.closeSession();
     AuditUtil.getInstance()
         .writeLog(
             AuditUtil.FILE_TYPE_HIBERNATE,
             new StringBuffer(this.getClass().getName())
                 .append(COLON_WITH_SPACES)
                 .append(CALLINGMETHOD)
                 .append(DataUtil.getCallingMethod())
                 .append(CURRENTMETHOD)
                 .append(DataUtil.getCurrentMethod())
                 .append(DASHES)
                 .append(RECORD_NOT_ADDED)
                 .toString(),
             Level.ERROR);
     AuditUtil.getInstance()
         .writeLog(
             AuditUtil.FILE_TYPE_HIBERNATE,
             new StringBuffer(this.getClass().getName())
                 .append(COLON_WITH_SPACES)
                 .append(CALLINGMETHOD)
                 .append(DataUtil.getCallingMethod())
                 .append(CURRENTMETHOD)
                 .append(DataUtil.getCurrentMethod())
                 .append(DASHES)
                 .append(e.getMessage())
                 .toString(),
             Level.ERROR);
     throw e;
   }
   AuditUtil.getInstance()
       .writeLog(
           AuditUtil.FILE_TYPE_G4G,
           new StringBuffer(this.getClass().getName())
               .append(COLON_WITH_SPACES)
               .append(CALLINGMETHOD)
               .append(DataUtil.getCallingMethod())
               .append(CURRENTMETHOD)
               .append(DataUtil.getCurrentMethod())
               .append(DASHES)
               .append(ENDED)
               .toString(),
           Level.INFO);
   return dto;
 }
 /**
  * @see com.g4g.services.GameOptionService#getGameOptions(int, int, com.g4g.dto.SearchCriteria)
  */
 public List<GameoptionsDTO> getGameOptions(
     int gameid, int optionsequenceid, SearchCriteria searchCriteria) throws HibernateException {
   AuditUtil.getInstance()
       .writeLog(
           AuditUtil.FILE_TYPE_G4G,
           new StringBuffer(this.getClass().getName())
               .append(COLON_WITH_SPACES)
               .append(CALLINGMETHOD)
               .append(DataUtil.getCallingMethod())
               .append(CURRENTMETHOD)
               .append(DataUtil.getCurrentMethod())
               .append(DASHES)
               .append(STARTED)
               .toString(),
           Level.INFO);
   StringBuffer query =
       new StringBuffer(GameIdConstants.gameoptionquery).append(gameid).append(G4GConstants.BLANK);
   Set<String> keys = searchCriteria.getAttributeNames();
   Iterator<String> it = keys.iterator();
   String key = null;
   Object value = null;
   if (keys.size() > 0) {
     query.append(GameIdConstants.gameoptionqueryapp);
   }
   while (it.hasNext()) {
     key = it.next();
     value = searchCriteria.getAttribute(key);
     query.append(key).append(SQLConstants.EQUAL).append(value).append(G4GConstants.BLANK);
   }
   if (keys.size() > 0) {
     query.append(SQLConstants.CLOSE_PAREN);
   }
   query
       .append(GameIdConstants.middelquery)
       .append((optionsequenceid + G4GConstants.ONE_NUMBER))
       .append(GameIdConstants.gameoptionquerylast);
   Session session = HibernateUtil.getSession();
   Query q = session.createQuery(query.toString());
   Transaction transaction = session.beginTransaction();
   List<GameoptionsDTO> list = null;
   try {
     list = q.list();
     transaction.commit();
   } catch (HibernateException e) {
     throw e;
   } finally {
     session.flush();
     HibernateUtil.closeSession();
   }
   AuditUtil.getInstance()
       .writeLog(
           AuditUtil.FILE_TYPE_G4G,
           new StringBuffer(this.getClass().getName())
               .append(COLON_WITH_SPACES)
               .append(CALLINGMETHOD)
               .append(DataUtil.getCallingMethod())
               .append(CURRENTMETHOD)
               .append(DataUtil.getCurrentMethod())
               .append(DASHES)
               .append(GAME_OPTIONS_LIST_SIZE_CRITERIA)
               .append(list.size())
               .toString(),
           Level.INFO);
   return list;
 }
  /** @see com.g4g.services.GameOptionService#getList(com.g4g.dto.SearchCriteria) */
  @SuppressWarnings(UNCHECKED)
  public List<GameoptionsDTO> getList(SearchCriteria searchCriteria) throws HibernateException {
    AuditUtil.getInstance()
        .writeLog(
            AuditUtil.FILE_TYPE_G4G,
            new StringBuffer(this.getClass().getName())
                .append(COLON_WITH_SPACES)
                .append(CALLINGMETHOD)
                .append(DataUtil.getCallingMethod())
                .append(CURRENTMETHOD)
                .append(DataUtil.getCurrentMethod())
                .append(DASHES)
                .append(STARTED)
                .toString(),
            Level.INFO);
    Session session = HibernateUtil.getSession();
    Criteria criteria = session.createCriteria(GameoptionsDTO.class);
    String orderBY = searchCriteria.getOrderBy();
    if (orderBY != null) {
      if (searchCriteria.isAsc()) {
        criteria.addOrder(Order.asc(orderBY));
      } else {
        criteria.addOrder(Order.desc(orderBY));
      }
    }
    Set<String> keys = searchCriteria.getAttributeNames();
    Iterator<String> it = keys.iterator();
    String key = null;
    Object value = null;
    while (it.hasNext()) {
      key = it.next();
      value = searchCriteria.getAttribute(key);
      criteria.add(Restrictions.eq(key, value));
      AuditUtil.getInstance()
          .writeLog(
              AuditUtil.FILE_TYPE_G4G,
              new StringBuffer(this.getClass().getName())
                  .append(DASHES)
                  .append(key)
                  .append(COLON)
                  .append(value)
                  .toString(),
              Level.INFO);
    }
    Transaction transaction = session.beginTransaction();
    List<GameoptionsDTO> list = new ArrayList<GameoptionsDTO>();

    try {
      list = criteria.list();
      transaction.commit();
    } catch (HibernateException e) {
      for (String keyexception : keys) {
        AuditUtil.getInstance()
            .writeLog(
                AuditUtil.FILE_TYPE_HIBERNATE,
                new StringBuffer(this.getClass().getName()).append(keyexception).toString(),
                Level.ERROR);
      }
      throw e;
    } finally {
      session.flush();
      HibernateUtil.closeSession();
    }
    AuditUtil.getInstance()
        .writeLog(
            AuditUtil.FILE_TYPE_G4G,
            new StringBuffer(this.getClass().getName())
                .append(COLON_WITH_SPACES)
                .append(CALLINGMETHOD)
                .append(DataUtil.getCallingMethod())
                .append(CURRENTMETHOD)
                .append(DataUtil.getCurrentMethod())
                .append(DASHES)
                .append(GAME_OPTIONS_LIST_SIZE_CRITERIA)
                .append(list.size())
                .toString(),
            Level.INFO);
    AuditUtil.getInstance()
        .writeLog(
            AuditUtil.FILE_TYPE_G4G,
            new StringBuffer(this.getClass().getName())
                .append(COLON_WITH_SPACES)
                .append(CALLINGMETHOD)
                .append(DataUtil.getCallingMethod())
                .append(CURRENTMETHOD)
                .append(DataUtil.getCurrentMethod())
                .append(DASHES)
                .append(ENDED)
                .toString(),
            Level.INFO);
    return list;
  }