Galera.
Estou tentando fazer um lock em um (ou mais) registros e estou recebendo a seguinte mensagem :
Oque eu quero é bloquear um registro quando eu pego ele, pois essa tabela terá muita concorrência…
Estou usando Glassfish, JPA (Toplink) e Oracle.
Será que no pool do glassfish eu tenho que alterar alguma coisa ?
O código que está abaixo.
[code]
try {
//throw new UnsupportedOperationException(“Not supported yet.”);
Context ctx = new InitialContext();
UserTransaction utx = (UserTransaction) ctx.lookup("java:comp/env/UserTransaction");
utx.begin();
EntityManager em = (EntityManager) ctx.lookup("java:comp/env/persistence/LogicalName");
Query q = em.createQuery("SELECT c FROM Code c where c.status='OK'");
q.setMaxResults(i);
q.setHint(TopLinkQueryHints.PESSIMISTIC_LOCK, PessimisticLock.LockNoWait);
List lcodes = q.getResultList();
lc = q.getResultList();
utx.commit();
ctx.close();
} catch (RollbackException ex) {
Logger.getLogger(CodeDAOjpa.class.getName()).log(Level.SEVERE, null, ex);
} catch (HeuristicMixedException ex) {
Logger.getLogger(CodeDAOjpa.class.getName()).log(Level.SEVERE, null, ex);
} catch (HeuristicRollbackException ex) {
Logger.getLogger(CodeDAOjpa.class.getName()).log(Level.SEVERE, null, ex);
} catch (SecurityException ex) {
Logger.getLogger(CodeDAOjpa.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalStateException ex) {
Logger.getLogger(CodeDAOjpa.class.getName()).log(Level.SEVERE, null, ex);
} catch (NotSupportedException ex) {
Logger.getLogger(CodeDAOjpa.class.getName()).log(Level.SEVERE, null, ex);
} catch (SystemException ex) {
Logger.getLogger(CodeDAOjpa.class.getName()).log(Level.SEVERE, null, ex);
} catch (NamingException ex) {
Logger.getLogger(CodeDAOjpa.class.getName()).log(Level.SEVERE, null, ex);
} catch (Exception e) {
System.out.println("EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE : "+e.getMessage());
}
[/code]
Valeu Galera.