1

I have upgraded all my project dependencies in gradle to spring boot 3 compatible. for ex: springframewor.boot version to 3.0.7 and Hibernate-core version to 6.1.7 final, java version to 17. During application build i am getting Unresolved reference for path in the import org.hibernate.query.criteria.internal.path.SingularAttributePath

a piece of code snippet using singularAttributePath is below:

val expression = getMethod.invoke(root,filterCriteria.field) as SingularAttributePath<*>

i am getting Unresolved reference for SingularAttributePath in the above code.

what is the implementation for SingularAttributePath in Hibernate 6?

1 Answer 1

0

Spring Boot 3.0 which comes with Hibernate 6 by default. In Hibernate 6, the SingularAttributePath is not typically used directly. Instead, you interact with the path expressions through Root, Join, or Path objects. You should use Path or Expression instead when working with a singular attribute (like a simple property on an entity).

For example,

CriteriaBuilder cb = session.getCriteriaBuilder();
CriteriaQuery<Person> query = cb.createQuery(Person.class);
Root<Person> root = query.from(Person.class);

// Correct approach for getting a singular attribute path in Hibernate 6
Path<String> namePath = root.get("name");

query.select(root).where(cb.equal(namePath, "John Doe"));

List<Person> resultList = session.createQuery(query).getResultList();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.