[rules-users] Drools Human Task Service Persistence

loumimi moundir.jamal-ext at sgcib.com
Thu May 12 11:25:45 EDT 2011


Hello Ram,

I'm running a simple J2SE application (a hello world), I'm trying to persist
a simple drools workflow into Oracle DB. 
Here's my configuration :
Oracle 10.2.0.4.0
drools-decisiontables-5.0.1.jar
hibernate-core-3.3.0.SP1.jar
...

persistence.xml : 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<persistence
  version="1.0"
  xsi:schemaLocation=
    "http://java.sun.com/xml/ns/persistence
     http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
     http://java.sun.com/xml/ns/persistence/orm
     http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
  xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://java.sun.com/xml/ns/persistence">


  <persistence-unit name="org.drools.persistence.jpa" 
transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>org.drools.persistence.session.SessionInfo</class>
   
<class>org.drools.persistence.processinstance.ProcessInstanceInfo</class> 
   
<class>org.drools.persistence.processinstance.ProcessInstanceEventInfo</class>
    <class>org.drools.persistence.processinstance.WorkItemInfo</class> 
    
    <properties>
      <property name="hibernate.dialect"
value="org.hibernate.dialect.Oracle10gDialect"/>
      <property name="hibernate.connection.driver_class"
value="oracle.jdbc.OracleDriver"/>
      <property name="hibernate.connection.url"
value="jdbc:oracle:thin:@gfxdevdb01.fr.world.xxxx:1567:CCOD02"/>
      <property name="hibernate.connection.username" value="xxxx"/>	  
      <property name="hibernate.connection.password" value="xxxx"/>
      <property name="hibernate.connection.autocommit" value="true" />
      <property name="hibernate.max_fetch_depth" value="3"/>
      <property name="hibernate.hbm2ddl.auto" value="update" />
      <property name="hibernate.show_sql" value="true" />    
      <property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup" />
    </properties>
  </persistence-unit>
</persistence>


----
orm.xml :
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
               version="1.0">  
      <named-query name="ProcessInstancesWaitingForEvent">
          <query>
select 
    processInstanceInfo.processInstanceId
from 
    ProcessInstanceInfo processInstanceInfo
where
    :type in elements(processInstanceInfo.eventTypes)
          </query>
      </named-query>
</entity-mappings>


---
the code :
public static final void main(String[] args) {
		try {
		    
		    KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
	      kbuilder.add(ResourceFactory.newClassPathResource("ruleflow.rf"),
ResourceType.DRF);
	      KnowledgeBuilderErrors errors = kbuilder.getErrors();
	      if (errors.size() > 0) {
	            for (KnowledgeBuilderError error: errors) {
	                System.err.println(error);
	            }
	            throw new IllegalArgumentException("Could not parse
knowledge.");
	      }
	      KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
	      kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
	        
        // create the entity manager factory and register it in the
environment
		    EntityManagerFactory emf =  Persistence.createEntityManagerFactory(
"org.drools.persistence.jpa" );
		    Environment env = KnowledgeBaseFactory.newEnvironment();
		    env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
   		  //  env.set( EnvironmentName.TRANSACTION_MANAGER, XXXXXXXXXXX );
		    // create a new knowledge session that uses JPA to store the runtime
state
		    StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
		                
		    // invoke methods on your method here
		    ksession.startProcess( "com.sample.ruleflow" );
		    ksession.fireAllRules();  		
		    ksession.dispose();
		    
		} catch (Throwable t) {
			t.printStackTrace();
		}
	}


I don't know If I miss something

--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Human-Task-Service-Persistence-tp1868778p2932251.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list