1
@Repository
public interface TopicRepository extends CrudRepository<Topic, String>{
@Query(value = "SELECT u from topic u where u.name = ?1")
List<Topic> findEverything(String name);
}
根據spring文檔,我可以做上面的@query。但是,它給我造成了:org.hibernate.hql.internal.ast.QuerySyntaxException:主題未映射錯誤。@Query引起:org.hibernate.hql.internal.ast.QuerySyntaxException:主題未映射錯誤
但是,當我這樣做下面,它的工作原理。
@Repository
public interface TopicRepository extends CrudRepository<Topic, String>{
@Query(value="SELECT * FROM topic WHERE topic.name = ?1", nativeQuery = true)
List<Topic> findEverything(String name);
}
我正在使用mySQL數據庫。我需要知道爲什麼。請幫助我,謝謝你。
是您的主題java類與@Entity註解? –
@premkumar是的,在這種情況下是 – Desmond
......可能是您的實體包掃描沒有發生。意義存儲庫被掃描,但不是您的實體 –