Last active
          April 11, 2020 19:05 
        
      - 
      
- 
        Save azell/5655888 to your computer and use it in GitHub Desktop. 
Revisions
- 
        azell renamed this gist Oct 9, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewingFile renamed without changes.
- 
        azell revised this gist Oct 9, 2015 . 1 changed file with 1 addition and 19 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ public class SpringExceptionTranslationExecuteListener SQLException e = ctx.sqlException(); if (e != null) { String name = ctx.configuration().dialect().thirdParty().springDbName(); /* Prefer product name, if available. */ SQLExceptionTranslator translator = (name != null) @@ -17,24 +17,6 @@ public class SpringExceptionTranslationExecuteListener ctx.exception(translator.translate("jOOQ", ctx.sql(), e)); } } } public class SpringTransactionConnectionProvider implements ConnectionProvider { 
- 
        azell revised this gist Aug 28, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,6 +18,8 @@ public class SpringExceptionTranslationExecuteListener } } // This will be simplified in 3.7.0 // https://github.com/jOOQ/jOOQ/issues/4252 protected String productName(SQLDialect dialect) { String name = null; 
- 
        azell revised this gist Jul 19, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,6 +15,7 @@ public class SpringExceptionTranslationExecuteListener : new SQLStateSQLExceptionTranslator(); ctx.exception(translator.translate("jOOQ", ctx.sql(), e)); } } protected String productName(SQLDialect dialect) { 
- 
        azell revised this gist Jul 19, 2014 . 1 changed file with 9 additions and 6 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,14 +4,17 @@ public class SpringExceptionTranslationExecuteListener /** {@inheritDoc} */ @Override public void exception(ExecuteContext ctx) { SQLException e = ctx.sqlException(); if (e != null) { String name = productName(ctx.configuration().dialect()); /* Prefer product name, if available. */ SQLExceptionTranslator translator = (name != null) ? new SQLErrorCodeSQLExceptionTranslator(name) : new SQLStateSQLExceptionTranslator(); ctx.exception(translator.translate("jOOQ", ctx.sql(), e)); } protected String productName(SQLDialect dialect) { 
- 
        azell revised this gist Feb 11, 2014 . 1 changed file with 21 additions and 3 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,13 +4,31 @@ public class SpringExceptionTranslationExecuteListener /** {@inheritDoc} */ @Override public void exception(ExecuteContext ctx) { String name = productName(ctx.configuration().dialect()); /* Prefer product name, if available. */ SQLExceptionTranslator translator = (name != null) ? new SQLErrorCodeSQLExceptionTranslator(name) : new SQLStateSQLExceptionTranslator(); ctx.exception(translator.translate("jOOQ", ctx.sql(), ctx.sqlException())); } protected String productName(SQLDialect dialect) { String name = null; if (dialect == SQLDialect.HSQLDB) { name = "HSQL"; } else if (dialect == SQLDialect.POSTGRES) { name = "PostgreSQL"; } else if (dialect == SQLDialect.MARIADB) { name = SQLDialect.MYSQL.getName(); } else if (dialect != null) { name = dialect.getName(); } return name; } } public class SpringTransactionConnectionProvider implements ConnectionProvider { 
- 
        azell revised this gist Aug 12, 2013 . 1 changed file with 2 additions and 5 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,18 +46,15 @@ public class JooqTransactionFactory { private final Configuration config = new DefaultConfiguration(); public JooqTransactionFactory(DataSource ds, SQLDialect dialect) { this(ds, dialect, new Settings().withRenderSchema(false)); } public JooqTransactionFactory(DataSource ds, SQLDialect dialect, Settings settings) { config.set(new SpringTransactionConnectionProvider(ds)).set(dialect).set( settings).set( new DefaultExecuteListenerProvider( new SpringExceptionTranslationExecuteListener())); } public DSLContext context() { 
- 
        azell revised this gist Jun 6, 2013 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -51,7 +51,6 @@ public class JooqTransactionFactory { public JooqTransactionFactory(DataSource ds, SQLDialect dialect, Settings settings) { config.set(new SpringTransactionConnectionProvider(ds)).set(dialect).set( new DefaultExecuteListenerProvider( new SpringExceptionTranslationExecuteListener())); 
- 
        azell revised this gist Jun 6, 2013 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,6 @@ public class SpringTransactionConnectionProvider implements ConnectionProvider { private final DataSource ds; public SpringTransactionConnectionProvider(DataSource ds) { this.ds = ds; } 
- 
        azell revised this gist May 28, 2013 . 1 changed file with 24 additions and 0 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -42,3 +42,27 @@ public class SpringTransactionConnectionProvider implements ConnectionProvider { } } } public class JooqTransactionFactory { private final Configuration config = new DefaultConfiguration(); public JooqTransactionFactory(DataSource ds, SQLDialect dialect) { this(ds, dialect, null); } public JooqTransactionFactory(DataSource ds, SQLDialect dialect, Settings settings) { super(); config.set(new SpringTransactionConnectionProvider(ds)).set(dialect).set( new DefaultExecuteListenerProvider( new SpringExceptionTranslationExecuteListener())); if (settings != null) { config.set(settings); } } public DSLContext context() { return DSL.using(config); } } 
- 
        azell revised this gist May 28, 2013 . 1 changed file with 6 additions and 8 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,8 +25,8 @@ public class SpringTransactionConnectionProvider implements ConnectionProvider { @Override public Connection acquire() { try { return DataSourceUtils.doGetConnection(ds); } catch (SQLException e) { throw new DataAccessException( "Error getting connection from data source " + ds, e); } @@ -35,12 +35,10 @@ public class SpringTransactionConnectionProvider implements ConnectionProvider { /** {@inheritDoc} */ @Override public void release(Connection conn) { try { DataSourceUtils.doReleaseConnection(conn, ds); } catch (SQLException e) { throw new DataAccessException("Error closing connection " + conn, e); } } } 
- 
        azell created this gist May 27, 2013 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ public class SpringExceptionTranslationExecuteListener extends DefaultExecuteListener { /** {@inheritDoc} */ @Override public void exception(ExecuteContext ctx) { SQLDialect dialect = ctx.configuration().dialect(); SQLExceptionTranslator translator = (dialect != null) ? new SQLErrorCodeSQLExceptionTranslator(dialect.name()) : new SQLStateSQLExceptionTranslator(); ctx.exception(translator.translate("jOOQ", ctx.sql(), ctx.sqlException())); } } public class SpringTransactionConnectionProvider implements ConnectionProvider { private final DataSource ds; public SpringTransactionConnectionProvider(DataSource ds) { super(); this.ds = ds; } /** {@inheritDoc} */ @Override public Connection acquire() { try { return DataSourceUtils.getConnection(ds); } catch (CannotGetJdbcConnectionException e) { throw new DataAccessException( "Error getting connection from data source " + ds, e); } } /** {@inheritDoc} */ @Override public void release(Connection conn) { if (conn != null) { try { conn.close(); } catch (SQLException e) { throw new DataAccessException("Error closing connection " + conn, e); } } } }