001package io.ebean.config; 002 003import io.ebean.bean.ObjectGraphNode; 004 005/** 006 * Slow query event. 007 */ 008public class SlowQueryEvent { 009 010 private final String sql; 011 012 private final long timeMillis; 013 014 private final int rowCount; 015 016 private final ObjectGraphNode originNode; 017 018 /** 019 * Construct with the SQL and execution time in millis. 020 */ 021 public SlowQueryEvent(String sql, long timeMillis, int rowCount, ObjectGraphNode originNode) { 022 this.sql = sql; 023 this.timeMillis = timeMillis; 024 this.rowCount = rowCount; 025 this.originNode = originNode; 026 } 027 028 /** 029 * Return the SQL for the slow query. 030 */ 031 public String getSql() { 032 return sql; 033 } 034 035 /** 036 * Return the execution time in millis. 037 */ 038 public long getTimeMillis() { 039 return timeMillis; 040 } 041 042 /** 043 * Return the total row count associated with the query. 044 */ 045 public int getRowCount() { 046 return rowCount; 047 } 048 049 /** 050 * Return the origin point for the root query. 051 * <p> 052 * Typically the <code>originNode.getOriginQueryPoint().getFirstStackElement()</code> provides the stack line that 053 * shows the code that invoked the query. 054 * </p> 055 */ 056 public ObjectGraphNode getOriginNode() { 057 return originNode; 058 } 059}