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 19:43:26 GMT
I would never connect any ugliness with iBATIS. This is Java hard-coded 
sql, which I see ugly. I have yet one question (please don't be nervous 
;)) - do you think that nested loops (that would solve my problem) 
should be added to iBATIS sqlmap. If yes I am eager to look at this 
deeper, and try to write it down

Best Regards,
Michał Małecki

Clinton Begin wrote:
> Personally, I don't think that ugliness has  anything to do with
> iBATIS.  It has to do with the fact that you're trying to merge two
> dynamic SQL generation paradigms.  I'd suggest that if iBATIS Dynamic
> SQL isn't capable of _completely_ expressing your SQL and it's
> conditional parts, then just use Java entirely for that part.  Don't
> try to generate half of it in Java and the other half in iBATIS.
> 
> Cheers,
> Clinton
> 
> 
> On Tue, 4 Jan 2005 10:17:51 +0100, Michał Małecki
> <misiek_x@poczta.onet.pl> wrote:
> 
>>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