Hi Maciej...
Basically, what I want is to do a query in a Database (Oracle11g) table, located in other scheme that reserved for JBPM, that I have mapped in the JBPM project through a DataObject to launch signals to processes instances related to the results I get from the query.
The code for the dataobject is:
package org.proyect.dataobjects;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
/**
* This class was automatically generated by the data modeler tool.
*/
public class IncidenciaHorizontal_Controller implements java.io.Serializable {
static final long serialVersionUID = 1L;
public void IncidenciaHorizontal_Controller() {
}
public void Propaga_Incidencia_Controller() {
EntityManagerFactory emf;
EntityManager em;
emf = Persistence.createEntityManagerFactory("desnorm");
em = emf.createEntityManager();
Query namedQuery = em.createQuery("SELECT ..............");
// process result after query execution.
// the code, generate a signal for all instance process related with query results.
// the query returns process instanceid signaled.
}
}
I have a bpmn process with a script type task that executes the following code:
...
org.proyect.dataobjects.IncidenceHorizontal_Controller IC = new org.proyect.dataobjects.IncidenciaHorizontal_Controller ();
IC.Propaga_Incidencia_Controller ();
...
I have also tried this:
package org.proyect.dataobjects;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.*;
public class Incidencia_Horizontal implements java.io.Serializable
{
@PersistenceContext(unitName = "desnorm")
private EntityManager entityManager;
public Incidencia_Horizontal()
{
System.out.println("entitymanager inyected= " + entityManager ) ;
}
public void Propaga_Incidencia()
{
System.out.println("...................................... invoke Propaga_Incidencia...................");
Query namedQuery = entityManager.createQuery("SELECT IDPROCED FROM V_TRAM_PERSON WHERE IDPERSON = to_number(:idperson)");
namedQuery.setParameter("idperson",72415);
//...................
}
}
In this case, entityManager allways is null ...
My POM file is:
<modelVersion>4.0.0</modelVersion>
<groupId>org.proyect</groupId>
<artifactId>PIA</artifactId>
<version>380</version>
<name>PIA</name>
<description>Incident Proyect </description>
<properties>
<hibernate.version>4.2.0.Final</hibernate.version>
<hibernate.core.version>4.2.0.Final</hibernate.core.version>
</properties>
<repositories>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</snapshots>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>6.3.0.Final-redhat-5</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
Thanks Maciej .....