ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niels Beekman" <n.beek...@wis.nl>
Subject RE: How to not verbosely declare resultmaps?
Date Tue, 20 Dec 2005 16:24:14 GMT
$-s are for SQL injection weren't they :-)

!-s can be used as operators (SELECT * FROM bla WHERE foo != 'bar')

"-s can be used to delimit strings, so this would require old uses of "
to be escaped (am I right?)

|-s can be used as string concatenator

 

So the only viable option left is @ I believe, which, as you were
saying, looks more like a parameter...

Or maybe use {NAME:VARCHAR} ?

 

Niels

 

________________________________

From: Clinton Begin [mailto:clinton.begin@gmail.com] 
Sent: dinsdag 20 december 2005 16:14
To: user-java@ibatis.apache.org
Subject: Re: How to not verbosely declare resultmaps?

 


I would love to add inline result map support.  :-)

Unfortunately you and I are the minority.  But that doesn't mean we
cannot do it.  So, my question to you is:  how would you like to see the
syntax?

Here are some options:

$NAME:VARCHAR$
!NAME:VARCHAR!
@NAME:VARCHAR@
"NAME:VARCHAR"
|NAME:VARCHAR|   << I like the pipes, but does anyone know of any
potential issues with using it?  

In hindsight, I wish I had used @@ for inline parameters and ## for
inline result maps (because it looks like a little row set!).  

Cheers,
Clinton




On 12/19/05, Yusuf <Yusuf@ekalife.co.id> wrote:

Dear All,
I've been using ibatis for about 1 year now, and i'm very satisfied with
it!
I wanted to ask if i can do this:

<select id="elions.uw.selectInfoProductInsured" resultClass="map"> 
SELECT name, age, address, income
  FROM person
</select>

but I wanted the default datatype for NAME is String, AGE is
Integer, and INCOME is Double, not the default BigDecimal..
without specifying resultMaps or resultClasses (because i have so many 
queries like this and it would be very verbose to declare them one by
one)

I know we can declare something like this in insert statements like

<insert id="..">
INSERT INTO person (name, age) VALUES (#name:VARCHAR:-#, #age:NUMBER:0#)

</insert>

but can it be done in select statements to in ibatis? for example like
this maybe:

<select id="elions.uw.selectInfoProductInsured" resultClass="map">
SELECT name:String, age:Integer, address:String, income:Double 
  FROM person
</select>

Thank you...

 


Mime
View raw message