How to write the new Criteria Query in my case?

Hi expert,

I am using hibernate 5.2.1.

However, I do not know how to change the following deprecated code into the new Criteria Query.

My old code is :

try{ tx = session.getTransaction(); tx.begin(); session.flush();
Query query = (Query) session.createQuery("from tutor where tutorid = '" + tutor.getTutorid() + "'"); Tutor t = (Tutor)((org.hibernate.Query) query).uniqueResult(); tx.commit(); if(t !=null)result = true; }catch (Exception ex){ if(tx !=null){ tx.rollback();

Hope someone can advise me. Tk.s

View Answers









Related Tutorials/Questions & Answers:
Advertisements