ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Henrique Ferreira e Silva <dhsi...@gmail.com>
Subject Re: Using constants in SQL statements
Date Tue, 07 Jun 2005 12:41:09 GMT
Hi,

I may be saying something really stupid but, well, progress comes
along with a lot of stupid questions :)

Let's suppose you have a class or interface loaded with plenty of
constants. If i create a type alias for that, can i use it in my sql
maps using the dot notation?

For instance:


public class MyConstants {

    public static String CONSTANT_1 = "blah";
    public static String CONSTANT_2 = "blah2";

}


In my sql maps i'd have a type alias for that class:

<typeAlias name="constants" type="MyConstants"/>

And in any sql map something like that:

<select ....>
  select * from foo where blah = #constants.CONSTANT_1#
</select>


Is that possible?

If not, how hard would be to implement it by creating an import
attribute for maps, for example?

So we would have:

<select  parameterMap="x" import="MyConstants">
   ... use MyConstants properties in here
</select>

And, inspired by all the sci-fi i had watched, maybe this import
attribute would allow me to even call static methods on those classes.

Opinions? Am I on crack?

Cheers,
Daniel Silva.



  





On 6/7/05, Clinton Begin <clinton.begin@gmail.com> wrote:
> 
>  It's not supported at this time.  But feel free to add a JIRA request.  It
> probably wouldn't be hard.
>  
>  Clinton
> 
>  
> 
> On 6/7/05, ONeill, Niall <Niall.ONeill@agriculture.gov.ie> wrote:
> > Hi,
> > 
> > Is there a way in iBATIS to use static Java fields within SQL statements?
> Currently I am having to hard-code static values in the statements, but this
> presents problems if those values ever change and make it difficult to
> understand the SQL.
> > 
> > Regards,
> > Niall O'Neill
> > 
> > 
> >
> **********************************************************************
> > ***********  Department of Agriculture and Food ***************
> > 
> > The information contained in this email and in any
> > attachments is confidential and is designated solely
> > for the attention and use of the intended recipient(s).
> > This information may be subject to legal and professional 
> > privilege.  If you are not an intended recipient of
> > this email, you must not use, disclose, copy,
> > distribute or retain this message or any part of it.
> > If you have received this email in error, please
> > notify the sender immediately and delete all copies of 
> > this email from your computer system(s).
> >
> **********************************************************************
> > 
> > 
> 
>

Mime
View raw message