JPAを使用して単純な検索エンジンをコーディングしたいだけです。PHP で動作するネイティブ SQL リクエストの例を次に示します。
"SELECT mobiles.brand, argus_waitings_mobiles_prices.mobile, argus_waitings_mobiles_prices.argus_buyer_id, "
. "MATCH(mobile) AGAINST('$mobile_tags' IN BOOLEAN MODE) AS pertinence "
. "FROM argus_waitings_mobiles_prices "
. "WHERE argus_waitings_mobiles_prices.argus_buyer_id = $buyerId "
. "ORDER BY pertinence DESC "
. "LIMIT 10");
私はこのように同じことをしたいのですが、うまくいきません:
@Override
@SuppressWarnings("unchecked")
@Transactional(readOnly=true)
public List<Thread> findAllWithReferer(String referer) {
EntityManager entityManager = EntityManagerUtil.createEntityManagerAndOpenTransaction();
Query query = entityManager.createQuery("SELECT t "
+ "MATCH(t.title) AGAINST(:referer IN BOOLEAN MODE) AS pertinence "
+ "FROM Thread t MATCH(t.title) AGAINST(:referer IN BOOLEAN MODE)"
+ "ORDER BY pertinence DESC "
+ "LIMIT 10");
return (query.getResultList());
}
エラーメッセージの冒頭は次のとおりです。
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: MATCH near line 1, column 40 [SELECT t FROM fr.dorian.model.Thread t MATCH(t.title) AGAINST(:referer IN BOOLEAN MODE)]
誰でも私を助けることができますか?
よろしくお願いします。