Hi Lukas - 
Unfortunately, implementing an exception translator didn't resolve the 
issue.
Or perhaps I did something wrong.

I implemented the following exception translator... 

package com.sm.gis.gdm;

import org.jooq.ExecuteContext;
import org.jooq.SQLDialect;
import org.jooq.impl.DefaultExecuteListener;

import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator;
import org.springframework.jdbc.support.SQLExceptionTranslator;
import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator;

public class JooqToSpringExceptionTransformer extends 
DefaultExecuteListener {
    
    private static final long serialVersionUID = 1L;

    @Override
    public void exception(ExecuteContext ctx) {

        if (ctx.sqlException() != null) {
            SQLDialect dialect = ctx.configuration().dialect();
            SQLExceptionTranslator translator = null;
            if ( dialect != null ) {
                translator = new 
SQLErrorCodeSQLExceptionTranslator(dialect.name());
            } else {
                translator = new SQLStateSQLExceptionTranslator();
            }
            ctx.exception(translator.translate("jOOQ", ctx.sql(), 
ctx.sqlException()));
        }
    }
    
}


    @Bean
    DSLContext dslContext() throws Exception {
        DefaultConfiguration jooqConfiguration = new DefaultConfiguration();
        jooqConfiguration.set(SQLDialect.POSTGRES_9_4);
        jooqConfiguration.set(atomikosJdbcConnectionFactory());
        jooqConfiguration.set(new DefaultExecuteListenerProvider(new 
JooqToSpringExceptionTransformer()));
        DSLContext dslContext = new DefaultDSLContext(jooqConfiguration);
        return dslContext;
    }

I can see the exception is translated...

    at 
org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:102)
    at 
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
    at 
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
    at 
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
    at 
com.sm.gis.gdm.JooqToSpringExceptionTransformer.exception(JooqToSpringExceptionTransformer.java:26)
    at org.jooq.impl.ExecuteListeners.exception(ExecuteListeners.java:246)
    at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:357)
    at 
org.jooq.impl.AbstractDelegatingQuery.execute(AbstractDelegatingQuery.java:133)
    at 
com.sm.gis.gdm.kernel.Kernel.receiveCreateGenomicTestOrderInGIS(Kernel.java:932)
    at com.sm.gis.gdm.sports.PortSIQueue.onMessage(PortSIQueue.java:53)


If I can, I'd prefer to wait for official release of spring boot 1.3. 
Of course, I'll try 1.3, if you think that is my best bet.
I did upgrade from spring-boot 1.2.5.RELEASE to spring-boot 1.2.6.RELEASE.
The upgrade to 1.2.6 had no effect.

I do appreciate the help.
Any other insights or suggestions?

Thanks,
Jim


On Tuesday, September 29, 2015 at 4:03:28 AM UTC-4, Lukas Eder wrote:
>
> Hi Jim,
>
> Yes - there's an example here:
>
> https://github.com/jOOQ/jOOQ/blob/version-3.6.0-branch/jOOQ-examples/jOOQ-spring-example/src/main/java/org/jooq/example/spring/exception/ExceptionTranslator.java
>
> Spring Boot 1.3 also works with jOOQ out of the box - perhaps that might 
> be an alternative way to go:
>
> http://docs.spring.io/spring-boot/docs/1.3.0.M5/reference/html/boot-features-jooq.html
>
> Hope this helps.
> Let us know if you run into any further issues.
>
> 2015-09-28 18:58 GMT+02:00 <[email protected] <javascript:>>:
>
>> Hi Lukas - 
>> Hmmm. I did not implement an exception translator. 
>> Perhaps that's the key point I missed.
>> I presume I'm currently using using the default behavior.
>> Sounds like I should have implemented an exception translator, is that 
>> correct?
>> Thanks,
>> Jim
>>
>>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to