pkleindl wrote:
Are you sure the variables are passed to the query correctly?
Try to remove the like-Restrictions and just do one with a known id... which just made me realize that your are using "usuario" as the id, usually not the best solution as it is a string
You can also try to replace the criteria query with HQL
Code:
ss.createQuery("from PendienteRegistro where usuario like :usuario and codigo like :codigo").addString("usuario",usuario).addString("codigo",codigo).uniqueResult();
and if you begin a Transaction you should commit at the end before closing the session.
hope that helps
Hi pkleindl and thanks very much for your help!
First, yes, "usuario" and "codigo" values are correct, check in real time debug.
I tried other Hibernate method to check if only failed Criteria method or other too.
I tried this:
Code:
Query query = ss.createSQLQuery("select * from pendiente_registro where usuario like ? and codigo like ? ").addEntity(PendienteRegistro.class);
query.setString(0, usuario);
query.setString(1, codigo);
pr = (PendienteRegistro) query.uniqueResult();
But query return "null" too, if I try with this:
Code:
Query query = ss.createSQLQuery("select * from pendiente_registro where usuario like 'value' and codigo like 'value' ").addEntity(PendienteRegistro.class);
pr = (PendienteRegistro) query.uniqueResult();
Result is correct, found correctly.
All interesting question is that if I copy and paste Hibernate sql_show print in java console, and replace '?' by correct values in mysql command line, query is correct too.