ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michał Małecki <misie...@poczta.onet.pl>
Subject Re: nested javabeans properties
Date Tue, 04 Jan 2005 09:17:51 GMT
Hello Brandon,
here is my detailed query:
<select id="selectEvents" parameterClass="ListOfConditions"
resultClass="LoggingBean"><![CDATA[
select le_level as level, le_location as location, le_logger as logger,
le_message as message,
le_ndc as ndc, le_thread as thread, le_throwable as throwable, le_timestamp
as timeStampAsDate
from log_events
where
]]>
<iterate conjunction="OR" property="list" open="(" close=")">
<![CDATA[
(#list[].level# = -1 OR #list[].level# $list[].levelOperator$ le_level)
AND (#list[].logger# = '' OR le_logger LIKE #list[].logger#)
AND (#list[].timestampSeconds# = -1 OR #list[].timestampSeconds#
$list[].timestampOperator$ (extract(epoch from le_timestamp)::integer))
$list[].attributesSubQuery$
]]> </iterate>
as you see, at the end there is $list[].attributesSubQuery$, which is
subqueries generated in Java, like this:
for (Iterator it = attributes.iterator(); it.hasNext();) {
            KeyValue kv = (KeyValue) it.next();
            sb
                    .append(" AND EXISTS (select 1 from
log_event_attributes")
                    .append(" where lea_event = le_id")
                    .append(" and lea_value LIKE '")
                    .append(kv.getValue())
                    .append(
                            "' and lea_key = (select lk_id from log_keys
where lk_name='")
                    .append(kv.getKey()).append("')) ");
        }

So, is this possible to express everthing in ibatis xml, without this dirty
$list[].attributesSubQuery$?

Michał Małecki

----- Original Message ----- 
From: "Brandon Goodin" <brandon.goodin@gmail.com>
To: <ibatis-user-java@incubator.apache.org>
Sent: Saturday, January 01, 2005 8:41 PM
Subject: Re: nested javabeans properties


have you looked into the isPresent, isEqual, isNotEqual,etc.. tags
yet? Otherwise, you will need to be more specific. It is difficult to
help out with ambiquous scenarios in dynasql.

Brandon


On Fri, 31 Dec 2004 12:35:14 +0100, Michał Małecki
<Michal.Malecki@man.poznan.pl> wrote:
> Hello Clinton,
>
> I have class Condition {
>         int timestamp;
>         Vector attributes; //Vector of key-value class
>         int level;
>         /* constructors, getters, setters, etc*/
> }
> I would like to pass List of condition objects, and to generate
> following query
> select .....
> from log_events
> where (
>         --first Condition object
>         conditions for timestamp and level
>         multiple subqueries for each element of attributes Vector
>
> ) OR (
>         --second Condition object
>         conditions for timestamp and level
>         multiple subqueries for each element of attributes Vector
> ).....
> So I have to use first iterate element for the big condition (connected
> using OR) and nested iterate for all subqueries built using "attribute"
> Vector; How can this be done??
>
> Michał
>
> Clinton Begin wrote:
> > Hi Michal,
> >
> >
> >>is it planned to add support for nested javabeans properties, also
> >>collections?
> >
> >
> > iBATIS supports both of these already.  I don't understand enough
> > about what you're asking to know how to help you.  Can you provide
> > some code examples?
> >
> > Clinton
> >
>
>
>



Mime
View raw message