3 Replies Latest reply on Oct 5, 2010 2:32 PM by Leo van den berg

    Query to store information from the jbpm to a db

    Andrea Vanz Newbie

      I have a TodoDoc.java document where I manage the process and from which I get 3 information to store in the db.
      I also have a Workflow.java document that is the entity I have to put the 3 information.

      I have a process definition. When I switch from one task to the next one I have to store in the database some information (like logged user, task description and name of the task). I have to put these information inside the entity (Workflow.java)

      The task description should be put in the idDocumento of the entity, the user and the name of the task inside the idStato.
      How can I create a query that would let me save these information inside the DB?


      public class TodoDoc {
           private String description;
           private String nomeDoc = new String();
           EntityManager entityManager;
           Credentials credentials;
           public String getDescription() {
                return description;
           public void setDescription(String description) {
                this.description = description;
           @CreateProcess(definition = "todo")
           public void createTodo() {
                nomeDoc = description;
           @CreateProcess(definition = "todo2")
           public void createTodo2() {
                nomeDoc = description;
           @StartTask @EndTask
           public void conferma() {
                System.out.println("Nome Documento: "+TaskInstance.instance().getDescription());
                System.out.println("Stato Documento: "+TaskInstance.instance().getName());
                System.out.println("User: "+credentials.getUsername());
      //          String query="INSERT INTO Workflow (documento_fk,statoDocumento_fk) VALUES (?,?)";
      //          entityManager.createQuery(query).executeUpdate();     
      //          String query="INSERT INTO Workflow (documento_fk,statoDocumento_fk) VALUES("+TaskInstance.instance().getDescription()+","+TaskInstance.instance().getName()+")";
      //          entityManager.createQuery(query);
           @EndTask(transition = "rifiuta")
           public void rifiuta() {
           public void idprocesso() {
                if ("redazione".equals(TaskInstance.instance().getName())) {
                               "Var", TaskInstance.instance().getDescription().toString());
                nomeDoc = ProcessInstance.instance().getContextInstance().getVariable(
           public String getNomeDoc() {
                return nomeDoc;
           public void setNomeDoc(String nomeDoc) {
                this.nomeDoc = nomeDoc;
           public EntityManager getEntityManager() {
                return entityManager;
           public void setEntityManager(EntityManager entityManager) {
                this.entityManager = entityManager;


      public class Workflow implements Serializable
          private Long id;
          private String name;
          private Documento documento;
          private StatoDocumento statoDocumento;
          private User user;
          @Id @GeneratedValue
          public Long getId() {
              return id;
          public void setId(Long id) {
              this.id = id;
          @Length(max = 20)
          public String getName() {
              return name;
          public void setName(String name) {
              this.name = name;
           public Documento getDocumento() {
                return documento;
           public void setDocumento(Documento documento) {
                this.documento = documento;
           public StatoDocumento getStatoDocumento() {
                return statoDocumento;
           public void setStatoDocumento(StatoDocumento statoDocumento) {
                this.statoDocumento = statoDocumento;
           public User getUser() {
                return user;
           public void setUser(User user) {
                this.user = user;