public int update(String statement, Object parameters) { String updateStatement = dbSqlSessionFactory.mapStatement(statement); return getSqlSession().update(updateStatement, parameters); }
if (isEngineTablePresent()) { PropertyEntity dbVersionProperty = selectById(PropertyEntity.class, "schema.version"); String dbVersion = dbVersionProperty.getValue(); matchingVersionIndex = findMatchingVersionIndex(dbVersion); matchingVersionIndex = findMatchingVersionIndex(LAST_V5_VERSION); dbHistoryProperty.setName("schema.history"); dbHistoryProperty.setValue("create(5.0)"); insert(dbHistoryProperty); } else { dbHistoryProperty = selectById(PropertyEntity.class, "schema.history"); dbSchemaUpgrade("engine", matchingVersionIndex); feedback = "upgraded Activiti from " + dbVersion + " to " + ProcessEngine.VERSION; dbSchemaCreateEngine(); if (isHistoryTablePresent()) { if (isUpgradeNeeded) { dbSchemaUpgrade("history", matchingVersionIndex); dbSchemaCreateHistory();
@SuppressWarnings({"rawtypes"}) public List selectList(String statement) { return selectList(statement, null, 0, Integer.MAX_VALUE); }
public Object execute(CommandContext commandContext) { DbSqlSession session = commandContext.getDbSqlSession(); session.dbSchemaDrop(); session.dbSchemaCreate(); return null; } });
public void performSchemaOperationsProcessEngineBuild() { String databaseSchemaUpdate = Context.getProcessEngineConfiguration().getDatabaseSchemaUpdate(); log.debug("Executing performSchemaOperationsProcessEngineBuild with setting " + databaseSchemaUpdate); if (ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_DROP_CREATE.equals(databaseSchemaUpdate)) { try { dbSchemaDrop(); } catch (RuntimeException e) { // ignore } } if (org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_CREATE_DROP.equals(databaseSchemaUpdate) || ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_DROP_CREATE.equals(databaseSchemaUpdate) || ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_CREATE.equals(databaseSchemaUpdate)) { dbSchemaCreate(); } else if (org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE.equals(databaseSchemaUpdate)) { dbSchemaCheckVersion(); } else if (ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE.equals(databaseSchemaUpdate)) { dbSchemaUpdate(); } }
public String execute(CommandContext commandContext) { DbSqlSessionFactory dbSqlSessionFactory = (DbSqlSessionFactory) commandContext.getSessionFactories().get(DbSqlSession.class); DbSqlSession dbSqlSession = new DbSqlSession(dbSqlSessionFactory, commandContext.getEntityCache(), connection, catalog, schema); commandContext.getSessions().put(DbSqlSession.class, dbSqlSession); return dbSqlSession.dbSchemaUpdate(); } });
public void dbSchemaCheckVersion() { try { String dbVersion = getDbVersion(); if (!ProcessEngine.VERSION.equals(dbVersion)) { throw new ActivitiWrongDbException(ProcessEngine.VERSION, if (!isEngineTablePresent()) { errorMessage = addMissingComponent(errorMessage, "engine"); if (dbSqlSessionFactory.isDbHistoryUsed() && !isHistoryTablePresent()) { errorMessage = addMissingComponent(errorMessage, "history"); if (isMissingTablesException(e)) { throw new ActivitiException( "no activiti tables in db. set <property name=\"databaseSchemaUpdate\" to value=\"true\" or value=\"create-drop\" (use create-drop for testing only!) in bean processEngineConfiguration in activiti.cfg.xml for automatic schema creation",
@Override public void insert(EntityImpl entity) { getDbSqlSession().insert(entity); }
@Override public void deleteByteArrayNoRevisionCheck(String byteArrayEntityId) { getDbSqlSession().delete("deleteByteArrayNoRevisionCheck", byteArrayEntityId, ByteArrayEntityImpl.class); }
public Session openSession(CommandContext commandContext) { DbSqlSession dbSqlSession = new DbSqlSession(this, commandContext.getEntityCache()); if (getDatabaseSchema() != null && getDatabaseSchema().length() > 0) { try { dbSqlSession.getSqlSession().getConnection().setSchema(getDatabaseSchema()); } catch (SQLException e) { throw new ActivitiException("Could not set database schema on connection", e); } } if (getDatabaseCatalog() != null && getDatabaseCatalog().length() > 0) { try { dbSqlSession.getSqlSession().getConnection().setCatalog(getDatabaseCatalog()); } catch (SQLException e) { throw new ActivitiException("Could not set database catalog on connection", e); } } return dbSqlSession; }
try { result.setTableName(tableName); DatabaseMetaData metaData = getDbSqlSession().getSqlSession().getConnection().getMetaData(); if ("postgres".equals(getDbSqlSession().getDbSqlSessionFactory().getDatabaseType())) { tableName = tableName.toLowerCase(); if ("oracle".equals(getDbSqlSession().getDbSqlSessionFactory().getDatabaseType())) { schema = getProcessEngineConfiguration().getDatabaseSchema().toUpperCase(); } else {
public Object execute(CommandContext commandContext) { commandContext.getDbSqlSession().dbSchemaDrop(); return null; } });
@Override public void commit() { long startTime = System.currentTimeMillis(); super.commit(); long endTime = System.currentTimeMillis(); CommandExecutionResult commandExecutionResult = getCurrentCommandExecution(); if (commandExecutionResult != null) { commandExecutionResult.addDatabaseTime(endTime - startTime); } }
@SuppressWarnings("unchecked") public void deleteAttachmentsByTaskId(String taskId) { checkHistoryEnabled(); List<AttachmentEntity> attachments = getDbSqlSession().selectList("selectAttachmentsByTaskId", taskId); for (AttachmentEntity attachment: attachments) { String contentId = attachment.getContentId(); if (contentId!=null) { getByteArrayManager().deleteByteArrayById(contentId); } getDbSqlSession().delete(attachment); } }
public void setValue(Object value, ValueFields valueFields) { byte[] byteArray = serialize(value, valueFields); valueFields.setCachedValue(value); if(valueFields.getByteArrayValue() == null) { if(valueFields instanceof VariableInstanceEntity) { Context .getCommandContext() .getDbSqlSession() .addDeserializedObject(valueFields.getCachedValue(), byteArray, (VariableInstanceEntity)valueFields); } } super.setValue(byteArray, valueFields); }
public Object execute(CommandContext commandContext) { commandContext.getDbSqlSession().dbSchemaUpdate(); return null; } });
public void deleteModel(String modelId) { ModelEntity model = getDbSqlSession().selectById(ModelEntity.class, modelId); getDbSqlSession().delete(model); deleteEditorSource(model); deleteEditorSourceExtra(model); }
@Override public Session openSession() { return new DbSqlSession(this); }
public void dbSchemaCheckVersion() { try { String dbVersion = getDbVersion(); if (!ProcessEngine.VERSION.equals(dbVersion)) { throw new ActivitiWrongDbException(ProcessEngine.VERSION, dbVersion); if (!isEngineTablePresent()) { errorMessage = addMissingComponent(errorMessage, "engine"); if (dbSqlSessionFactory.isDbHistoryUsed() && !isHistoryTablePresent()) { errorMessage = addMissingComponent(errorMessage, "history"); if (dbSqlSessionFactory.isDbIdentityUsed() && !isIdentityTablePresent()) { errorMessage = addMissingComponent(errorMessage, "identity"); if (isMissingTablesException(e)) { throw new ActivitiException( "no activiti tables in db. set <property name=\"databaseSchemaUpdate\" to value=\"true\" or value=\"create-drop\" (use create-drop for testing only!) in bean processEngineConfiguration in activiti.cfg.xml for automatic schema creation",
public Void execute(CommandContext commandContext) { if (ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_DROP_CREATE.equals(schemaOperation)) { try { commandContext.getDbSqlSession().dbSchemaDrop(); } catch (RuntimeException e) { // ignore } } if (org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_CREATE_DROP.equals(schemaOperation) || ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_DROP_CREATE.equals(schemaOperation) || ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_CREATE.equals(schemaOperation)) { commandContext.getDbSqlSession().dbSchemaCreate(); } else if (org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE.equals(schemaOperation)) { commandContext.getDbSqlSession().dbSchemaCheckVersion(); } else if (ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE.equals(schemaOperation)) { commandContext.getDbSqlSession().dbSchemaUpdate(); } return null; }