Spring/Activiti/JPA(Hibernate) Integration

1. script

Target DB: Oracle 11g XE on Windows 7

Scripts Location:

D:\activiti-5.10\apps\apache-tomcat-6.0.32\work\Catalina\localhost\activiti-explorer\loader\org\activiti\db\create
activiti.oracle.create.engine.sql

activiti.oracle.create.history.sql

activiti.oracle.create.identity.sql

2. applicationContext.xml

On the basis of the Spring/Hibernate integration, which you can refer to http://blog.csdn.net/derek_zhang_/article/details/8363490,we should inject the EntityManagerFactory into Activiti Engine Configuration, as follows:




    
        
    

    

    
        
            classpath*:META-INF/persistence.xml
        
    

    
        
        
    

    
    

    
    
    
    
    
    
    
        
        
        
        
    

    
        
        
        
        
        
        
        
        
        
    
    
    
        
    

    
    
    
    
    
    

THINK: Activiti engine must have the reference of EntiyManagerFactory, in order to conduct database related operations like storing historic information. In the other hand, activiti would call back business services in the task declarations, since business services have been injected EntiyManagerFactory object, there is probably no need for business service to utilize the activiti sessionfactory, I guess.

What I still don't understand is why there is a datasource property in SpringProcessEngineConfiguration, if it's compulsory, I would really regard it as a typical unelegant example. Reason: explore it below.


3. Touchy Issue

### The error occurred while setting parameters
### SQL: select * from ACT_RE_DEPLOYMENT D where NAME_=? order by D.DEPLOY_TIME_ desc     LIMIT ? OFFSET ?
### Cause: java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)

Be aware of that we take JPA as persistence solution, however, when we initialize ApplicationContext in unit test, we got ibatis exception as shown above. Probably, activiti utilizes ibatis for interanl database operation. Hence, activiti engine configuration needs a data source reference, rather than an instance of EntityManagerFactory.

Caused by: incorrect process engine configuration:

		
		
		
		
		
		
		
		
		
	
Solution: set the databaseType as 'oracle'

你可能感兴趣的:(Workflow,J2EE)