【发布时间】:2016-06-16 13:20:38
【问题描述】:
当我为实体编写accessor 时,我通常会添加同一查询的同步和异步版本。例如:
@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.
可能有一种方法可以同时拥有同一查询的同步和异步版本,但无需重新准备?
【问题讨论】: