public OracleQueryFactory(SQLTemplates templates, Provider<Connection> connection) { this(new Configuration(templates), connection); }
protected void close(ResultSet rs) { try { rs.close(); } catch (SQLException e) { throw configuration.translate(e); } }
/** * Use the other getJavaType method instead * * @param sqlType * @param size * @param digits * @param tableName * @param columnName * @return */ @Deprecated public Class<?> getJavaType(int sqlType, int size, int digits, String tableName, String columnName) { return getJavaType(sqlType, null, size, digits, tableName, columnName); }
@Override @Before public void setUp() throws ClassNotFoundException, SQLException{ super.setUp(); // create schema statement.execute("drop table person if exists"); statement.execute("create table person(" + "id INT, " + "firstname VARCHAR(50), " + "gender VARCHAR(50), " + "securedId VARCHAR(50), " + "CONSTRAINT PK_person PRIMARY KEY (id) " + ")"); // create configuration configuration = new Configuration(new HSQLDBTemplates()); // configuration.setJavaType(Types.DATE, java.util.Date.class); configuration.register(new UtilDateType()); configuration.register("PERSON", "SECUREDID", new EncryptedString()); configuration.register("PERSON", "GENDER", new EnumByNameType<Gender>(Gender.class)); configuration.register(new StringType()); }
/** * Set the parameters to the given PreparedStatement * * @param stmt preparedStatement to be populated * @param objects list of constants * @param constantPaths list of paths related to the constants * @param params map of param to value for param resolving */ protected void setParameters(PreparedStatement stmt, List<?> objects, List<Path<?>> constantPaths, Map<ParamExpression<?>, ?> params) { if (objects.size() != constantPaths.size()) { throw new IllegalArgumentException("Expected " + objects.size() + " paths, " + "but got " + constantPaths.size()); } for (int i = 0; i < objects.size(); i++) { Object o = objects.get(i); try { if (o instanceof ParamExpression) { if (!params.containsKey(o)) { throw new ParamNotSetException((ParamExpression<?>) o); } o = params.get(o); } configuration.set(stmt, constantPaths.get(i), i+1, o); } catch (SQLException e) { throw configuration.translate(e); } } }
context = startContext(connection, metadata, entity); try { if (configuration.getTemplates().isNativeMerge()) { PreparedStatement stmt = null; if (batches.isEmpty()) { throw configuration.translate(queryString, constants, e); } finally { reset();
append(COMMA); append(configuration.asLiteral(o)); first = false; append(configuration.asLiteral(constant)); if (stage == Stage.SELECT && !Null.class.isInstance(constant) && configuration.getTemplates().isWrapSelectParameters()) { String typeName = configuration.getTypeNameForCast(constant.getClass()); Expression type = Expressions.constant(typeName); super.visitOperation(constant.getClass(), SQLOps.CAST, ImmutableList.<Expression<?>>of(Q, type));
/** * Register the given javaType for the given table and column * * @param table * @param column * @param javaType */ public void register(String table, String column, Class<?> javaType) { register(table, column, javaTypeMapping.getType(javaType)); }
@Nullable private <T> T get(ResultSet rs, Expression<?> expr, int i, Class<T> type) throws SQLException { return configuration.get(rs, expr instanceof Path ? (Path<?>)expr : null, i, type); }
private <T> T executeWithKey(Class<T> type, @Nullable Path<T> path) { ResultSet rs = null; try { rs = executeWithKeys(); if (rs.next()) { return configuration.get(rs, path, 1, type); } else { return null; } } catch (SQLException e) { throw configuration.translate(e); } finally { if (rs != null) { close(rs); } reset(); } }
public SQLInsertClause(Connection connection, SQLTemplates templates, RelationalPath<?> entity, AbstractSQLSubQuery<?> subQuery) { this(connection, new Configuration(templates), entity); this.subQueryBuilder = subQuery; }
protected void close(Statement stmt) { try { stmt.close(); } catch (SQLException e) { throw configuration.translate(e); } }
private <T> List<T> executeWithKeys(Class<T> type, @Nullable Path<T> path) { ResultSet rs = null; try{ rs = executeWithKeys(); List<T> rv = new ArrayList<T>(); while (rs.next()) { rv.add(configuration.get(rs, path, 1, type)); } return rv; } catch (SQLException e) { throw configuration.translate(e); }finally { if (rs != null) { close(rs); } reset(); } }
Class<?> clazz = configuration.getJavaType(columnType, typeName, columnSize != null ? columnSize.intValue() : 0,
/** * Create a new SQLQuery instance * * @param conn Connection to use * @param templates SQLTemplates to use * @param metadata */ public SQLQuery(Connection conn, SQLTemplates templates, QueryMetadata metadata) { super(conn, new Configuration(templates), metadata); }
@Override public void close() { try{ try { if (rs != null) { rs.close(); } } finally { if (stmt != null) { stmt.close(); } } }catch(SQLException e) { throw configuration.translate(e); } }
private <T> List<T> executeWithKeys(Class<T> type, @Nullable Path<T> path) { ResultSet rs = null; try { rs = executeWithKeys(); List<T> rv = new ArrayList<T>(); while (rs.next()) { rv.add(configuration.get(rs, path, 1, type)); } return rv; } catch (SQLException e) { throw configuration.translate(e); } finally { if (rs != null) { close(rs); } reset(); } }
public SQLInsertClause(Connection connection, SQLTemplates templates, RelationalPath<?> entity) { this(connection, new Configuration(templates), entity); }
@Override public long count() { try { return unsafeCount(); } catch (SQLException e) { String error = "Caught " + e.getClass().getName(); logger.error(error, e); throw configuration.translate(e); } }