Hello,
well thanks for your reply.
The main difficulty in my code is that the front-end can select as many filter 
as he wish....or maybe even none.
In plain SQL you have to build SQL dynamically checking if the filter was set 
then you add "AND param = :parameter". 

Anyway I just managed to run it:

Here's the TaskInstance with one filter in it:

<?xml version="1.0"?>
  | 
  | <!DOCTYPE hibernate-mapping PUBLIC
  |     "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
  |     "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd";>
  | 
  | <hibernate-mapping auto-import="false" default-access="field">
  | 
  |   <class name="org.jbpm.taskmgmt.exe.TaskInstance" 
  |          table="JBPM_TASKINSTANCE"
  |          discriminator-value="T">
  |     <id name="id" column="ID_"><generator class="native" /></id>
  |     <discriminator type="char" column="CLASS_"/>
  |     <version name="version" column="VERSION_" />
  |   
  |     <property name="name"         column="NAME_" />
  |     <property name="description"  column="DESCRIPTION_" length="4000">
  |       <type name="string_max">
  |         <param name="length">4000</param>
  |       </type> 
  |     </property>
  |     <property name="actorId"      column="ACTORID_" 
index="IDX_TASK_ACTORID"/>
  |     <property name="create"       column="CREATE_" />
  |     <property name="start"        column="START_" />
  |     <property name="end"          column="END_" />
  |     <property name="dueDate"      column="DUEDATE_" />
  |     <property name="priority"     column="PRIORITY_" />
  |     <property name="isCancelled"  column="ISCANCELLED_" />
  |     <property name="isSuspended"  column="ISSUSPENDED_" />
  |     <property name="isOpen"       column="ISOPEN_" />
  |     <property name="isSignalling" column="ISSIGNALLING_" />
  |     <property name="isBlocking"   column="ISBLOCKING_" />
  |     
  |     
  |     
  |     <many-to-one name="task"
  |                  column="TASK_"
  |                  foreign-key="FK_TASKINST_TASK"
  |                  index="IDX_TASKINST_TSK"/>
  |     <many-to-one name="token"
  |                  column="TOKEN_" 
  |                  foreign-key="FK_TASKINST_TOKEN"
  |                  index="IDX_TASKINST_TOKN"/>
  |     <many-to-one name="processInstance"
  |                  column="PROCINST_"
  |                  foreign-key="FK_TSKINS_PRCINS"
  |                  index="IDX_TASKINST_TSK"/>
  |     <many-to-one name="swimlaneInstance" 
  |                  column="SWIMLANINSTANCE_" 
  |                  foreign-key="FK_TASKINST_SLINST"
  |                  index="IDX_TSKINST_SLINST" />
  |     <many-to-one name="taskMgmtInstance" 
  |                  column="TASKMGMTINSTANCE_" 
  |                  foreign-key="FK_TASKINST_TMINST"
  |                  index="IDX_TSKINST_TMINST"/>
  | 
  |     <map name="variableInstances" cascade="all">
  |       <key column="TASKINSTANCE_" foreign-key="FK_VAR_TSKINST"/>
  |       <index type="string" column="NAME_" />
  |       <one-to-many class="org.jbpm.context.exe.VariableInstance" />
  |     </map>
  |     <set name="pooledActors" 
  |          cascade="all"
  |          table="JBPM_TASKACTORPOOL">
  |       <key column="TASKINSTANCE_" foreign-key="FK_TASKACTPL_TSKI"/>
  |       <many-to-many class="org.jbpm.taskmgmt.exe.PooledActor" 
column="POOLEDACTOR_" />
  |     </set>
  |     <list name="comments" cascade="all" >
  |       <key column="TASKINSTANCE_" />
  |       <index column="TASKINSTANCEINDEX_" />
  |       <one-to-many class="org.jbpm.graph.exe.Comment" />
  |     </list>
  |     
  |     <filter name="activatedFilter" condition=":activatedParam = NAME_"/>
  |     
  |   </class>
  |   
  | <filter-def name="activatedFilter">
  |     <filter-param name="activatedParam" type="string"/>
  |   </filter-def>
  | 
  | </hibernate-mapping>

I have replaced the file in the jbpm-jpdl.jar and then from my Servlet:

ArrayList array = new ArrayList();
  |             JbpmConfiguration jbpmConfiguration = 
JbpmConfiguration.getInstance();
  |             JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
  | 
  |     Session session = jbpmContext.getSession();
  |     session.enableFilter("activatedFilter").setParameter("activatedParam", 
"TaskRisolta");
  |     String sqlParent = "from  org.jbpm.taskmgmt.exe.TaskInstance";
  | 
  | 
  |     Query queryParent = session.createQuery(sqlParent);
  | 
  | 
  |     List list = queryParent.list();
In this example I'm using a filter on the TaskName, now I need to add also 
filter for all other columns.

A bit tough but I managed to do it !
Thanks
Francesco

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4150392#4150392

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4150392
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to