-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
521 additions
and
79 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
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
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
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
63 changes: 63 additions & 0 deletions
63
...te-core/src/main/java/org/hibernate/dialect/function/array/AbstractArrayFillFunction.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,63 @@ | ||
/* | ||
* 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.dialect.function.array; | ||
|
||
import org.hibernate.metamodel.mapping.MappingModelExpressible; | ||
import org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor; | ||
import org.hibernate.query.sqm.produce.function.ArgumentTypesValidator; | ||
import org.hibernate.query.sqm.produce.function.FunctionArgumentTypeResolver; | ||
import org.hibernate.query.sqm.produce.function.FunctionParameterType; | ||
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter; | ||
import org.hibernate.query.sqm.tree.expression.SqmFunction; | ||
import org.hibernate.type.BasicPluralType; | ||
|
||
/** | ||
* Encapsulates the validator, return type and argument type resolvers for the array_contains function. | ||
* Subclasses only have to implement the rendering. | ||
*/ | ||
public abstract class AbstractArrayFillFunction extends AbstractSqmSelfRenderingFunctionDescriptor { | ||
|
||
public AbstractArrayFillFunction() { | ||
super( | ||
"array_fill", | ||
new ArgumentTypesValidator( null, FunctionParameterType.NO_UNTYPED, FunctionParameterType.INTEGER ), | ||
ArrayViaElementArgumentReturnTypeResolver.DEFAULT_INSTANCE, | ||
ArrayFillArgumentsValidator.INSTANCE | ||
); | ||
} | ||
|
||
@Override | ||
public String getArgumentListSignature() { | ||
return "(OBJECT element, INTEGER elementCount)"; | ||
} | ||
|
||
private static class ArrayFillArgumentsValidator implements FunctionArgumentTypeResolver { | ||
|
||
public static final FunctionArgumentTypeResolver INSTANCE = new ArrayFillArgumentsValidator(); | ||
|
||
private ArrayFillArgumentsValidator() { | ||
} | ||
|
||
@Override | ||
public MappingModelExpressible<?> resolveFunctionArgumentType( | ||
SqmFunction<?> function, | ||
int argumentIndex, | ||
SqmToSqlAstConverter converter) { | ||
if ( argumentIndex == 0 ) { | ||
final MappingModelExpressible<?> impliedReturnType = converter.resolveFunctionImpliedReturnType(); | ||
return impliedReturnType instanceof BasicPluralType<?, ?> | ||
? ( (BasicPluralType<?, ?>) impliedReturnType ).getElementType() | ||
: null; | ||
} | ||
else { | ||
return converter.getCreationContext().getSessionFactory().getTypeConfiguration().getBasicTypeRegistry() | ||
.getRegisteredType( Integer.class ); | ||
} | ||
} | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.