ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew McDougall <macdo...@swbell.net>
Subject Fw: Having an architectural issue need some ideas
Date Thu, 22 Mar 2007 14:12:55 GMT
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?


----- 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.
        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);
public buildWhereClause(Vector vector){
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.
    getSqlMapClientTemplate().insert("insertWhereClause", ????);
resultMap (didn't include)
<insert "insertWhereClause">
     insert into tableA (a , b, c., d, e, f) values (#a#, #b#, #c#, #d#, #e#, #f#)
So how can I do this?
View raw message