public final class IntegerUserType extends AbstractWrapperUserType
P2J integer
. This permits Hibernate to
convert this data type to and from the SQL INTEGER data type. The unknown
value is mapped to SQL NULL.Modifier and Type | Field and Description |
---|---|
private static int[] |
SQL_TYPES
Single element array containing the SQL type constant being mapped
|
LOG, LOG_TRACE
Constructor and Description |
---|
IntegerUserType() |
Modifier and Type | Method and Description |
---|---|
protected void |
bindNonNull(java.sql.PreparedStatement ps,
BaseDataType value,
int index)
Set an
int value into the given prepared statement,
based upon the integer instance value . |
java.lang.Object |
deepCopy(java.lang.Object value)
Create and return a deep copy of the given
integer
instance. |
java.lang.Object |
nullSafeGet(java.sql.ResultSet rs,
java.lang.String[] names,
org.hibernate.engine.spi.SessionImplementor session,
java.lang.Object owner)
Create an instance of the data type mapped by this class, based upon
a data value in the specified result set.
|
java.lang.Class |
returnedClass()
Gets the Java data type class mapped by this custom type.
|
int[] |
sqlTypes()
Get the array of SQL data type constants (in this case only a single
constant), which this classes uses to map an integer to/from a database
record.
|
protected java.lang.String |
toString(BaseDataType value)
Return the string value of the
int embedded in the
given integer object value . |
assemble, disassemble, equals, getBaseValue, hashCode, instantiateRegular, instantiateUnknown, isMutable, nullSafeSet, replace
private static final int[] SQL_TYPES
public int[] sqlTypes()
public java.lang.Class returnedClass()
P2J integer
class.public java.lang.Object deepCopy(java.lang.Object value)
integer
instance.value
- The integer
instance to be copied.integer
which contains the
same internal value as value
.public java.lang.Object nullSafeGet(java.sql.ResultSet rs, java.lang.String[] names, org.hibernate.engine.spi.SessionImplementor session, java.lang.Object owner) throws java.sql.SQLException
integer
instance which is initialized to the unknown value.nullSafeGet
in interface org.hibernate.usertype.UserType
nullSafeGet
in class AbstractWrapperUserType
rs
- Result set positioned at the record from which we will access
an int
.names
- Array of column names. In this case, it will contain only one
element, which represents the name of the column from which
we will access our data.session
- Not used.owner
- Owning entity; not used.integer
instance, possibly initialized to the
unknown value.java.sql.SQLException
- if an error occurs accessing the result set.protected void bindNonNull(java.sql.PreparedStatement ps, BaseDataType value, int index) throws java.sql.SQLException
int
value into the given prepared statement,
based upon the integer
instance value
.bindNonNull
in class AbstractWrapperUserType
ps
- Prepared statement into which we will set our data.value
- An integer
instance.index
- Index in the statement at which to write the data.java.sql.SQLException
- if an error occurs setting data into the statement.protected java.lang.String toString(BaseDataType value)
int
embedded in the
given integer
object value
. The default
toString()
method of integer
returns a
formatted, padded string, which is not suitable for our purposes.toString
in class AbstractWrapperUserType
value
- An integer
object. It is safe to assume this
will not be null
.String
representation of the contents of
value
.