Package org.ofbiz.core.entity.jdbc
Class SqlJdbcUtil
java.lang.Object
org.ofbiz.core.entity.jdbc.SqlJdbcUtil
GenericDAO Utility methods for general tasks
- Since:
- 2.0
- Version:
- $Revision: 1.2 $
- Author:
- David E. Jones, Chris Maurer, Andy Zeneski, Juergen Donnerstag, Peter Moon
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAn enumeration of the various data types supported by the entity engine. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcountWhereStringParametersFromFields(List<ModelField> modelFields, Map<String, ?> fieldValues) static StringfilterColName(String colName) static SqlJdbcUtil.FieldTypegetFieldType(String javaType) Does the same thing asgetType(String), except that it returns anenumtype instead of a magic number and doesn't throw a checked exception.static intstatic voidgetValue(ResultSet rs, int ind, ModelField curField, GenericEntity entity, ModelFieldTypeReader modelFieldTypeReader) static booleanIndicates whether the given field type represents a Boolean field.static StringmakeFromClause(ModelEntity modelEntity, DatasourceInfo datasourceInfo, SqlEscapeHelper sqlEscapeHelper) Makes the FROM clause and when necessary the JOIN clause(s) as wellstatic StringmakeOrderByClause(ModelEntity modelEntity, List<String> orderBy, boolean includeTablenamePrefix, DatasourceInfo datasourceInfo) static StringmakeOrderByClause(ModelEntity modelEntity, List<String> orderBy, DatasourceInfo datasourceInfo) static StringmakeViewTable(ModelEntity modelEntity, DatasourceInfo datasourceInfo, SqlEscapeHelper sqlEscapeHelper) static StringmakeViewWhereClause(ModelEntity modelEntity, String joinStyle, SqlEscapeHelper sqlEscapeHelper) static StringmakeWhereClause(ModelEntity modelEntity, List<ModelField> modelFields, Map<String, ?> fields, String operator, String joinStyle, SqlEscapeHelper sqlEscapeHelper) static StringmakeWhereStringFromFields(List<ModelField> modelFields, Map<String, ?> fieldValues, String operator, List<? super EntityConditionParam> entityConditionParams, SqlEscapeHelper sqlEscapeHelper) Makes a WHERE clause String with "col_name=?" if not null or "col_name IS NULL" if null, all separated by the given operator.static StringmakeWhereStringFromFields(List<ModelField> modelFields, Map<String, ?> fieldValues, String operator, SqlEscapeHelper sqlEscapeHelper) Makes a WHERE clause String with "col_name=?" if not null or "col_name IS NULL" if null, all separated by the given operator.static voidsetPkValues(SQLProcessor sqlP, ModelEntity modelEntity, GenericEntity entity, ModelFieldTypeReader modelFieldTypeReader) Get all primary keys from the model entity and bind their values to the an SQL statement (SQL-Processor)static voidsetValue(SQLProcessor sqlP, ModelField modelField, String entityName, Object fieldValue, ModelFieldTypeReader modelFieldTypeReader) static voidsetValue(SQLProcessor sqlP, ModelField modelField, GenericEntity entity, ModelFieldTypeReader modelFieldTypeReader) static voidsetValues(SQLProcessor sqlP, List<ModelField> list, GenericEntity entity, ModelFieldTypeReader modelFieldTypeReader) The elements (ModelFields) of the list are bound to an SQL statement (SQL-Processor)static voidsetValuesWhereClause(SQLProcessor sqlP, List<ModelField> list, GenericValue dummyValue, ModelFieldTypeReader modelFieldTypeReader) The elements (ModelFields) of the list are bound to an SQL statement (SQL-Processor), but values must not be null.
-
Field Details
-
module
-
-
Constructor Details
-
SqlJdbcUtil
public SqlJdbcUtil()
-
-
Method Details
-
isBoolean
Indicates whether the given field type represents a Boolean field. This convenience method is exactly equivalent toFieldType.BOOLEAN.matches(fieldType)- Parameters:
fieldType- the field type to check- Returns:
- see above
-
makeFromClause
public static String makeFromClause(ModelEntity modelEntity, DatasourceInfo datasourceInfo, SqlEscapeHelper sqlEscapeHelper) throws GenericEntityException Makes the FROM clause and when necessary the JOIN clause(s) as well- Throws:
GenericEntityException
-
makeWhereStringFromFields
public static String makeWhereStringFromFields(List<ModelField> modelFields, Map<String, ?> fieldValues, String operator, SqlEscapeHelper sqlEscapeHelper) Makes a WHERE clause String with "col_name=?" if not null or "col_name IS NULL" if null, all separated by the given operator.- Parameters:
modelFields- the fields to include in the WHERE string (can be null)fieldValues- any field values to be checked against non-null values; keys are field (not column) namesoperator- the operator to insert between each column condition in the returned WHERE string (typically "AND" or "OR")- Returns:
- an empty string if the given list of fields is null or empty, otherwise a string like "first_name IS NULL OR last_name=?"
-
countWhereStringParametersFromFields
public static int countWhereStringParametersFromFields(List<ModelField> modelFields, Map<String, ?> fieldValues) -
makeWhereStringFromFields
public static String makeWhereStringFromFields(List<ModelField> modelFields, Map<String, ?> fieldValues, String operator, List<? super EntityConditionParam> entityConditionParams, SqlEscapeHelper sqlEscapeHelper) Makes a WHERE clause String with "col_name=?" if not null or "col_name IS NULL" if null, all separated by the given operator.- Parameters:
modelFields- the fields to include in the WHERE string (can be null)fieldValues- any field values to be checked against non-null values; keys are field (not column) namesoperator- the operator to insert between each column condition in the returned WHERE string (typically "AND" or "OR")entityConditionParams- if not null, an element will be added to this list- Returns:
- an empty string if the given list of fieldValues is null or empty, otherwise a string like "first_name IS NULL OR last_name=?"
-
makeWhereClause
public static String makeWhereClause(ModelEntity modelEntity, List<ModelField> modelFields, Map<String, ?> fields, String operator, String joinStyle, SqlEscapeHelper sqlEscapeHelper) throws GenericEntityException- Throws:
GenericEntityException
-
makeViewWhereClause
public static String makeViewWhereClause(ModelEntity modelEntity, String joinStyle, SqlEscapeHelper sqlEscapeHelper) throws GenericEntityException - Throws:
GenericEntityException
-
makeOrderByClause
public static String makeOrderByClause(ModelEntity modelEntity, List<String> orderBy, DatasourceInfo datasourceInfo) -
makeOrderByClause
public static String makeOrderByClause(ModelEntity modelEntity, List<String> orderBy, boolean includeTablenamePrefix, DatasourceInfo datasourceInfo) -
makeViewTable
public static String makeViewTable(ModelEntity modelEntity, DatasourceInfo datasourceInfo, SqlEscapeHelper sqlEscapeHelper) throws GenericEntityException - Throws:
GenericEntityException
-
filterColName
-
setValues
public static void setValues(SQLProcessor sqlP, List<ModelField> list, GenericEntity entity, ModelFieldTypeReader modelFieldTypeReader) throws GenericEntityException The elements (ModelFields) of the list are bound to an SQL statement (SQL-Processor)- Parameters:
sqlP-list-entity-modelFieldTypeReader-- Throws:
GenericEntityException
-
setValuesWhereClause
public static void setValuesWhereClause(SQLProcessor sqlP, List<ModelField> list, GenericValue dummyValue, ModelFieldTypeReader modelFieldTypeReader) throws GenericEntityException The elements (ModelFields) of the list are bound to an SQL statement (SQL-Processor), but values must not be null.- Parameters:
sqlP-list-dummyValue-modelFieldTypeReader-- Throws:
GenericEntityException
-
setPkValues
public static void setPkValues(SQLProcessor sqlP, ModelEntity modelEntity, GenericEntity entity, ModelFieldTypeReader modelFieldTypeReader) throws GenericEntityException Get all primary keys from the model entity and bind their values to the an SQL statement (SQL-Processor)- Parameters:
sqlP-modelEntity-entity-modelFieldTypeReader-- Throws:
GenericEntityException
-
getValue
public static void getValue(ResultSet rs, int ind, ModelField curField, GenericEntity entity, ModelFieldTypeReader modelFieldTypeReader) throws GenericEntityException - Throws:
GenericEntityException
-
setValue
public static void setValue(SQLProcessor sqlP, ModelField modelField, GenericEntity entity, ModelFieldTypeReader modelFieldTypeReader) throws GenericEntityException - Throws:
GenericEntityException
-
setValue
public static void setValue(SQLProcessor sqlP, ModelField modelField, String entityName, Object fieldValue, ModelFieldTypeReader modelFieldTypeReader) throws GenericEntityException - Throws:
GenericEntityException
-
getType
- Throws:
GenericNotImplementedException
-
getFieldType
Does the same thing asgetType(String), except that it returns anenumtype instead of a magic number and doesn't throw a checked exception.- Parameters:
javaType- the java type to resolve to a field type- Returns:
- the matching field type
- Throws:
IllegalArgumentException- if the java class type is unsupported- Since:
- 1.1.0
-