AnsweredAssumed Answered

Activiti with JPA

Question asked by luisalves00 on Apr 21, 2011
Latest reply on Apr 26, 2011 by luisalves00
Hello,

I'm using activiti with JPA.

my config:


<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
        <property name="url" value="jdbc:mysql://localhost:3306/activiti?autoReconnect=true" />
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="username" value="activiti" />
        <property name="password" value="activiti" />
        <property name="defaultAutoCommit" value="false" />

         <!– confirm these properties –>
        <!– <property name="jdbcMaxActiveConnections" value="300" />
        <property name="jdbcMaxIdleConnections" value="30" /> –>
    </bean>

    <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
        <property name="dataSource" ref="dataSource" />

        <property name="databaseType" value="mysql" />
        <property name="databaseSchemaUpdate" value="true" />

        <property name="jpaPersistenceUnitName" value="GAEPU" />
        <property name="jpaHandleTransaction" value="true" />
        <property name="jpaCloseEntityManager" value="true" />


        <property name="history" value="audit" />
    </bean>


Issue:

    When I set new values on the (JavaDelegate) service task they don't seem to be "auto-magically" updated.

Tried to invoke this code at the end:

private void updatePedidoAutorizacao(PedidoAutorizacao pa) throws Exception {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        PedidoAutorizacaoJpaController authorizationRequestController = (PedidoAutorizacaoJpaController) facesContext.getApplication().getELResolver().getValue(facesContext.getELContext(), null, "PedidoAutorizacaoJpa");
        authorizationRequestController.edit(pa);
    }

but get some weird behaviour, i.e. tries to insert stuff that is already there and got an exception:

Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'SomeCo' for key 'designacao'

Outcomes