Criação de uma classe de atualização

Top  Previous  Next

O process action que vai ser criado para a atualização dos registros, utiliza a seguinte classe java:
 

package corporate.hoteisadmin6;

import java.sql.Connection;

import java.sql.PreparedStatement;

import lumis.portal.PortalException;

import lumis.portal.UnexpectedException;

import lumis.portal.dao.DaoException;

import lumis.portal.dao.jdbc.ITransactionJdbc;

import lumis.util.ITransaction;

public class HotelDaoJdbc

{

 public void definirLotados(String[] hotelIds, ITransaction transaction) throws DaoException, PortalException

 {

  try

  {

   ITransactionJdbc daoTransactionJdbc = (ITransactionJdbc) transaction;

   Connection connection = daoTransactionJdbc.getConnection();

   String hotelIdsList = "";

   for(String hotelId : hotelIds)

    hotelIdsList += "'"+hotelId+"',";

  

   if(hotelIdsList.length() > 0)

    hotelIdsList = hotelIdsList.substring(0, hotelIdsList.length()-1);

   else

    return;

  

   PreparedStatement statement = connection.prepareStatement("update tr3_hotel set lotado = 1 where hotelId in ("+hotelIdsList+")");

   try

   {

    statement.executeUpdate();

   }

   finally

   {

    statement.close();

   }

  }

  catch (PortalException e)

  {

   throw e;

  }

  catch (Exception e)

  {

   throw new UnexpectedException(e);

  }

 }

}


Lumis Portal 6.2.0.120405
Copyright © 2006–2012 Lumis EIP Tecnologia da Informação LTDA. Todos os direitos reservados.