ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brandon Goodin <brandon.goo...@gmail.com>
Subject Re: Using constants in SQL statements
Date Tue, 07 Jun 2005 13:08:44 GMT
currently everything is setter/getter based. So, you would need to
provide a getter at minimum for your constant. We could discuss direct
access to public properties. I don't think that would be too
difficult. It might even be a cool idea to use an alias like daniel
discussed. However, it would require some discussion on how to resolve
potential name conflicts. If you define 'myObject' as an alias to a
constant class and then in your mapped statement you had a 'myObject'
property on the parameterClass... how would you distinguish between
the myObject alias and the myObject property?

Ex.

<typeAlias name="myObject" type="my.super.cool.MyObject"/>

<select id="myCoolSelect" parameterClass="SomeClass">
SELECT ... 
WHERE id=#myObject.aProperty# <-- how would we resolve this?
</select>

We might have to introduce a notation to define when an alias is being used.
Something like #@myObject.constant# for accessing an alias.

Just some thoughts for discussion.

Anyway, can someone add this stuff to JIRA.We should have this
discussion over there.

Brandon

On 6/7/05, Daniel Henrique Ferreira e Silva <dhsilva@gmail.com> wrote:
> 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