/** * Create a connected crud validating it against the specified datasource. * The table name is derived from the jpa annotation or from the class name. * @param dataSource the datasource * @return a new crud instance * @throws SQLException if an error occurred */ public ConnectedCrud<T, K> to(DataSource dataSource) throws SQLException { Connection connection = dataSource.getConnection(); try { return new ConnectedCrud<T, K>(new DataSourceTransactionTemplate(dataSource), to(connection)); } finally { connection.close(); } }
/** * Create a connected crud against the specified table validating it against the specified datasource. * @param dataSource the datasource * @param table the table * @return a new crud instance * @throws SQLException if an error occurred */ public ConnectedCrud<T, K> table(DataSource dataSource, String table) throws SQLException { Connection connection = dataSource.getConnection(); try { return new ConnectedCrud<T, K>(new DataSourceTransactionTemplate(dataSource), table(connection, table)); } finally { connection.close(); } }
/** * Create a connected crud against the specified table validating it against the specified datasource. * @param dataSource the datasource * @param table the table * @return a new crud instance * @throws SQLException if an error occurred */ public ConnectedCrud<T, K> table(DataSource dataSource, String table) throws SQLException { Connection connection = dataSource.getConnection(); try { return new ConnectedCrud<T, K>(new DataSourceTransactionTemplate(dataSource), table(connection, table)); } finally { connection.close(); } }
/** * Create a connected crud validating it against the specified datasource. * The table name is derived from the jpa annotation or from the class name. * @param dataSource the datasource * @return a new crud instance * @throws SQLException if an error occurred */ public ConnectedCrud<T, K> to(DataSource dataSource) throws SQLException { Connection connection = dataSource.getConnection(); try { return new ConnectedCrud<T, K>(new DataSourceTransactionTemplate(dataSource), to(connection)); } finally { connection.close(); } }
when(dataSource.getConnection()).thenReturn(connection); ConnectedCrud<Object, Object> connectedCrud = new ConnectedCrud<Object, Object>(new DataSourceTransactionTemplate(dataSource), crud);
when(dataSource.getConnection()).thenReturn(connection); ConnectedCrud<Object, Object> connectedCrud = new ConnectedCrud<Object, Object>(new DataSourceTransactionTemplate(dataSource), crud);