ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Iwao AVE! <haraw...@gmail.com>
Subject Re: Ibator: disable aliases for update and delete statements?
Date Sun, 09 Aug 2009 17:25:42 GMT
I actually have experienced a similar problem with MySql; the  
deleteByExample results in an syntax error when 'alias' is specified.
Fortunately, there was an easy workaround that allows me to use alias  
in DELETE statement and I could write a plugin to tweak Ibator's  
default syntax.

http://harawata.blogspot.com/2009/04/ibators-deletebyexample-and-mysql.html

--
I cannot confirm this, but is the following syntax valid in SQL Server?
If so, writing a simple plugin could be a solution for deleteByExample.

DELETE u FROM User AS u
WHERE u.xxx = ...

Regards,
Iwao

On 2009/08/10, at 1:12, Jeff Butler <jeffgbutler@gmail.com> wrote:

> There's no support for this in Ibator now.  It will take a rewrite of
> the example class generator at the very least - with support from new
> SQL element generators too.
>
> It also presents a bit of a usage problem for the iBATIS3 interface
> mapper generator.  I haven't released this yet, but will soon.
>
> So I'll have to think about this for a bit to come up with the best
> way to deal with it.
>
> Don't you love how "standard" SQL is?  I've never run into this in all
> my testing, but I don't test with SQL Server regularly.  No problems
> in MySql, HSQLDB, DB2, and (I think) PostgreSQL.
>
> Jeff Butler
>
>
>
> On Sun, Aug 9, 2009 at 10:11 AM, Chad McHenry<mchenryc@gmail.com>  
> wrote:
>> Using SQL Server, I get syntax errors from Ibator generated  
>> deleteByExample
>> and updateByExample* for tables which I give an alias.
>> Neither deleteByPrimaryKey, updateByPrimaryKey, nor
>> updateByPrimaryKeySelective use of the alias, and work, but  
>> deleteByExample,
>> updateByExample, and updateByExampleSelective use the alias, and  
>> fail.
>> I don't see a way to disable alias use in just the '*ByExample*'  
>> statements
>> without creating "Example_Where_Clause_Without_Aliases" sql  
>> fragment, and
>> using that instead of the "Example_Where_Clause", but that would  
>> take a lot
>> of rewriting of the auto generated stuff or an Ibator plugin.
>> Any suggestions?
>>    <table tableName="user" alias="u" delimitIdentifiers="true" />
>>
>> generates:
>>  <delete id="ibatorgenerated_deleteByPrimaryKey"
>> parameterClass="model.User">
>>    <!--
>>      WARNING - This element is automatically generated by Apache  
>> iBATIS
>> ibator, do not modify.
>>    -->
>>    delete from "user"
>>    where id = #id:VARCHAR#
>>  </delete>
>>  <delete id="ibatorgenerated_deleteByExample"
>> parameterClass="model.UserExample">
>>    <!--
>>      WARNING - This element is automatically generated by Apache  
>> iBATIS
>> ibator, do not modify.
>>    -->
>>    delete "user" from "user" u
>>    <include refid="user.ibatorgenerated_Example_Where_Clause" />
>>  </delete>
>> deleteByPrimaryKey works fine, but deleteByExample fails with bad- 
>> syntax
>> error, due to the aliases which SQLServer 2005 does not like in  
>> delete or
>> update statements.
>>
>>
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message