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 16:45:41 GMT

Yes unfortunately this setup is wacked! But I unfortunately have to work with
it. You should've seen the endless lines of string building of sql that was
in the previous code. They had soooooo much in the code it made the code a
nightmere to follow plus the previous dev didn't believe in writting a
method for certain pieces just one big class with one method and a bunch of
if else statements. Anyway I started from scratch and have rebuilt this
monster and now I'm at the point of trying to the string building sql that
they did in the code in the mapped statement if I can just figure out how. I
would never have set it up like this either but my problem is I have rules
27 of them for each group, each group is contained within a cell.So I might
not have all 27 rules for each group and I might only have 1 group! The
other issue is that each group is either an INTERSECT or a UNION of each
other depending on what is selected so this really makes it difficult.

Brandon Goodin wrote:
> 
> I would say dynamic SQL is your best option. The task that you are looking
> to accomplish seems a bit bewildering and there are little alarms going
> off
> in my mind that make me question whether you are making the whole insert
> process more complicated than it needs to be. However, I know there are
> some
> wild requirements out there and I'll assume that what you are trying to do
> is necessary. Since you are already studying whether dynamic SQL is the
> best
> option, I don't think there is anymore i can add.
> 
> Brandon
> 
> On 3/22/07, macdoug1 <macdoug1@swbell.net> wrote:
>>
>>
>> Yes, mapped statement. I want to build a giant subquery that depends on
>> how
>> many groups I have. So if I have one group I get the list of rules for it
>> (could be 27 of them) each of these are in an object which I then thought
>> I'd put them in a vector to pass to the mapped statement.But then I was
>> unsure of how to get them out since each object has the same fields in it
>> but different data (meaning different set of rules). So I need to build
>> the
>> subquery's where clause with these and going back to the beginning here
>> if
>> there is more then one group I could have multiple groups with multiple
>> rules and each group if it exists needs to be either a UNION or
>> INTERSECT.
>> Does that help any?
>>
>> Andrew
>>
>> Brandon Goodin wrote:
>> >
>> > You are making some statements that i don't quite understand. You keep
>> > saying "xml properties". Are you talking about your mapped statement
>> > configurations? Also, you are not clearly describing your issue. I'm
>> left
>> > wondering what you expect your SQL to look like in the end and how you
>> > want
>> > the vector rule objects to affect that outcome.
>> >
>> > Brandon
>> >
>> > On 3/22/07, macdoug1 <macdoug1@swbell.net> wrote:
>> >>
>> >>
>> >> 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.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Fw%3A-Having-an-architectural-issue-need-some-ideas-tf3447797.html#a9618317
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

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


Mime
View raw message