エラー内容

org.hibernate.hql.internal.ast.QuerySyntaxException: table_name is not mapped

 

発生条件/原因

@Queryアノテーション内のテーブル名が正しくないのが原因。

 

対処法

@Query内に書くテーブル名は実際のテーブル名ではなく、Entity名を指定する点に注意。

以下の例を参照。(テーブル名はTestTable)

@Repository

public interface TestTableRepository extends JpaRepository<TestTable, String>{

@Query("FROM TestTable WHERE ID = :id")

TestTable findById(@Param("id") String id);

}