Given the following entity…
@Entity
@Getter
@Setter
public class OrderDTD {
private Long id;
...
private String orderType;
private String orderStatus;
… and the following view…
public interface OrderStatsView {
/** Gets the order type. */
String getOrderType();
/** Gets the total number of orders. */
Long getOrderCount();
/** Gets the number of executed orders. */
Long getExecutedOrderCount();
}
… I’ve created a method to retrieve some stats for a given order:
@Repository
public interface OrderRepository
extends JpaRepository<OrderDTD, Long> {
...
@Query("SELECT o.orderType AS orderType,"
+ " COUNT(o.orderStatus) AS orderCount,"
+ " COUNT(CASE WHEN o.orderStatus = 'EXECUTED'"
+ " THEN 1 END) AS executedOrderCount"
+ " FROM OrderDTD o"
+ " WHERE o.orderType = :orderType"
+ " GROUP BY o.orderType")
@Cacheable("orderStatsView")
Optional<OrderStatsView> getOrderStats(@NonNull String orderType);
@Override
@CacheEvict(value = "orderStatsView", key = "#p0.orderType")
<T extends OrderDTD> T save(T order);
}
Method getOrderStats()
works as expected without caching… whereas when I enable caching with @Cacheable
, I always get this error:
com.hazelcast.nio.serialization.HazelcastSerializationException: Failed to serialize 'jdk.proxy3.$Proxy584'
Am I missing something? Any help would be really appreciated 🙂