Hi!
First I apologize for my bad English.
I'm searching for a way to create filter-statements dynamically:
My table:
<class name="myPackage.Person" table="Person">
<id name="pid" type="int">
<column name="pid" />
<generator class="assigned" />
</id>
...
<set name="memos" cascade="all" lazy="true">
<key column="mpid"/>
<one-to-many class="myPackage.Memos"/>
<filter name="memoFilter" condition="mpid IN (
select anotherTable.AMTZ from anotherTable where :memoSearch)"/>
</set>
</class>
My first try:
The param "memoSearch" is a SQL-statement, which is build dynamically by the user of my application.
for Example:
memoSearch= "( anotherTable.FIELD_A = 'some' AND anotherTable.FIELD_B = 'thing' OR (anotherTable.FIELD_A='foo' AND ... )
I cannot call a simple "mpid IN :values" because I don't know anything about the structure of the search (ANDs/ORs, paranthesis).
But this fails as the parameter are injected as string parameters, so I get
... from anotherTable where ' ( anotherTable.FIELD_A = 'some' AND...)'
and so it won't be executed.
Any hints?
Thanks in advance,
gizeh
|