提交 f71bae8b 编写于 作者: C cmuelder

ACT-187: fixed postgres scripts (postgres 8.4)

上级 549a0562
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>
<name>Activiti - Engine</name>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<name>Activiti - Engine</name>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<parent>
<groupId>org.activiti</groupId>
<artifactId>activiti-root</artifactId>
<relativePath>../..</relativePath>
<version>5.0.rc1-SNAPSHOT</version>
</parent>
<parent>
<groupId>org.activiti</groupId>
<artifactId>activiti-root</artifactId>
<relativePath>../..</relativePath>
<version>5.0.rc1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-pvm</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
</dependency>
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel-impl</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<!-- required for building with JDK 5 -->
<dependency>
<groupId>org.livetribe</groupId>
<artifactId>livetribe-jsr223</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
</dependency>
<!-- EMAIL -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
</dependency>
<dependency>
<groupId>org.subethamail</groupId>
<artifactId>subethasmtp-wiser</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</dependency>
</dependencies>
<repositories>
<repository>
<id>alfresco</id>
<url>http://maven.alfresco.com/nexus/content/groups/public</url>
</repository>
</repositories>
<!-- build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*TestCase.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build -->
<dependencies>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-pvm</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
</dependency>
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel-impl</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<!-- required for building with JDK 5 -->
<dependency>
<groupId>org.livetribe</groupId>
<artifactId>livetribe-jsr223</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
</dependency>
<profiles>
<profile>
<id>checkspring</id>
<properties>
<skipTests>true</skipTests>
</properties>
</profile>
<profile>
<id>distro</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- database qa profile -->
<profile>
<id>database</id>
<activation>
<property>
<name>database</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.4-701.jdbc4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<!--
only worked with this version, there might be a bug with antrun
see http://jira.codehaus.org/browse/MANTRUN-109
-->
<version>1.4</version>
<executions>
<execution>
<id>database-test-create-schema</id>
<phase>process-test-classes</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo
message="CREATING SCHEMA AND UPDATING PROPERTIES ${database} #{database} @{database} " />
<ant antfile="${basedir}/../../qa/db/build.xml" target="create.db.schema"
inheritAll="false">
<property name="test_classpath" refid="maven.test.classpath" />
<property name="database" value="${database}" />
</ant>
<ant antfile="${basedir}/../../qa/db/build.xml" target="create.activiti.prop">
<property name="database" value="${database}" />
</ant>
</tasks>
</configuration>
</execution>
<execution>
<id>database-test-drop-schema</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo message="DROPPING SCHEMA ${database} #{database} @{database} " />
<ant antfile="${basedir}/../../qa/db/build.xml" target="drop.db.schema"
inheritAll="false">
<property name="test_classpath" refid="maven.test.classpath" />
<property name="database" value="${database}" />
</ant>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>oracle</id>
<activation>
<property>
<name>database</name>
<value>oracle</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc5</artifactId>
<version>11.2.0.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<!-- EMAIL -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
</dependency>
<dependency>
<groupId>org.subethamail</groupId>
<artifactId>subethasmtp-wiser</artifactId>
<scope>test</scope>
</dependency>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<excludePackageNames>org.activiti.impl*,org.activiti.engine.impl*</excludePackageNames>
</configuration>
</plugin>
</plugins>
</reporting>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</dependency>
</dependencies>
<repositories>
<repository>
<id>alfresco</id>
<url>http://maven.alfresco.com/nexus/content/groups/public</url>
</repository>
</repositories>
<!--
build> <plugins> <plugin>
<artifactId>maven-surefire-plugin</artifactId> <configuration>
<excludes> <exclude>**/*TestCase.java</exclude> </excludes>
</configuration> </plugin> </plugins> </build
-->
<profiles>
<profile>
<id>checkspring</id>
<properties>
<skipTests>true</skipTests>
</properties>
</profile>
<profile>
<id>distro</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- database qa profile -->
<profile>
<id>database</id>
<activation>
<property>
<name>database</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.4-701.jdbc4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<!--
only worked with this version, there might be a bug with antrun
see http://jira.codehaus.org/browse/MANTRUN-109
-->
<version>1.4</version>
<executions>
<execution>
<id>database-test-create-schema</id>
<phase>process-test-classes</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo
message="CREATING SCHEMA AND UPDATING PROPERTIES ${database} #{database} @{database} " />
<ant antfile="${basedir}/../../qa/db/build.xml" target="create.db.schema"
inheritAll="false">
<property name="test_classpath" refid="maven.test.classpath" />
<property name="database" value="${database}" />
</ant>
<ant antfile="${basedir}/../../qa/db/build.xml" target="create.activiti.prop">
<property name="database" value="${database}" />
</ant>
</tasks>
</configuration>
</execution>
<execution>
<id>database-test-drop-schema</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo message="DROPPING SCHEMA ${database} #{database} @{database} " />
<ant antfile="${basedir}/../../qa/db/build.xml" target="drop.db.schema"
inheritAll="false">
<property name="test_classpath" refid="maven.test.classpath" />
<property name="database" value="${database}" />
</ant>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>oracle</id>
<activation>
<property>
<name>database</name>
<value>oracle</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc5</artifactId>
<version>11.2.0.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<excludePackageNames>org.activiti.impl*,org.activiti.engine.impl*</excludePackageNames>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
......@@ -109,12 +109,25 @@ public class DbManagementSession implements ManagementSession, Session {
.getSqlSession()
.getConnection()
.getMetaData();
DbMetaDataHandler databaseMetaDataHandler = TableMetaDataCacheHandler.getInstance().getDatabaseHandler(metaData);
TableMetaData resultCached = null;
if( (resultCached = databaseMetaDataHandler.getFromCache(tableName)) != null)
{
return resultCached;
}
else
{
tableName = databaseMetaDataHandler.handleTableName(tableName);
}
ResultSet resultSet = metaData.getColumns(null, null, tableName, null);
while(resultSet.next()) {
String name = resultSet.getString("COLUMN_NAME");
String type = resultSet.getString("TYPE_NAME");
result.addColumnMetaData(name, type);
}
databaseMetaDataHandler.addToCache(result);
} catch (SQLException e) {
throw new ActivitiException("Could not retrieve database metadata: " + e.getMessage());
}
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.db;
import org.activiti.engine.management.TableMetaData;
/**
* @author Christian Mlder
*/
public interface DbMetaDataHandler {
public String handleTableName(String table);
public void addToCache(TableMetaData metaData);
public TableMetaData getFromCache(String tableName);
}
......@@ -61,12 +61,20 @@ public class DbSqlSessionFactory implements SessionFactory, ProcessEngineConfigu
protected static final Map<String, Map<String, String>> databaseSpecificStatements = new HashMap<String, Map<String,String>>();
static {
//mysql specific
addDatabaseSpecificStatement("mysql", "selectTaskByQueryCriteria", "selectTaskByQueryCriteria_mysql");
addDatabaseSpecificStatement("mysql", "selectNextJobsToExecute", "selectNextJobsToExecute_mysql");
addDatabaseSpecificStatement("mysql", "selectProcessDefinitionsByQueryCriteria", "selectProcessDefinitionsByQueryCriteria_mysql");
addDatabaseSpecificStatement("mysql", "selectProcessDefinitionCountByQueryCriteria", "selectProcessDefinitionCountByQueryCriteria_mysql");
addDatabaseSpecificStatement("mysql", "selectDeploymentsByQueryCriteria", "selectDeploymentsByQueryCriteria_mysql");
addDatabaseSpecificStatement("mysql", "selectDeploymentCountByQueryCriteria", "selectDeploymentCountByQueryCriteria_mysql");
//postgres specific
addDatabaseSpecificStatement("postgres", "insertByteArray", "insertByteArray_postgres");
addDatabaseSpecificStatement("postgres", "updateByteArray", "updateByteArray_postgres");
addDatabaseSpecificStatement("postgres", "selectByteArrayById", "selectByteArrayById_postgres");
addDatabaseSpecificStatement("postgres", "selectResourceByDeploymentIdAndResourceName", "selectResourceByDeploymentIdAndResourceName_postgres");
addDatabaseSpecificStatement("postgres", "selectResourcesByDeploymentId", "selectResourcesByDeploymentId_postgres");
}
protected String databaseName;
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.db;
import java.util.ArrayList;
import java.util.List;
import org.activiti.engine.management.TableMetaData;
/**
* @author Christian Mlder
*/
public class PostgresDbMetaDataHandler extends StdDbMetaDataHandler implements DbMetaDataHandler {
@Override
public void addToCache(TableMetaData metaData) {
toUpperCase(metaData);
super.addToCache(metaData);
}
private void toUpperCase(TableMetaData metaData) {
List<String> list = new ArrayList<String>();
for(String columnNames : metaData.getColumnNames())
{
list.add(columnNames.toUpperCase());
}
metaData.setColumnNames(list);
list = new ArrayList<String>();
for(String columnTypes : metaData.getColumnTypes())
{
list.add(columnTypes.toUpperCase());
}
metaData.setColumnTypes(list);
}
@Override
public String handleTableName(String table) {
return table.toLowerCase();
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.db;
import org.activiti.engine.management.TableMetaData;
/**
* @author Christian Mlder
*/
public class StdDbMetaDataHandler implements DbMetaDataHandler {
public void addToCache(TableMetaData metaData) {
TableMetaDataCacheHandler.getInstance().getMetaDataCache().put(metaData.getTableName(), metaData);
}
public TableMetaData getFromCache(String tableName) {
return TableMetaDataCacheHandler.getInstance().getMetaDataCache().get(tableName);
}
public String handleTableName(String table) {
return table;
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.db;
import java.util.HashMap;
import org.activiti.engine.management.TableMetaData;
/**
* @author Christian Mlder
*/
public class TableMetaDataCache extends HashMap<String, TableMetaData> {
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.db;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
/**
* @author Christian Mlder
*/
public class TableMetaDataCacheHandler {
private static TableMetaDataCacheHandler instance = new TableMetaDataCacheHandler();
private TableMetaDataCache cache = new TableMetaDataCache();
public static TableMetaDataCacheHandler getInstance() {
return instance;
}
public DbMetaDataHandler getDatabaseHandler(DatabaseMetaData metaData) throws SQLException
{
if(metaData.getDatabaseProductName().equalsIgnoreCase("postgresql"))
return new PostgresDbMetaDataHandler();
else
return new StdDbMetaDataHandler();
}
public TableMetaDataCache getMetaDataCache() {
return cache;
}
}
......@@ -250,4 +250,22 @@
select distinct count(D.ID_)
<include refid="selectDeploymentsByQueryCriteriaSql"/>
</select>
<!-- postgresql specific -->
<resultMap id="resourceResultMap_postgres" type="org.activiti.engine.impl.repository.ResourceEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" jdbcType="VARCHAR"/>
<result property="bytes" column="BYTES_" jdbcType="BINARY"/>
</resultMap>
<select id="selectResourceByDeploymentIdAndResourceName_postgres" parameterType="map" resultMap="resourceResultMap_postgres">
select * from ACT_GE_BYTEARRAY
where DEPLOYMENT_ID_ = #{deploymentId}
AND NAME_ = #{resourceName}
</select>
<select id="selectResourcesByDeploymentId_postgres" parameterType="string" resultMap="resourceResultMap_postgres">
select * from ACT_GE_BYTEARRAY where DEPLOYMENT_ID_ = #{deploymentId} order by NAME_ asc
</select>
</mapper>
\ No newline at end of file
......@@ -111,7 +111,7 @@
<delete id="deleteByteArraysForDeployment" parameterType="string">
delete from ACT_GE_BYTEARRAY where DEPLOYMENT_ID_ = #{id}
</delete>
<delete id="deleteByteArray" parameterType="string">
delete from ACT_GE_BYTEARRAY where ID_ = #{id}
</delete>
......@@ -122,7 +122,7 @@
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="revision" column="REV_" jdbcType="INTEGER"/>
<result property="name" column="NAME_" jdbcType="VARCHAR"/>
<result property="bytes" column="BYTES_" jdbcType="BLOB"/>
<result property="bytes" column="BYTES_" jdbcType="BLOB"/>
</resultMap>
<!-- BYTE ARRAY SELECT -->
......@@ -145,4 +145,35 @@
AND NAME_ = #{resourceName}
</select>
<!-- Postgresql specific configuration -->
<resultMap id="byteArrayResultMap_postgres" type="org.activiti.engine.impl.runtime.ByteArrayEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="revision" column="REV_" jdbcType="INTEGER"/>
<result property="name" column="NAME_" jdbcType="VARCHAR"/>
<result property="bytes" column="BYTES_" jdbcType="BINARY"/>
</resultMap>
<select id="selectByteArrayById_postgres" parameterType="string" resultMap="byteArrayResultMap_postgres">
select * from ACT_GE_BYTEARRAY where ID_ = #{id}
</select>
<update id="updateByteArray_postgres" parameterType="org.activiti.engine.impl.runtime.ByteArrayEntity">
update ACT_GE_BYTEARRAY
set
REV_ = #{revisionNext, jdbcType=INTEGER},
BYTES_ = #{bytes, jdbcType=BINARY}
where ID_ = #{id}
and REV_ = #{revision, jdbcType=INTEGER}
</update>
<insert id="insertByteArray_postgres" parameterType="org.activiti.engine.impl.runtime.ByteArrayEntity">
insert into ACT_GE_BYTEARRAY(ID_, REV_, NAME_, BYTES_, DEPLOYMENT_ID_)
values (
#{id, jdbcType=VARCHAR},
1,
#{name, jdbcType=VARCHAR},
#{bytes, jdbcType=BINARY},
#{deploymentId, jdbcType=VARCHAR}
)
</insert>
</mapper>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册