Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for 'length' and 'substring' as predicates and selections.
- Loading branch information
Showing
7 changed files
with
188 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
74 changes: 74 additions & 0 deletions
74
hibernate-core/src/main/java/org/hibernate/sql/ast/tree/spi/expression/SubstrFunction.java
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.sql.ast.tree.spi.expression; | ||
|
||
import java.util.List; | ||
|
||
import org.hibernate.sql.SqlExpressableType; | ||
import org.hibernate.sql.ast.consume.spi.SqlAstWalker; | ||
import org.hibernate.sql.ast.produce.spi.SqlExpressable; | ||
import org.hibernate.sql.results.internal.SqlSelectionImpl; | ||
import org.hibernate.sql.results.spi.SqlSelection; | ||
import org.hibernate.type.descriptor.java.spi.BasicJavaDescriptor; | ||
import org.hibernate.type.spi.TypeConfiguration; | ||
|
||
/** | ||
* @author Chris Cranford | ||
*/ | ||
public class SubstrFunction implements StandardFunction { | ||
private final String functionName; | ||
private final List<Expression> expressions; | ||
private final SqlExpressableType type; | ||
|
||
public SubstrFunction(String name, List<Expression> expressions, SqlExpressableType type) { | ||
this.functionName = name; | ||
this.expressions = expressions; | ||
this.type = type; | ||
} | ||
|
||
public String getFunctionName() { | ||
return functionName; | ||
} | ||
|
||
public List<Expression> getExpressions() { | ||
return expressions; | ||
} | ||
|
||
@Override | ||
public SqlExpressableType getExpressableType() { | ||
return type; | ||
} | ||
|
||
@Override | ||
public SqlExpressableType getType() { | ||
return getExpressableType(); | ||
} | ||
|
||
@Override | ||
public SqlExpressable getExpressable() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public void accept(SqlAstWalker walker) { | ||
walker.visitSubstrFunction( this ); | ||
} | ||
|
||
@Override | ||
public SqlSelection createSqlSelection( | ||
int jdbcPosition, | ||
int valuesArrayPosition, | ||
BasicJavaDescriptor javaTypeDescriptor, | ||
TypeConfiguration typeConfiguration) { | ||
return new SqlSelectionImpl( | ||
jdbcPosition, | ||
valuesArrayPosition, | ||
this, | ||
getType().getJdbcValueExtractor() | ||
); | ||
} | ||
} |
This file contains 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 characters
This file contains 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 characters