Results 1 to 2 of 2

Thread: Spring jBPM Transactions Not Flushing

  1. #1

    Default Spring jBPM Transactions Not Flushing

    Hi all,

    I have been working with the new jBPM code in the spring-modules CVS, but none of the calls are being persisted to the database. I have the following spring config, but it seems the JbpmSessionFactoryUtils class cannot get a handle on a Transaction via the TransactionSynchronizationManager. Whenever I instantiate a Hibernate Transaction directly, I have no problems. Also, I am able read data from the database, just not write. Any suggestions?

    Thanks,
    Julian

    Code:
        <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="org.postgresql.Driver"/>
            <property name="url" value="jdbc&#58;postgresql&#58;//localhost&#58;5432/jbpm/>
            <property name="username" value="sa"/>
            <property name="password" value=""/>
        </bean>
    
        <bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="dataSource">
                <ref bean="dataSource"/>
            </property>
            <property name="mappingLocations">
                <value>classpath*&#58;/org/jbpm/**/*.hbm.xml</value>
            </property>
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
                    <prop key="hibernate.show_sql">true</prop>
                </props>
            </property>
            <property name="schemaUpdate" value="true"/>
        </bean>
    
        <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory" ref="hibernateSessionFactory"/>
        </bean>
    
        <bean id="hibernateConfiguration" factory-bean="&amp;hibernateSessionFactory" factory-method="getConfiguration"/>
    
        <bean id="jbpmSessionFactory" class="org.springframework.workflow.jbpm.LocalJbpmSessionFactoryBean">
            <property name="hibernateSessionFactory" ref="hibernateSessionFactory"/>
            <property name="hibernateConfiguration" ref="hibernateConfiguration"/>
        </bean>
        
        <bean id="jbpmTemplate" class="org.springframework.workflow.jbpm.JbpmTemplate">
            <property name="jbpmSessionFactory" ref="jbpmSessionFactory"/>
        </bean>

  2. #2
    Join Date
    Nov 2004
    Location
    Dallas, TX USA
    Posts
    24

    Default

    Julian,

    I throughly tested the spring-jbpm module. Rob Harrop told me its still a work in progress, but everything including transaction management is working quite well for me. I've tested JbpmTemplate transaciton intermingled with my domain specific HibernateTemplate transactions. Commits and rollbacks for all participating in the transaction are applied as you would expect.

    I'm using hypersonic right now, looks like you're using postgres.

    I'd like to see your implementation class, here's one I'm using to test writing a ProcessDefinition then retrieving a ProcessInstance

    Code:
    public class SimpleProcessPAOImpl implements SimpleProcessPAO &#123;
        
        private JbpmTemplate jbpmTemplate;
    
        public ProcessDefinition createProcessDef&#40;String xmlFileResource, final String processName&#41; &#123;
            final ProcessDefinition myDefinition = ProcessDefinition.parseXmlResource&#40;xmlFileResource&#41;;
            myDefinition.setName&#40;processName&#41;;
            ProcessDefinition processDef = &#40;ProcessDefinition&#41;jbpmTemplate.execute&#40;new JbpmCallback&#40;&#41;&#123;
                
                public Object doInJbpm&#40;JbpmSession jbpmSession&#41; throws Exception &#123;
                    GraphSession gSession = jbpmSession.getGraphSession&#40;&#41;;
                    gSession.saveProcessDefinition&#40;myDefinition&#41;;
                    return myDefinition;
                &#125;&#125;&#41;;
    
            return processDef;
        &#125;
        
        public void setJbpmSessionFactory&#40;JbpmSessionFactory jbpmSessionFactory&#41;
        &#123;
            jbpmTemplate = new JbpmTemplate&#40;jbpmSessionFactory&#41;;
        &#125;
    
        public ProcessInstance findProcessInstance&#40;Long processId&#41; &#123;
            return jbpmTemplate.findProcessInstance&#40;processId&#41;;
        &#125;
    
        public ProcessInstance createNewProcessInstance&#40;ProcessDefinition def&#41; &#123;
            ProcessInstance resultInstance = new ProcessInstance&#40;def&#41;;
            long instanceId = jbpmTemplate.saveProcessInstance&#40;resultInstance&#41;;
            return resultInstance;
            
        &#125;
        
        
    
    &#125;
    I'm calling this code inside of a transaction kicked of by the AbstractTransactionalDataSourceSpringContextTests class from spring-mock. In another case, to really see the transaction boundaries, I'm calling this code inside of a TransactionTemplate.execute().
    -steve

Similar Threads

  1. Spring MVC Web Framework versus Struts
    By biguniverse in forum Web Flow
    Replies: 27
    Last Post: Aug 29th, 2012, 03:57 AM
  2. Replies: 5
    Last Post: Aug 25th, 2005, 05:37 PM
  3. Replies: 6
    Last Post: May 25th, 2005, 01:56 AM
  4. A Spring Class Loader?
    By azzoti in forum Architecture
    Replies: 8
    Last Post: May 7th, 2005, 04:02 AM
  5. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •