@Override
public int insertAction(ActionVO<Integer, Integer> action, boolean useDateFromVO) {
if (logger.isTraceEnabled()) {
logger.trace("inserting action=" + action);
}
validateNonEmptyFields(action, useDateFromVO);
Object[] args = {action.getTenant(), action.getUser(), action.getSessionId(), action.getIp(),
((action.getItem() != null) ? action.getItem().getItem() : null),
((action.getItem() != null) ? action.getItem().getType() : null), action.getActionType(),
action.getRatingValue(), action.getSearchSucceeded(), action.getNumberOfFoundItems(),
action.getDescription(), ((useDateFromVO && action.getActionTime() != null) ? action.getActionTime() :
new Date(System.currentTimeMillis()))};
KeyHolder keyHolder = new GeneratedKeyHolder();
int rowsAffected = getJdbcTemplate().update(PS_INSERT_ACTION.newPreparedStatementCreator(args), keyHolder);
action.setId(keyHolder.getKey().intValue());
return rowsAffected;
}