0

我有的:

我正在尝试将 Activiti 配置为使用 jpa 事务管理器。请参阅下面的代码部分,我在processEngineConfiguration beanjpa-persistance.xml中 都定义了数据库配置。

有什么问题:

我得到 org.postgresql.util.PSQLException: ERROR: relationship act_hi_procinst already exists 异常

问题:

如何解决问题?

代码:

应用程序上下文.xml

 <bean id="activitiDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
        <property name="driverClass" value="org.postgresql.Driver" />
        <property name="url" value="jdbc:postgresql://localhost:5432/activiti-transaction-demo" />
        <property name="username" value="postgres" />
        <property name="password" value="Volodumur6894834" />
    </bean>

    <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
        <property name="persistenceXmlLocation">
            <value>classpath:jpa-persistence.xml</value>
        </property>
    </bean>

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceUnitManager" ref="persistenceUnitManager" />
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
    </bean>

    <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">

        <property name="databaseType" value="postgres" />
        <property name="dataSource" ref="activitiDataSource" />
        <property name="transactionManager" ref="transactionManager" />
        <property name="databaseSchemaUpdate" value="create" />
        <property name="jpaEntityManagerFactory" ref="entityManagerFactory" />
        <property name="jpaHandleTransaction" value="true" />
        <property name="jpaCloseEntityManager" value="true" />
        <property name="deploymentResources" value="classpath*:process/simplest_process.bpmn20.xml" />
        <property name="jobExecutorActivate" value="false" />
        <property name="history" value="full"/>
    </bean>

    <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
        <property name="processEngineConfiguration" ref="processEngineConfiguration" />
    </bean>

jpa-persistance.xml:

<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
    <persistence-unit name="Client" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <class>name.krestjaninoff.activiti.hello.db.Client</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.ProgressDialect" />
            <property name="hibernate.hbm2ddl.auto" value="create" />
            <property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
            <property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/activiti-transaction-demo" />
            <property name="hibernate.connection.username" value="postgres" />
            <property name="hibernate.connection.password" value="Volodumur6894834" />
            <property name="hibernate.show_sql" value="true"/>
        </properties>
    </persistence-unit>
</persistence>
4

1 回答 1

1

您已经在两个地方定义了数据库的创建:

<property name="databaseSchemaUpdate" value="create" />

<property name="hibernate.hbm2ddl.auto" value="create" />

也许尝试删除此属性之一或将 databaseSchemaUpdate 设置为“更新”。

于 2014-04-10T18:04:43.193 回答