You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Joram Barrez <jo...@gmail.com> on 2010/04/07 16:46:02 UTC

Dynamic table replacement possible in iBatis3 ?

Hi All,

I was wondering if this is possible with iBatis 3:

<select id="selectTableCount" parameterType="string" resultType="long" >
    select count(*) from ${tableName}
</select>

The problem is that the string ${tableName} is not replaced by the
parameter, leadin to a 'select count(*) from null' at runtime.
Am I doing something wrong here or is this feature not yet implemeted
(as it worked on iBatis2 according to Google)?


Regards,

Joram

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: Dynamic table replacement possible in iBatis3 ?

Posted by Nathan Maves <na...@gmail.com>.
this still works in IB3.

Give us more of your code to figure out where the issue really is.
Show us the full sqlmap/annotation as well as the calling method.

N

On Wed, Apr 7, 2010 at 8:46 AM, Joram Barrez <jo...@gmail.com> wrote:
> Hi All,
>
> I was wondering if this is possible with iBatis 3:
>
> <select id="selectTableCount" parameterType="string" resultType="long" >
>    select count(*) from ${tableName}
> </select>
>
> The problem is that the string ${tableName} is not replaced by the
> parameter, leadin to a 'select count(*) from null' at runtime.
> Am I doing something wrong here or is this feature not yet implemeted
> (as it worked on iBatis2 according to Google)?
>
>
> Regards,
>
> Joram
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: Dynamic table replacement possible in iBatis3 ?

Posted by François Schiettecatte <fs...@gmail.com>.
Nathan

Good point, I knew about it (and used it) but it slipped my mind.

Cheers

François

On Apr 8, 2010, at 11:39 AM, Nathan Maves wrote:

> You are only half correct.  The format that you just used as an
> example is only for parameters.  He is looking for the string
> substitution which also changed.
> 
> #{foo} == jdbc set parameter
> ${foo} == string substitution before the prepared statement
> 
> Nathan
> 
> 2010/4/7 François Schiettecatte <fs...@gmail.com>:
>> The format did change, here is the new format:
>> 
>>        <select id="selectCountBySourceKey" parameterType="String" resultType="Integer">
>> 
>>                /* contents.Content.selectCountBySourceKey */
>>                SELECT  COUNT(*)
>>                FROM    contents
>>                WHERE   source_key = #{value}
>> 
>>        </select>
>> 
>> 
>> François
>> 
>> On Apr 7, 2010, at 5:54 PM, Niels Beekman wrote:
>> 
>>> In iBATIS 2, you would use ${value}. Maybe this still holds for version 3?
>>> 
>>> Niels
>>> 
>>> On 7 April 2010 16:46, Joram Barrez <jo...@gmail.com> wrote:
>>> Hi All,
>>> 
>>> I was wondering if this is possible with iBatis 3:
>>> 
>>> <select id="selectTableCount" parameterType="string" resultType="long" >
>>>    select count(*) from ${tableName}
>>> </select>
>>> 
>>> The problem is that the string ${tableName} is not replaced by the
>>> parameter, leadin to a 'select count(*) from null' at runtime.
>>> Am I doing something wrong here or is this feature not yet implemeted
>>> (as it worked on iBatis2 according to Google)?
>>> 
>>> 
>>> Regards,
>>> 
>>> Joram
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>> 
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: Dynamic table replacement possible in iBatis3 ?

Posted by Nathan Maves <na...@gmail.com>.
You are only half correct.  The format that you just used as an
example is only for parameters.  He is looking for the string
substitution which also changed.

#{foo} == jdbc set parameter
${foo} == string substitution before the prepared statement

Nathan

2010/4/7 François Schiettecatte <fs...@gmail.com>:
> The format did change, here is the new format:
>
>        <select id="selectCountBySourceKey" parameterType="String" resultType="Integer">
>
>                /* contents.Content.selectCountBySourceKey */
>                SELECT  COUNT(*)
>                FROM    contents
>                WHERE   source_key = #{value}
>
>        </select>
>
>
> François
>
> On Apr 7, 2010, at 5:54 PM, Niels Beekman wrote:
>
>> In iBATIS 2, you would use ${value}. Maybe this still holds for version 3?
>>
>> Niels
>>
>> On 7 April 2010 16:46, Joram Barrez <jo...@gmail.com> wrote:
>> Hi All,
>>
>> I was wondering if this is possible with iBatis 3:
>>
>> <select id="selectTableCount" parameterType="string" resultType="long" >
>>    select count(*) from ${tableName}
>> </select>
>>
>> The problem is that the string ${tableName} is not replaced by the
>> parameter, leadin to a 'select count(*) from null' at runtime.
>> Am I doing something wrong here or is this feature not yet implemeted
>> (as it worked on iBatis2 according to Google)?
>>
>>
>> Regards,
>>
>> Joram
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: Dynamic table replacement possible in iBatis3 ?

Posted by François Schiettecatte <fs...@gmail.com>.
The format did change, here is the new format:

	<select id="selectCountBySourceKey" parameterType="String" resultType="Integer">

		/* contents.Content.selectCountBySourceKey */
		SELECT	COUNT(*)
		FROM	contents
		WHERE	source_key = #{value}

	</select>


François

On Apr 7, 2010, at 5:54 PM, Niels Beekman wrote:

> In iBATIS 2, you would use ${value}. Maybe this still holds for version 3?
> 
> Niels
> 
> On 7 April 2010 16:46, Joram Barrez <jo...@gmail.com> wrote:
> Hi All,
> 
> I was wondering if this is possible with iBatis 3:
> 
> <select id="selectTableCount" parameterType="string" resultType="long" >
>    select count(*) from ${tableName}
> </select>
> 
> The problem is that the string ${tableName} is not replaced by the
> parameter, leadin to a 'select count(*) from null' at runtime.
> Am I doing something wrong here or is this feature not yet implemeted
> (as it worked on iBatis2 according to Google)?
> 
> 
> Regards,
> 
> Joram
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: Dynamic table replacement possible in iBatis3 ?

Posted by Niels Beekman <n....@o3spaces.com>.
In iBATIS 2, you would use ${value}. Maybe this still holds for version 3?

Niels

On 7 April 2010 16:46, Joram Barrez <jo...@gmail.com> wrote:

> Hi All,
>
> I was wondering if this is possible with iBatis 3:
>
> <select id="selectTableCount" parameterType="string" resultType="long" >
>    select count(*) from ${tableName}
> </select>
>
> The problem is that the string ${tableName} is not replaced by the
> parameter, leadin to a 'select count(*) from null' at runtime.
> Am I doing something wrong here or is this feature not yet implemeted
> (as it worked on iBatis2 according to Google)?
>
>
> Regards,
>
> Joram
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>