Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Mybatis-guice, configuring default exception type for @Transactional
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Stephane C.  
View profile  
 More options Jul 19 2012, 5:14 am
From: "Stephane C." <stefatw...@gmail.com>
Date: Thu, 19 Jul 2012 02:14:15 -0700 (PDT)
Local: Thurs, Jul 19 2012 5:14 am
Subject: Mybatis-guice, configuring default exception type for @Transactional

Hello,

I really appreciate the @Transactional annotation provided by mybatis-guice
(and by the way, thanks Simone for maintaining it over years).

@Transactional(
        executorType = ExecutorType.BATCH,
        isolation = Isolation.READ_UNCOMMITTED,
        rethrowExceptionsAs = MyDaoException.class,

However, I would like my service layer to use my own data access exception
class all the time so it would be great if I could define a default value
for rethrowExceptionAs in a single place instead of specifying it above
every method.
Looking at the source code, it does not seem possible at the moment but
maybe it's worth considering in a future release?

Best


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Poitras Christian  
View profile  
 More options Jul 19 2012, 10:48 am
From: Poitras Christian <Christian.Poit...@ircm.qc.ca>
Date: Thu, 19 Jul 2012 10:48:18 -0400
Local: Thurs, Jul 19 2012 10:48 am
Subject: RE: Mybatis-guice, configuring default exception type for @Transactional

Hi,

In such a case, it may be better to add an your own rethrow interceptor over @Transactional.
That way, you don’t have to modify every @Transactional annotations and it’s easier to maintain.

Christian

De : mybatis-user@googlegroups.com [mailto:mybatis-user@googlegroups.com] De la part de Stephane C.
Envoyé : July-19-12 5:14 AM
À : mybatis-user@googlegroups.com
Objet : Mybatis-guice, configuring default exception type for @Transactional

Hello,

I really appreciate the @Transactional annotation provided by mybatis-guice (and by the way, thanks Simone for maintaining it over years).

@Transactional(

        executorType = ExecutorType.BATCH,

        isolation = Isolation.READ_UNCOMMITTED,

        rethrowExceptionsAs = MyDaoException.class,
However, I would like my service layer to use my own data access exception class all the time so it would be great if I could define a default value for rethrowExceptionAs in a single place instead of specifying it above every method.
Looking at the source code, it does not seem possible at the moment but maybe it's worth considering in a future release?

Best


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Poitras Christian  
View profile  
 More options Jul 19 2012, 10:50 am
From: Poitras Christian <Christian.Poit...@ircm.qc.ca>
Date: Thu, 19 Jul 2012 10:50:39 -0400
Local: Thurs, Jul 19 2012 10:50 am
Subject: RE: Mybatis-guice, configuring default exception type for @Transactional

Sorry, I didn’t read your question correctly.

But my point is still valid. By using a custom interceptor you can handle the exception the way you like and MyBatis-Guice interceptor will still work its magic.

Christian

De : mybatis-user@googlegroups.com [mailto:mybatis-user@googlegroups.com] De la part de Poitras Christian
Envoyé : July-19-12 10:48 AM
À : 'mybatis-user@googlegroups.com'
Objet : RE: Mybatis-guice, configuring default exception type for @Transactional

Hi,

In such a case, it may be better to add an your own rethrow interceptor over @Transactional.
That way, you don’t have to modify every @Transactional annotations and it’s easier to maintain.

Christian

De : mybatis-user@googlegroups.com<mailto:mybatis-user@googlegroups.com> [mailto:mybatis-user@googlegroups.com] De la part de Stephane C.
Envoyé : July-19-12 5:14 AM
À : mybatis-user@googlegroups.com<mailto:mybatis-user@googlegroups.com>
Objet : Mybatis-guice, configuring default exception type for @Transactional

Hello,

I really appreciate the @Transactional annotation provided by mybatis-guice (and by the way, thanks Simone for maintaining it over years).

@Transactional(

        executorType = ExecutorType.BATCH,

        isolation = Isolation.READ_UNCOMMITTED,

        rethrowExceptionsAs = MyDaoException.class,
However, I would like my service layer to use my own data access exception class all the time so it would be great if I could define a default value for rethrowExceptionAs in a single place instead of specifying it above every method.
Looking at the source code, it does not seem possible at the moment but maybe it's worth considering in a future release?

Best


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simone Tripodi  
View profile  
 More options Jul 21 2012, 4:02 pm
From: Simone Tripodi <simonetrip...@apache.org>
Date: Sat, 21 Jul 2012 22:02:00 +0200
Subject: Re: Mybatis-guice, configuring default exception type for @Transactional
Hi Stephane,

> Looking at the source code, it does not seem possible at the moment but
> maybe it's worth considering in a future release?

I think it could be possible - can you feel me an issue as a reminder, please?
TIA!
-Simo

http://people.apache.org/~simonetripodi/
http://simonetripodi.livejournal.com/
http://twitter.com/simonetripodi
http://www.99soft.org/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephane C.  
View profile  
 More options Jul 25 2012, 3:22 am
From: "Stephane C." <stefatw...@gmail.com>
Date: Wed, 25 Jul 2012 00:22:51 -0700 (PDT)
Local: Wed, Jul 25 2012 3:22 am
Subject: Re: Mybatis-guice, configuring default exception type for @Transactional

Hello,

Thanks for your answer, I will have a look and investigate your solution
further.
I also thought there could be a way to achieve this kind of behavior using
annotation and interceptors, but for some reasons I am a bit shy when it
comes to AOP stuff.

Best


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Poitras Christian  
View profile   Translate to Translated (View Original)
 More options Jul 25 2012, 8:57 am
From: Poitras Christian <Christian.Poit...@ircm.qc.ca>
Date: Wed, 25 Jul 2012 08:57:11 -0400
Local: Wed, Jul 25 2012 8:57 am
Subject: RE: Mybatis-guice, configuring default exception type for @Transactional

I agree. Interceptors seems non-trivial at first and you may encounter some problems because it usually creates proxies.
But once you taste it, it becomes addictive!

The main thing you must keep in mind with MyBatis-Guice @Transactional is that the annotation will only work on methods that can be overridden by a subclass. So only use @Transactional on public or protected methods.
Don’t use @Transactional on private methods. That doesn’t work. I haven’t tested on package methods.

This also applies to any interceptor you use with Guice or Spring.

As an additional hint, remember that if you annotate an interface method but not its actual implementation, you will need to check for the annotation recursively one the parents. I doubt Guice will check parent annotations for you.

Christian

De : mybatis-user@googlegroups.com [mailto:mybatis-user@googlegroups.com] De la part de Stephane C.
Envoyé : July-25-12 3:23 AM
À : mybatis-user@googlegroups.com
Objet : Re: Mybatis-guice, configuring default exception type for @Transactional

Hello,

Thanks for your answer, I will have a look and investigate your solution further.
I also thought there could be a way to achieve this kind of behavior using annotation and interceptors, but for some reasons I am a bit shy when it comes to AOP stuff.

Best

On Thursday, July 19, 2012 4:50:39 PM UTC+2, christia...@ircm.qc.ca<mailto:christia...@ircm.qc.ca> wrote:
Sorry, I didn’t read your question correctly.

But my point is still valid. By using a custom interceptor you can handle the exception the way you like and MyBatis-Guice interceptor will still work its magic.

Christian

De : mybatis-user@googlegroups.com<mailto:mybatis-user@googlegroups.com> [mailto:mybatis-user@googlegroups.com<mailto:mybatis-user@googlegroups.com> ] De la part de Poitras Christian
Envoyé : July-19-12 10:48 AM
À : 'mybatis-user@googlegroups.com<mailto:mybatis-user@googlegroups.com>'
Objet : RE: Mybatis-guice, configuring default exception type for @Transactional

Hi,

In such a case, it may be better to add an your own rethrow interceptor over @Transactional.
That way, you don’t have to modify every @Transactional annotations and it’s easier to maintain.

Christian

De : mybatis-user@googlegroups.com<mailto:mybatis-user@googlegroups.com> [mailto:mybatis-user@googlegroups.com] De la part de Stephane C.
Envoyé : July-19-12 5:14 AM
À : mybatis-user@googlegroups.com<mailto:mybatis-user@googlegroups.com>
Objet : Mybatis-guice, configuring default exception type for @Transactional

Hello,

I really appreciate the @Transactional annotation provided by mybatis-guice (and by the way, thanks Simone for maintaining it over years).

@Transactional(

        executorType = ExecutorType.BATCH,

        isolation = Isolation.READ_UNCOMMITTED,

        rethrowExceptionsAs = MyDaoException.class,
However, I would like my service layer to use my own data access exception class all the time so it would be great if I could define a default value for rethrowExceptionAs in a single place instead of specifying it above every method.
Looking at the source code, it does not seem possible at the moment but maybe it's worth considering in a future release?

Best


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »