I need to perform Filter & aggregration based on set of collections objects (whether they are linked to each other or not in hbm setting) such as flow below:
1. Process1 loads records from DB to memory (i.e. session.createCriteria(object.getClass()).list())
2. Process1 performs some filtering and pass to Process2
3. Process2 performs another set of filtering and aggregration and pass to process 3
4. and so on and so on, which can be dynamically configured throug a configuration file till the final result will be persistent back to DB.
I have thought of using declarative <filter> or Criteria in Hibernate, but as far as I know, both of this approach will not be able to address the requirement by considering such dynamic process that is declarative.
One feature that I can think of in Hibernate is: createFilter(), however always hit this weird problem :
"org.hibernate.QueryException: The collection was unreferenced"
A simple example:
<hibernate-mapping>
<class name="Person" table="person">
<id name="id" type="java.lang.Long">
<generator class="assigned"/>
</id>
<property name="name" type="string">
<column name="name" length="12" />
</property>
<property name="age" type="long">
<column name="age" />
</property>
<property name="city" type="string">
<column name="city"/>
</property>
</class>
</hibernate-mapping>
By following above mentioned flow:
1. List persons = session.createCriteria(person.getClass()).list(); --> succesfully loaded to memory
2. List results = session.createFilter(persons, " where this.age < 30").list; --> failed, error msg: "org.hibernate.QueryException: The collection was unreferenced""
anyone has solution for this ?
Looks like my resolution will have to use Hypersonic SQL which provide so called "query in memory" feature.
Thanks.
sunento
|