public static String insertarSucursal(String clavePublica, Sucursal bean)
     throws UnknownException {
   PersistenceManager pm = null;
   Connection cnx = null;
   try {
     String keypublic = StringHex.convertHexToString(clavePublica);
     pm = PMF.getClassPMF().getPMF(keypublic).getPersistenceManager();
     if (!pm.isClosed()) {
       LogicSucursal logic = new LogicSucursal(pm);
       JDOConnection cnxJDO = pm.getDataStoreConnection();
       cnx = (Connection) cnxJDO.getNativeConnection();
       cnx.setAutoCommit(false);
       List<String> array = (List) logic.insertarSucursal(cnx, bean);
       cnx.commit();
       cnx.close();
       return array.get(0);
     } else {
       throw new UnknownException("Conexión expiró/nvuelva a iniciar sesión");
     }
   } catch (UnknownException ex) {
     throw new UnknownException(ex.getMessage());
   } catch (SQLException ex) {
     throw new UnknownException(ex.getMessage());
   } finally {
     if (cnx != null) {
       try {
         if (!cnx.isClosed()) {
           cnx.rollback();
           cnx.close();
         }
       } catch (SQLException ex) {
         Logger.getLogger(MantenimientoPrecioItem.class.getName()).log(Level.SEVERE, null, ex);
         throw new UnknownException(ex.getMessage());
       }
     }
     if (!pm.isClosed()) {
       pm.close();
     }
   }
 }
 public static List<CondicionVenta> listarxVigenciaCredito(
     String clavePublica, Integer vigenciaCredito) throws UnknownException {
   PersistenceManager pm = null;
   Connection cnx = null;
   try {
     String keypublic = StringHex.convertHexToString(clavePublica);
     pm = PMF.getClassPMF().getPMF(keypublic).getPersistenceManager();
     if (!pm.isClosed()) {
       LogicCondicionVenta logic = new LogicCondicionVenta(pm);
       JDOConnection cnxJDO = pm.getDataStoreConnection();
       cnx = (Connection) cnxJDO.getNativeConnection();
       List<CondicionVenta> lista =
           (List) logic.getListarBeanXvigenciaCredito(cnx, vigenciaCredito);
       cnx.close();
       return lista;
     } else {
       throw new UnknownException("Conexión expiró/nvuelva a iniciar sesión");
     }
   } catch (UnknownException ex) {
     throw new UnknownException(ex.getMessage());
   } catch (Exception ex) {
     throw new UnknownException(ex.getMessage());
   } finally {
     if (cnx != null) {
       try {
         if (!cnx.isClosed()) {
           cnx.close();
         }
       } catch (SQLException ex) {
         Logger.getLogger(MantenimientoCondicionVenta.class.getName()).log(Level.SEVERE, null, ex);
         throw new UnknownException(ex.getMessage());
       }
     }
     if (!pm.isClosed()) {
       pm.close();
     }
   }
 }