user222
user222

Reputation: 597

IllegalArgumentException - did not match expected type unable to build the query

I am trying to write the below JPQL query .

List<Person> personList = query
            .from(person)
            .innerJoin(person.address, address)
            .where(address.status.eq("active")
            .fetch();

Below is the exception thrown after executing the above lines:

nested exception is java.lang.IllegalArgumentException: Parameter value [select person
from Person person
  inner join person.address as address
where address.status = ?1] did not match expected type [com.org.myProject.entity.Address (n/a)] 

Upvotes: 0

Views: 132

Answers (1)

Karamveer Gahlot
Karamveer Gahlot

Reputation: 222

can u try this

EntityManager em = entityManagerFactory.createEntityManager();
Query query = em.createQuery("SELECT DISTINCT p FROM Person p INNER JOIN p.address a");
List<Person> resultList = query.getResultList();

Upvotes: 1

Related Questions