No, you aren't misunderstanding the requirement. That's a good suggestion, I might do something like that. I suppose I could use my introspection approach in a similar utility method to put my objects properties at the "top level" of the map. -Jonathan

Niels Beekman wrote:
Hi,

Before doing AOP or hardcoded proxy stuff, if there's just a few queries
that need the date passed in you could get away with just a utility
method. It takes the original parameter object, creates a map and stores
the parameter object under a fixed key "parameter" and the current date
under key "currentDate". The query could then access #currentDate# and
#parameter.whatEverProperty#. Calls are then simply as follows:

String myOwnParam = "someValue";
queryForList("myQuery", wrapWithCurrDate(myOwnParam));

myQuery (parameterClass=java.util.Map):

[SELECT * FROM foo WHERE start_time <= #currentDate# AND other_col =
#parameter#]

Or if you find #parameter# to be non-descriptive, use an overloaded
wrapWithCurrDate that takes a String, which you then use as key in the
map.

Does this make any sense at all, or am I misunderstanding your
requirements?

Niels

-----Original Message-----
From: Jonathan Slate [mailto:[EMAIL PROTECTED] Sent: Friday, August 22, 2008 7:28 PM
To: [email protected]
Subject: Re: passing in java date

Hehehe! Well, yeah, you are probably right. I have no specific love for the Java date APIs. It's just that I want my application logic to be in one place, in the application layer. But maybe I should just let go of that hangup...

On the other hand, I did look some more into how I'd do the proxy thing.

I think I could could provide before advice to all the methods in SqlCleintMap that take a parameter object, and swap out that object for a map, using the handy com.ibatis.common.beans.ClassInfo class to get the readable properties from the parameter object and set entries in the

map. Then I could also add additional entries in the map, like the current date. Or does that sound like an LSD-induced nightmare? ;)

-Jonathan


Larry Meadors wrote:
Really? Man, I think the Java date APIs suck worse than any SQL
dialect ever conceived. :-)

It's like they were created by a mad man after a vision he had in a
LSD-induced nightmare where colors tasted like music.

Larry


On Fri, Aug 22, 2008 at 9:20 AM, Jonathan Slate <[EMAIL PROTECTED]>
wrote:
I can. I'd just prefer to work with Java dates. If it is really
INSERT INTO
foo (time, value) values ([six days from now at midnight], 'bar') I'd
rather
be figuring out the time using Java rather than coding "six days from
now at
midnight" in SQL. (Clearly I do have options here, I'm just looking
for the
one that is the most straightforward to implement and maintain.)

-Jonathan

Reply via email to