この内容は古いバージョンです。最新バージョンを表示するには、戻るボタンを押してください。
バージョン:1
ページ更新者:guest
更新日時:2018-07-31 12:29:35

タイトル: org.hibernate.hql.internal.ast.QuerySyntaxException: table_name is not mapped

エラー内容

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);

}