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<Sucursal> listarSucursalCla(String clavePublica) 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();
       List<Sucursal> lista = (List) logic.getListarSucursalCla(cnx);
       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(MantenimientoSucursal.class.getName()).log(Level.SEVERE, null, ex);
         throw new UnknownException(ex.getMessage());
       }
     }
     if (!pm.isClosed()) {
       pm.close();
     }
   }
 }