1 Reply Latest reply on Feb 13, 2014 2:07 AM by Maciej Swiderski

    how to join task entity to processInstanceInfo?

    mostapha aminipour Newbie

      I want to join task entity to processInstanceInfo using hibernate Criteria. how I do it? because no entity relation between them and there is "long processInstanceId" instead "ProcessInstanceInfo processInstance"

      currently my Criteria is :

      Criteria crit = hSession.createCriteria(Task.class, "t")

                  .setProjection( Projections.projectionList()

                      .add( Projections.property("t.id"), "id" )

                      .add( Projections.property("t.taskData.processInstanceId"), "processInstanceId" )

                      .add( Projections.property("name.text"), "name" )

                      .add( Projections.property("subject.text"), "subject" )

                      .add( Projections.property("description.text"), "description" )

                      .add( Projections.property("t.taskData.status"), "status" )

                      .add( Projections.property("t.priority"), "priority" )

                      .add( Projections.property("t.taskData.skipable"), "skipable" )

                      .add( Projections.property("t.taskData.actualOwner"), "actualOwner" )

                      .add( Projections.property("t.taskData.createdBy"), "createdBy" )

                      .add( Projections.property("t.taskData.createdOn"), "createdOn" )

                      .add( Projections.property("t.taskData.activationTime"), "activationTime" )

                      .add( Projections.property("t.taskData.expirationTime"), "expirationTime" )

                      .add( Projections.property("t.taskData.processId"), "processId" )

                      .add( Projections.property("t.taskData.processSessionId"), "processSessionId" )

                  )

                  .setResultTransformer(Transformers.aliasToBean(TaskSummary.class))

                  .createAlias("t.taskData.createdBy", "createdBy", JoinType.LEFT_OUTER_JOIN)

                  .createAlias("t.taskData.actualOwner", "actualOwner", JoinType.LEFT_OUTER_JOIN)

                  .createAlias("t.subjects", "subject", JoinType.LEFT_OUTER_JOIN)

                  .createAlias("t.descriptions", "description", JoinType.LEFT_OUTER_JOIN)

                  .createAlias("t.names", "name", JoinType.LEFT_OUTER_JOIN)

                  .add( Restrictions.eq("t.taskData.actualOwner.id", userId) )

                  .add( Restrictions.in("t.taskData.status", status) )

                  .add( Restrictions.or(Restrictions.eq("name.language", language), Restrictions.sizeEq("t.names", 0)) )

                  .add( Restrictions.or(Restrictions.eq("subject.language", language), Restrictions.sizeEq("t.subjects", 0)) )

                  .add( Restrictions.or(Restrictions.eq("description.language", language), Restrictions.sizeEq("t.descriptions", 0)) )

                  .add( Restrictions.isNull("t.taskData.expirationTime") );