Class PrimitiveByteArrayJavaType

java.lang.Object
org.hibernate.type.descriptor.java.AbstractClassJavaType<byte[]>
org.hibernate.type.descriptor.java.PrimitiveByteArrayJavaType
All Implemented Interfaces:
Serializable, BasicJavaType<byte[]>, JavaType<byte[]>, VersionJavaType<byte[]>

public class PrimitiveByteArrayJavaType extends AbstractClassJavaType<byte[]> implements VersionJavaType<byte[]>
Descriptor for byte[] handling.
See Also:
  • Field Details

  • Constructor Details

    • PrimitiveByteArrayJavaType

      public PrimitiveByteArrayJavaType()
  • Method Details

    • isInstance

      public boolean isInstance(Object value)
      Description copied from interface: JavaType
      Is the given value an instance of the described type?

      Usually just getJavaTypeClass().isInstance(value), but some descriptors need specialized semantics, for example, the descriptors for java.sql.Date, java.sql.Time, and java.sql.Timestamp.

      Specified by:
      isInstance in interface JavaType<byte[]>
    • areEqual

      public boolean areEqual(byte[] one, byte[] another)
      Description copied from interface: JavaType
      Determine if two instances are equal
      Specified by:
      areEqual in interface JavaType<byte[]>
      Overrides:
      areEqual in class AbstractClassJavaType<byte[]>
      Parameters:
      one - One instance
      another - The other instance
      Returns:
      True if the two are considered equal; false otherwise.
    • extractHashCode

      public int extractHashCode(byte[] bytes)
      Description copied from interface: JavaType
      Extract a proper hash code for the given value.
      Specified by:
      extractHashCode in interface JavaType<byte[]>
      Overrides:
      extractHashCode in class AbstractClassJavaType<byte[]>
      Parameters:
      bytes - The value for which to extract a hash code.
      Returns:
      The extracted hash code.
    • toString

      public String toString(byte[] bytes)
      Specified by:
      toString in interface JavaType<byte[]>
    • appendString

      public void appendString(SqlAppender appender, byte[] bytes)
    • appendString

      public void appendString(StringBuilder appender, byte[] bytes)
    • extractLoggableRepresentation

      public String extractLoggableRepresentation(byte[] value)
      Description copied from interface: JavaType
      Extract a loggable representation of the given value.
      Specified by:
      extractLoggableRepresentation in interface JavaType<byte[]>
      Overrides:
      extractLoggableRepresentation in class AbstractClassJavaType<byte[]>
      Parameters:
      value - The value for which to extract a loggable representation.
      Returns:
      The loggable representation
    • fromString

      public byte[] fromString(CharSequence string)
      Specified by:
      fromString in interface BasicJavaType<byte[]>
      Specified by:
      fromString in interface JavaType<byte[]>
    • unwrap

      public <X> X unwrap(byte[] value, Class<X> type, WrapperOptions options)
      Description copied from interface: JavaType
      Unwrap an instance of our handled Java type into the requested type.

      As an example, if this is a JavaType<Integer> and we are asked to unwrap the Integer value as a Long, we would return something like Long.valueOf( value.longValue() ).

      Intended use is during PreparedStatement binding.

      Specified by:
      unwrap in interface JavaType<byte[]>
      Type Parameters:
      X - The conversion type.
      Parameters:
      value - The value to unwrap
      type - The type as which to unwrap
      options - The options
      Returns:
      The unwrapped value.
    • wrap

      public <X> byte[] wrap(X value, WrapperOptions options)
      Description copied from interface: JavaType
      Wrap a value as our handled Java type.

      Intended use is during ResultSet extraction.

      Specified by:
      wrap in interface JavaType<byte[]>
      Type Parameters:
      X - The conversion type.
      Parameters:
      value - The value to wrap.
      options - The options
      Returns:
      The wrapped value.
    • seed

      public byte[] seed(Long length, Integer precision, Integer scale, SharedSessionContractImplementor session)
      Description copied from interface: VersionJavaType
      Generate an initial version.

      Note that this operation is only used when the program sets a null or negative number as the value of the entity version field. It is not called when the program sets the version field to a sensible-looking version.

      Specified by:
      seed in interface VersionJavaType<byte[]>
      Parameters:
      length - The length of the type
      precision - The precision of the type
      scale - The scale of the type
      session - The session from which this request originates.
      Returns:
      an instance of the type
    • next

      public byte[] next(byte[] current, Long length, Integer precision, Integer scale, SharedSessionContractImplementor session)
      Description copied from interface: VersionJavaType
      Increment the version.
      Specified by:
      next in interface VersionJavaType<byte[]>
      Parameters:
      current - the current version
      length - The length of the type
      precision - The precision of the type
      scale - The scale of the type
      session - The session from which this request originates.
      Returns:
      an instance of the type