Throw an exception in mapper if no row is updated

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Throw an exception in mapper if no row is updated

Eugene Dzhurinsky
Hello!

For mapper interface, if it's method should update a row in the
database by primary key, I would like to receive an exception if no
row was updated - so key is missing in the database.

I know that I can verify number of updated rows, however I want to get
exceptions.

Is there anything to use in MyBatis for this?

Thanks!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Throw an exception in mapper if no row is updated

Clinton Begin
Administrator
No, you'd have to do that yourself.  You might be able to do it by writing an Executor or StatementHandler plugin.

http://www.mybatis.org/core/configuration.html#plugins

Cheers,
Clinton


On Tue, Jan 15, 2013 at 9:03 AM, jdevelop <[hidden email]> wrote:
Hello!

For mapper interface, if it's method should update a row in the
database by primary key, I would like to receive an exception if no
row was updated - so key is missing in the database.

I know that I can verify number of updated rows, however I want to get
exceptions.

Is there anything to use in MyBatis for this?

Thanks!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Throw an exception in mapper if no row is updated

Rob Sargent
Under what situations does your application have a (mapped) primary key
id which does not exist in the database.  Are you perhaps hitting a case
where the data is not different and no update is done?

cheers,
rjs


On 01/15/2013 09:59 AM, Clinton Begin wrote:

> No, you'd have to do that yourself.  You might be able to do it by
> writing an Executor or StatementHandler plugin.
>
> http://www.mybatis.org/core/configuration.html#plugins
>
> Cheers,
> Clinton
>
>
> On Tue, Jan 15, 2013 at 9:03 AM, jdevelop <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hello!
>
>     For mapper interface, if it's method should update a row in the
>     database by primary key, I would like to receive an exception if no
>     row was updated - so key is missing in the database.
>
>     I know that I can verify number of updated rows, however I want to get
>     exceptions.
>
>     Is there anything to use in MyBatis for this?
>
>     Thanks!
>
>

Loading...