faoxis faoxis - 1 year ago 597
Java Question

Deprecated createCriteria method in Hibernate

This calling is deprecated:


In source files I can see this:

/** @deprecated */
Criteria createCriteria(Class var1);

/** @deprecated */
Criteria createCriteria(Class var1, String var2);

/** @deprecated */
Criteria createCriteria(String var1);

/** @deprecated */
Criteria createCriteria(String var1, String var2);

But I can't understand which method I have to use instead of

Answer Source

You can use the following interfaces instead in Hibernate 5.2 +:


// Create CriteriaBuilder
CriteriaBuilder builder = session.getCriteriaBuilder();

// Create CriteriaQuery
CriteriaQuery<YourClass> criteria = builder.createQuery(YourClass.class);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download