ENTITY
- The type of the class being persisted.public class DirectPrimaryKey<ENTITY> extends Object implements PrimaryKey<ENTITY,ENTITY>
Most users of hrorm will have no need to directly use this.
Constructor and Description |
---|
DirectPrimaryKey(String prefix,
String name,
String sequenceName,
Function<ENTITY,Long> getter,
BiConsumer<ENTITY,Long> setter) |
Modifier and Type | Method and Description |
---|---|
Long |
getKey(ENTITY item) |
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.
|
String |
getSequenceName()
The name of the database sequence that is used to populate this key
|
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.
|
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.
|
void |
optimisticSetKey(ENTITY item,
Long id)
Sets the key onto the object
|
PopulateResult |
populate(ENTITY constructor,
ResultSet resultSet)
Populates the object with the data read from the database.
|
void |
setKey(ENTITY builder,
Long id) |
void |
setSqlTypeName(String sqlTypeName) |
void |
setValue(ENTITY item,
int index,
PreparedStatement preparedStatement)
Sets a value onto the prepared statement based on the state of the object passed.
|
Set<Integer> |
supportedTypes()
The members of
java.sql.Types that this column should support. |
Column<ENTITY,ENTITY> |
withPrefix(String newPrefix,
Prefixer prefixer)
Make a new instance of the column, identical to this instance, except with a
new prefix.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isParentColumn
public String getSequenceName()
PrimaryKey
getSequenceName
in interface PrimaryKey<ENTITY,ENTITY>
public void setKey(ENTITY builder, Long id)
setKey
in interface PrimaryKey<ENTITY,ENTITY>
public void optimisticSetKey(ENTITY item, Long id)
PrimaryKey
optimisticSetKey
in interface PrimaryKey<ENTITY,ENTITY>
item
- the object whose key is to be setid
- the primary key to assign itpublic String getName()
Column
public String getPrefix()
Column
public PopulateResult populate(ENTITY constructor, ResultSet resultSet) throws SQLException
Column
populate
in interface Column<ENTITY,ENTITY>
constructor
- The object being populatedresultSet
- The result said being readSQLException
- allowed for ResultSet
operationspublic void setValue(ENTITY item, int index, PreparedStatement preparedStatement) throws SQLException
Column
setValue
in interface Column<ENTITY,ENTITY>
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
operationspublic Column<ENTITY,ENTITY> withPrefix(String newPrefix, Prefixer prefixer)
Column
withPrefix
in interface Column<ENTITY,ENTITY>
newPrefix
- The new prefixprefixer
- The source for new prefixespublic boolean isPrimaryKey()
Column
isPrimaryKey
in interface Column<ENTITY,ENTITY>
public void notNull()
Column
public Set<Integer> supportedTypes()
Column
java.sql.Types
that this column should support.supportedTypes
in interface Column<ENTITY,ENTITY>
public boolean isNullable()
Column
isNullable
in interface Column<ENTITY,ENTITY>
public String getSqlTypeName()
Column
String
,
"decimal" for BigDecimal
.getSqlTypeName
in interface Column<ENTITY,ENTITY>
public void setSqlTypeName(String sqlTypeName)
setSqlTypeName
in interface Column<ENTITY,ENTITY>
Copyright © 2019. All rights reserved.