商店的統計數據我有一個計算時代的一些服務被稱爲AOP方面:使用Hibernate在DB與Hibernate
@Aspect
@Component
public class CounterAspect {
private Map<Integer, Integer> gettingEventStatistics = new HashMap<>();
@Pointcut("execution(Event EventService+.getById(Integer))")
private void gettingEvent() {}
@AfterReturning(pointcut = "gettingEvent()", returning = "retVal")
public void countGettingEvent(JoinPoint joinPoint, Object retVal) {
Integer id = (Integer) joinPoint.getArgs()[0];
if (id != null && retVal != null) {
Integer currentCounterValue = gettingEventStatistics.get(id);
gettingEventStatistics.put(id, currentCounterValue == null ? 1 : currentCounterValue + 1);
}
}
}
我怎麼能存儲這樣的信息?
什麼阻止您自動裝配存儲庫相關的bean並在您選擇的表中手動保存數據? – isah