0

I have three tables: user, home, user_home.

In code i have entity User and Home.

In repository i want to get users by home address.

I`m using next code:

@Query("select u " +
        "from UserHome m " +
        "join User u on m.user_id = u.user_id " +
        "join Home h on m.home_id = h.home_id " +
        "where h.address = :address")
List<Users> findByHomeAddress(@Param("address") String address);

But i receive next message:"QuerySyntaxException: UserHome is not mapped"

ks_on_v
  • 219
  • 2
  • 3
  • 15
  • Most likely there's an issue in the code of your entities where you should have implemented @ManyToMany mapping, and this important part is missing. – Nowhere Man Apr 21 '20 at 18:00
  • 1
    You may want to review this answer explaining [how create a query for ManyToMany relationship](https://stackoverflow.com/questions/33438483/spring-data-jpa-query-manytomany) – Nowhere Man Apr 21 '20 at 18:04

1 Answers1

0

The table name which you are using in the query should match exactly the entity name as you are writing the custom query. Check once.

Harisudha
  • 527
  • 5
  • 5