當我爲實體編寫accessor時,我通常會添加同一查詢的同步和異步版本。例如:如何正確使用同步和異步方法爲DataStax訪問器做飯?
@Accessor
public interface SourceDataAccessor {
@Query("select * from source_data where data_id = ?")
Result<SourceDataCass> get(UUID dataId);
@Query("select * from source_data where data_id = ?")
ListenableFuture<Result<SourceDataCass>> getAsync(UUID dataId);
}
但是,當訪問被實例化這樣的警告出現在日誌中:
12:32:49,793 WARN com.datastax.driver.core.Cluster:2109 - Re-preparing already prepared query select * from source_data where data_id = ?. Please note that preparing the same query more than once is generally an anti-pattern and will likely affect performance. Consider preparing the statement only once.
可能有辦法有兩個同步和相同的查詢,但沒有異步版本重新準備?
是的,這是有道理的。謝謝! – sedovav