Package org.ofbiz.core.entity.model
Class FunctionDefinitionBuilder
java.lang.Object
org.ofbiz.core.entity.model.FunctionDefinitionBuilder
Base class for creating a function definition. The main purpose is to return
different function definitions based on database type, for instance the substr function
is different in each of our supported databases.
You should provide an override of this class for your function definition, for example
public class LowerFunctionDefinitionBuilder extends FunctionDefinitionBuilder {
public LowerFunctionDefinitionBuilder(String virtualColumn, String type, List<String> columns, @Nullable String argsList) {
super(virtualColumn, type, columns, argsList);
}
public String getFunctionDefinition(DatabaseType databaseType) {
String column = columns.get(0);
return "lower(" + column +")";
}
}
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StringgetFunctionDefinition(DatabaseType databaseType) getType()getVirtualColumn(DatabaseType dbType) boolean
-
Field Details
-
columns
-
argsList
-
-
Constructor Details
-
FunctionDefinitionBuilder
public FunctionDefinitionBuilder(String virtualColumn, String type, List<String> columns, @Nullable String argsList) - Parameters:
virtualColumn- the name of any virtual column to be created, must be provided, but only used in MySql and SQLServertype- the model type of the virtual column, this should be the same as the function return type and is something like"long-varchar".columns- a list of columns that the function operates on, must contain at least one column.argsList- an optional comma separated string of arguments to be provided to the function.
-
-
Method Details
-
getVirtualColumn
- Returns:
- the name of the vitrtual column to create in the databse. Only those databases that do not support function based indexes need to create a column, so return null for supported databases.
-
getType
-
getFunctionDefinition
-
supportsFunctionBasedIndices
-