DBTYPE
- The type of the data element as represented in the JDBC.CLASSTYPE
- The type of the data element as defined in the entity class.ENTITY
- The type of the entity.BUILDER
- The class that is used to build new entity instances.public interface Column<DBTYPE,CLASSTYPE,ENTITY,BUILDER>
The class GenericColumn
is intended for clients that
wish to extend hrorm to new types.
Most users of hrorm will have no need to directly use this.
Modifier and Type | Method and Description |
---|---|
GenericColumn<DBTYPE> |
asGenericColumn()
Returns a generic column instance that supports the underlying
DBTYPE |
default CLASSTYPE |
fromResultSet(ResultSet resultSet)
Parses a result set object for the value of this column
using its name without using the prefix value.
|
String |
getName()
The name of the database column this instance represents.
|
String |
getPrefix()
The prefix that should be used for this column when generating
SQL.
|
default String |
getSqlTypeName()
Returns the name of the column type in SQL, e.g.
|
boolean |
isNullable()
Indicator of whether or not this column is nullable or not.
|
default boolean |
isParentColumn()
Flag indicating whether this column represents a reference to a parent entity.
|
default boolean |
isPrimaryKey()
Flag indicating whether or not this column is the primary key of the table
|
void |
notNull()
Calling this method will enforce a not-null constraint on this column.
|
PopulateResult |
populate(BUILDER constructor,
ResultSet resultSet)
Populates the passed builder object with the data read from the database.
|
void |
setSqlTypeName(String sqlTypeName)
Set the name of the type of this column as it would be in the SQL schema.
|
void |
setValue(ENTITY item,
int index,
PreparedStatement preparedStatement)
Sets a value onto the prepared statement based on the state of the object passed.
|
default Set<Integer> |
supportedTypes()
The members of
java.sql.Types that this column should support. |
CLASSTYPE |
toClassType(DBTYPE dbType)
Applies any
Converter associated with this column to
a raw database type. |
Column<DBTYPE,CLASSTYPE,ENTITY,BUILDER> |
withPrefix(String newPrefix,
Prefixer prefixer)
Make a new instance of the column, identical to this instance, except with a
new prefix.
|
String getName()
String getPrefix()
void setValue(ENTITY item, int index, PreparedStatement preparedStatement) throws SQLException
item
- The object to read the data from.index
- Where in the prepared statement to set the read valuepreparedStatement
- The statement being populatedSQLException
- allowed for PreparedStatement
operationsdefault boolean isPrimaryKey()
void notNull()
boolean isNullable()
default boolean isParentColumn()
PopulateResult populate(BUILDER constructor, ResultSet resultSet) throws SQLException
constructor
- The object being populatedresultSet
- The result said being readSQLException
- allowed for ResultSet
operationsColumn<DBTYPE,CLASSTYPE,ENTITY,BUILDER> withPrefix(String newPrefix, Prefixer prefixer)
newPrefix
- The new prefixprefixer
- The source for new prefixesCLASSTYPE toClassType(DBTYPE dbType)
Converter
associated with this column to
a raw database type.dbType
- The value of an element represented by this column, as
stored in the database, or at least, as represented in the
JDBC.ENTITY
class.default Set<Integer> supportedTypes()
java.sql.Types
that this column should support.default String getSqlTypeName()
String
,
"decimal" for BigDecimal
.void setSqlTypeName(String sqlTypeName)
sqlTypeName
- The name of the SQL type.GenericColumn<DBTYPE> asGenericColumn()
DBTYPE
Copyright © 2019. All rights reserved.