ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From macdoug1 <macdo...@swbell.net>
Subject Re: Fw: Having an architectural issue need some ideas
Date Thu, 22 Mar 2007 15:33:00 GMT

I've looked at it and I don't see anything in there that shows or speaks of
handing in more then one object to use in building the dynamic sql. I
actually included the wrong sql statement I was in a hurry and put the wrong
one in. Anyway the actual statement needs to be an insert with a bunch of
subqueries inside of it and the subqueries are select statements in which
the where clause is built dynamically and depending on how many objects I
have from each group mentioned below will determine how many subqueries will
be made.Those fields mentioned are the fields that contain the data that is
critical in building each where clause in each subquery.


Larry Meadors-2 wrote:
> 
> Take a look in the developers guide at dynamic SQL:
> 
> http://ibatis.apache.org/javadownloads.cgi
> 
> Larry
> 
> 
> On 3/22/07, Andrew McDougall <macdoug1@swbell.net> wrote:
>>
>> My question is below that I sent yesterday but didn't register first. Is
>> there any chance that I can get some ideas on this issue I have below?
>>
>> Thanks.
>> Andrew
>>
>>
>> ----- Forwarded Message ----
>> From: Andrew McDougall <macdoug1@swbell.net>
>> To: user-java@ibatis.apache.org
>> Sent: Wednesday, March 21, 2007 11:23:54 PM
>> Subject: Having an architectural issue need some ideas
>>
>>
>>
>> To whom it may concern,
>>
>>     I'm writting an application using iBatis and it has been really
>> excellent so far but now I'm stuck on how to get this last part to work!
>> Anyway here's my situation; I have a Vector of objects contained in it
>> and I
>> pass that into my DAOImpl and this is where I'd normally just pass the
>> object into the queryForList, update,insert methods along with the name
>> of
>> the sql to call in the xml properties file. But in this case I have
>> multiple
>> objects that have the same fields being populated in each object and I
>> need
>> to be able to take these fields and pass them into the xml properties
>> file
>> where they are used in the sql statements as the values passed in. At
>> this
>> point I also need to be able to build dynamic statement in the sql based
>> on
>> if there are values in these fields. So potentially I could have a huge
>> select statement or just a very short one depending on the data passed in
>> those objects.
>>
>> For example:
>> Vector vector = new Vector();
>>  Rule rule;
>>
>> Iterator itr = rgplist.iterator();
>>
>> //Have the group(s). Now need to get the set of rules for each group.
>>
>> while(itr.hasNext()){
>>
>>         grp = (Groups)itr.next();
>>
>>         //Get the rules for each group and put it in a list
>>
>>         ruleslst = getRules(grp);
>>
>>         for(int i = 0; i < ruleslst.size(); i++){
>>
>>                 rule = (Rule)  vector.get(i);
>>
>>                 vector.add(rule);
>>
>>          }
>>
>> }
>>
>>
>>
>> buildWhereClause(vector);
>>
>>
>>
>> public buildWhereClause(Vector vector){
>>
>>     mtf.insertWhereCluase(vector);
>>
>> }
>>
>>
>>
>> DAOImpl
>>
>> Rule rule;
>>
>> public void insertWhereClause(Vector vector){
>>
>>     for(int i=0;i<vector.size();i++){
>>
>>         rule = (Rule)vector.get(i);
>>
>>
>>
>>         //These are the fields that I need to pass in from the object
>> depending on how many are in the vector.
>>
>>         //these same fields can be just one or many but I don't want to
>> overwrite the fields on each iteration.
>>
>>         rule.getCellId();
>>
>>         rule.getCellRuleID();
>>
>>         rule.getCellTypeID();
>>
>>         rule.getCellTypeRuleGrp();
>>
>>         rule.getNam();
>>
>>         rule.getCd();
>>
>>
>>
>>     }
>>
>>     getSqlMapClientTemplate().insert("insertWhereClause",
>> ????);
>>
>> }
>>
>>
>>
>>
>>
>> Cell.xml
>>
>> resultMap (didn't include)
>>
>>
>>
>> <insert "insertWhereClause">
>>
>>      insert into tableA (a , b, c., d, e, f) values (#a#, #b#, #c#, #d#,
>> #e#, #f#)
>>
>> </insert>
>>
>>
>>
>>
>>
>> So how can I do this?
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Fw%3A-Having-an-architectural-issue-need-some-ideas-tf3447797.html#a9617313
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Mime
View raw message