com.mtgi.analytics
Class JdbcBehaviorEventPersisterImpl
java.lang.Object
org.springframework.dao.support.DaoSupport
org.springframework.jdbc.core.support.JdbcDaoSupport
com.mtgi.analytics.JdbcBehaviorEventPersisterImpl
- All Implemented Interfaces:
- BehaviorEventPersister, org.springframework.beans.factory.InitializingBean
public class JdbcBehaviorEventPersisterImpl
- extends org.springframework.jdbc.core.support.JdbcDaoSupport
- implements BehaviorEventPersister
Basic implementation of BehaviorEventPersister
, which uses JDBC
batching to persist instances of BehaviorEvent
using configurable
insert SQL. An instance of EventDataElementSerializer
is used
to convert event data to XML documents for insertion.
Fields inherited from class org.springframework.dao.support.DaoSupport |
logger |
Methods inherited from class org.springframework.jdbc.core.support.JdbcDaoSupport |
checkDaoConfig, createJdbcTemplate, getConnection, getDataSource, getExceptionTranslator, getJdbcTemplate, initTemplateConfig, releaseConnection, setDataSource, setJdbcTemplate |
Methods inherited from class org.springframework.dao.support.DaoSupport |
afterPropertiesSet |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JdbcBehaviorEventPersisterImpl
public JdbcBehaviorEventPersisterImpl()
setBatchSize
public void setBatchSize(int batchSize)
- Set the JDBC batch size for executing inserts. Only has effect if the JDBC driver
supports statement batching. Defaults to 25 if unspecified.
setIdSql
public void setIdSql(String idSql)
- Set the SQL select statement used to retrieve a new primary key value for an event
prior to insert. Default is
select S_BEHAVIOR_TRACKING_EVENT.nextval from dual
if unspecified.
getIdSql
public String getIdSql()
setInsertSql
public void setInsertSql(String insertSql)
- Set the SQL statement used to insert a new behavior event record into the database.
The SQL statement must take exactly 11 parameters, which must accept the following
event values in order:
- EVENT ID
- PARENT EVENT ID
- APPLICATION
- TYPE
- NAME
- START
- DURATION
- USER ID
- SESSION ID
- ERROR
- DATA
Default is
insert into BEHAVIOR_TRACKING_EVENT
(EVENT_ID, PARENT_EVENT_ID, APPLICATION, TYPE, NAME, START, DURATION_MS, USER_ID, SESSION_ID, ERROR, DATA)
values
( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
initDao
protected void initDao()
throws Exception
- Overrides:
initDao
in class org.springframework.dao.support.DaoSupport
- Throws:
Exception
persist
public int persist(Queue<BehaviorEvent> events)
- Description copied from interface:
BehaviorEventPersister
- Drain the given event queue, persisting all instances to the
database. Persisters must support the persisting of child events
before their parents, since this is generally the natural order
in which events are completed. This method returns when the queue
is empty.
- Specified by:
persist
in interface BehaviorEventPersister
- Returns:
- the number of persisted events
nextId
protected Long nextId(PreparedStatement idQuery)
throws SQLException
- Throws:
SQLException
nullSafeSet
protected void nullSafeSet(PreparedStatement stmt,
int index,
Object value,
int sqlType)
throws SQLException
- Throws:
SQLException