#Spring Data JPA @Query issue with List of DTO objects as parameter.

4 messages · Page 1 of 1 (latest)

surreal bone
#

I have a List of UnitDTO objects containing multiple fields including searchString1 and searchString2.

@Query("SELECT HU "
      + "FROM Unit HU "
      + "   LEFT JOIN FETCH HU.ent1 S "
      + "   LEFT JOIN FETCH S.ent2 EB "
      + "WHERE (HU.searchString1, HU.searchString2) IN :unitDTO")
  List<Unit> findAllBySearchStrings(@Param("unitDTO") List<UnitDTO> huDTOs);

Obviously I get an exception which says that UnitDTO is not an entity (Caused by: org.hibernate.HibernateException: Could not determine a type for class: packagenameshere.UnitDTO).

I want to keep the signature of my repository method as is. Is there any way to do this?

chilly sparrowBOT
#

This post has been reserved for your question.

Hey @surreal bone! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

#

<@&765578700724371486>

Requested by Yasin#9548