/** * Creates an immutable copy of this ColumnMapping. * * @throws IllegalStateException when a propertyName has not been defined for a column. */ protected ColumnMapping createImmutableCopy() { for (Column c : dbColumnMap.values()) { c.checkMapping(); } return new ColumnMapping(parsed, dbColumnMap); }
private int[] createIndexPositions(OrmQueryRequest<?> request, SqlTree sqlTree) { List<String> chain = sqlTree.buildRawSqlSelectChain(); ColumnMapping columnMapping = request.getQuery().getRawSql().getColumnMapping(); int[] indexPositions = new int[chain.size()]; // set the resultSet index positions for the property expressions for (int i = 0; i < chain.size(); i++) { String logicalPropertyPath = chain.get(i); int mappedPosition = columnMapping.getIndexPosition(logicalPropertyPath); if (mappedPosition == -1 && logicalPropertyPath.endsWith(".id")) { // try a automatically mapped foreign key mappedPosition = columnMapping.getIndexPosition(foreignKeyPath(logicalPropertyPath)); } indexPositions[i] = 1 + mappedPosition; } // check and handle the case where a discriminator column for // an associated bean is in the raw SQL but is mapped columnIgnore for (int i = 0; i < indexPositions.length; i++) { if (indexPositions[i] == 0) { if (i < indexPositions.length) { // expect discriminator column to immediately proceed id column indexPositions[i] = indexPositions[i + 1] - 1; } } } return indexPositions; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Key that = (Key) o; return parsed == that.parsed && columnMapping.equals(that.columnMapping) && unParsedSql.equals(that.unParsedSql); }
Iterator<Column> it = columnMapping.getColumns(); while (it.hasNext()) { RawSql.ColumnMapping.Column column = it.next(); if (idProperty != null && columnMapping.contains(idProperty.getName())) {
Iterator<Column> it = columnMapping.getColumns(); while (it.hasNext()) { RawSql.ColumnMapping.Column column = it.next();
Iterator<Column> it = columnMapping.getColumns(); while (it.hasNext()) { RawSql.ColumnMapping.Column column = it.next();
/** * Set the mapping of a DB Column to a bean property. * <p> * For Unparsed SQL the columnMapping MUST be defined in the same order that * the columns appear in the SQL statement. * </p> * * @param dbColumn * the DB column that we are mapping to a bean property * @param propertyName * the bean property that we are mapping the DB column to. */ public RawSqlBuilder columnMapping(String dbColumn, String propertyName) { columnMapping.columnMapping(dbColumn, propertyName); return this; }
/** * Set the mapping of a DB Column to a bean property. * <p> * For Unparsed SQL the columnMapping MUST be defined in the same order that * the columns appear in the SQL statement. * </p> * * @param dbColumn * the DB column that we are mapping to a bean property * @param propertyName * the bean property that we are mapping the DB column to. */ public RawSqlBuilder columnMapping(String dbColumn, String propertyName) { columnMapping.columnMapping(dbColumn, propertyName); return this; }
/** * Set the mapping of a DB Column to a bean property. * <p> * For Unparsed SQL the columnMapping MUST be defined in the same order that * the columns appear in the SQL statement. * </p> * * @param dbColumn the DB column that we are mapping to a bean property * @param propertyName the bean property that we are mapping the DB column to. */ public RawSqlBuilder columnMapping(String dbColumn, String propertyName) { columnMapping.columnMapping(dbColumn, propertyName); return this; }
/** * Construct with a ResultSet and properties that the columns map to. * <p> * The properties listed in the propertyNames must be in the same order as the columns in the * resultSet. * <p> * When a query executes this RawSql object then it will close the resultSet. */ public RawSql(ResultSet resultSet, String... propertyNames) { this.resultSet = resultSet; this.sql = null; this.columnMapping = new ColumnMapping(propertyNames); }
/** * Create the immutable RawSql object. Do this after all the column mapping * has been defined. */ public RawSql create() { return new RawSql(sql, columnMapping.createImmutableCopy()); }
public DeployParser createDeployParser() { if (rawSql != null) { return new DeployPropertyParserMap(rawSql.getColumnMapping().getMapping()); } else { return beanDescriptor.createDeployPropertyParser(); } }
/** * Create the immutable RawSql object. Do this after all the column mapping * has been defined. */ public RawSql create() { return new RawSql(resultSet, sql, columnMapping.createImmutableCopy()); }
private ColumnMapping parse() { ArrayList<ColumnMapping.Column> columns = new ArrayList<>(); while (pos <= end) { ColumnMapping.Column c = nextColumnInfo(); columns.add(c); } return new ColumnMapping(columns); }
/** * Creates an immutable copy of this ColumnMapping. * * @throws IllegalStateException * when a propertyName has not been defined for a column. */ protected ColumnMapping createImmutableCopy() { for (Column c : dbColumnMap.values()) { c.checkMapping(); } return new ColumnMapping(parsed, dbColumnMap); }
/** * Return an unparsed RawSqlBuilder. Unlike a parsed one this query can not be * modified - so no additional WHERE or HAVING expressions can be added to * this query. */ public static RawSqlBuilder unparsed(String sql) { Sql s = new Sql(sql); return new RawSqlBuilder(s, new ColumnMapping()); }
/** * Creates an immutable copy of this ColumnMapping. * * @throws IllegalStateException * when a propertyName has not been defined for a column. */ protected ColumnMapping createImmutableCopy() { for (Column c : dbColumnMap.values()) { c.checkMapping(); } return new ColumnMapping(parsed, dbColumnMap); }
/** * Return the hash for this query. */ public int queryHash() { return 31 * sql.queryHash() + columnMapping.queryHash(); }
private ColumnMapping parse() { ArrayList<ColumnMapping.Column> columns = new ArrayList<ColumnMapping.Column>(); while (pos <= end) { ColumnMapping.Column c = nextColumnInfo(); columns.add(c); } return new ColumnMapping(columns); }
/** * Create the immutable RawSql object. Do this after all the column mapping * has been defined. */ public RawSql create() { return new RawSql(sql, columnMapping.createImmutableCopy()); }