ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Kratz" <jason.kr...@firm58.com>
Subject RE: Save Generated WHERE Clause
Date Mon, 25 Feb 2008 20:28:52 GMT
Of course you'd also have to ask how likely is a DB vendor switch?  I hear
that argument a lot (don't use feature X..you might want to switch databases
some day!) and have yet to hear of many cases where a DB vendor switch
actually happened.




From: Ryan Shelley [mailto:12gaugemedia@gmail.com] 
Sent: Monday, February 25, 2008 2:26 PM
To: user-java@ibatis.apache.org
Subject: Re: Save Generated WHERE Clause


Well, if I serialize the Example class, then changing the db vendor isn't an
issue, but it's a very good point if I decided to save the actual built SQL


On Mon, Feb 25, 2008 at 11:13 AM, Nathan Maves <nathan.maves@gmail.com>

not to rain on the parade but I think the idea of storing sql would be a bad
thing.  Just imagine the amount of work in the event of a DB vendor
switch.... ouch

I would say think outside the box and find a different solution to storing
the save criteria.  Even the idea of serializing the Java class gives me


On Mon, Feb 25, 2008 at 11:27 AM, Ryan Shelley <12gaugemedia@gmail.com>

You're correct about the Abator example class.  The idea is that there will
be records in the database that my users want to extract based upon their
own criteria.  I can allow them to filter dynamically based upon the Example
classes, however, if they want to save that filter for later (since they can
be complex), I'd like to store it in the database.  Since the values of the
filter don't change, I don't see a problem with saving the Example class.  I
did figure out that I could serialize the Example class and store that in
the database, and unserialize it when I want to use it, so that is probably
the best option for now.


On Mon, Feb 25, 2008 at 8:49 AM, Jeff Butler <jeffgbutler@gmail.com> wrote:

I assume you are talking about the Abator example classes.  But this isn't
exactly an Abator issue.


iBATIS dynamic SQL is resolved at run time based on the values in the
parameter object - so you'd need to capture the SQL after the resolution
step and save it somewhere.  You could probably do this by tinkering with
iBATIS internals, but the easiest way to do it would be to create a custom
logger and grab the SQL from the log.


Another alternative would be to serialize the example class as you've
suggested - but this doesn't save the SQL, it only saves the values in the
example class - which would generate the same SQL on reuse.


Is this some kind of a user preference or user history thing?


Jeff Butler





On Sun, Feb 24, 2008 at 4:02 PM, Ryan Shelley <12gaugemedia@gmail.com>

I'd like to be able to save the WHERE clause generated by the Example
classes in a database.  The purpose is so that I can allow users to create
custom filters which distill down to SQL criteria, and then save them for
re-use later.  I'm curious if anyone else has had a similar requirement, and
whether they attempted to serialize the Example object to XML, or if they
attempted to capture the generated SQL in another SQL statement.  Any
thoughts?  Thanks!






View raw message