Class UserTypeJavaTypeWrapper<J>

java.lang.Object
org.hibernate.type.internal.UserTypeJavaTypeWrapper<J>
All Implemented Interfaces:
Serializable, BasicJavaType<J>, JavaType<J>
Direct Known Subclasses:
UserTypeVersionJavaTypeWrapper

public class UserTypeJavaTypeWrapper<J> extends Object implements BasicJavaType<J>
Adaptor between UserType and JavaType.
See Also:
  • Field Details

    • userType

      protected final UserType<J> userType
  • Constructor Details

    • UserTypeJavaTypeWrapper

      public UserTypeJavaTypeWrapper(UserType<J> userType)
  • Method Details

    • getMutabilityPlan

      public MutabilityPlan<J> getMutabilityPlan()
      Description copied from interface: JavaType
      Retrieve the mutability plan for this Java type.
      Specified by:
      getMutabilityPlan in interface JavaType<J>
    • getRecommendedJdbcType

      public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context)
      Description copied from interface: BasicJavaType
      Obtain the "recommended" SQL type descriptor for this Java type. Often, but not always, the source of this recommendation is the JDBC specification.
      Specified by:
      getRecommendedJdbcType in interface BasicJavaType<J>
      Specified by:
      getRecommendedJdbcType in interface JavaType<J>
      Parameters:
      context - Contextual information
      Returns:
      The recommended SQL type descriptor
    • getDefaultSqlLength

      public long getDefaultSqlLength(Dialect dialect, JdbcType jdbcType)
      Description copied from interface: JavaType
      The default column length when this Java type is mapped to a SQL data type which is parametrized by length, for example Types.VARCHAR.
      Specified by:
      getDefaultSqlLength in interface JavaType<J>
      Returns:
      Size.DEFAULT_LENGTH unless overridden
    • getDefaultSqlPrecision

      public int getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType)
      Description copied from interface: JavaType
      The default column precision when this Java type is mapped to a SQL data type which is parametrized by precision, for example Types.DECIMAL.
      Specified by:
      getDefaultSqlPrecision in interface JavaType<J>
      Returns:
      Size.DEFAULT_PRECISION unless overridden
    • getDefaultSqlScale

      public int getDefaultSqlScale(Dialect dialect, JdbcType jdbcType)
      Description copied from interface: JavaType
      The default column scale when this Java type is mapped to a SQL data type which is parametrized by scale, for example Types.DECIMAL.
      Specified by:
      getDefaultSqlScale in interface JavaType<J>
      Returns:
      Size.DEFAULT_SCALE unless overridden
    • getComparator

      public Comparator<J> getComparator()
      Description copied from interface: JavaType
      Retrieve the natural comparator for this type.
      Specified by:
      getComparator in interface JavaType<J>
    • extractHashCode

      public int extractHashCode(J value)
      Description copied from interface: JavaType
      Extract a proper hash code for the given value.
      Specified by:
      extractHashCode in interface JavaType<J>
      Parameters:
      value - The value for which to extract a hash code.
      Returns:
      The extracted hash code.
    • areEqual

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

      public J fromString(CharSequence string)
      Specified by:
      fromString in interface BasicJavaType<J>
      Specified by:
      fromString in interface JavaType<J>
    • toString

      public String toString(J value)
      Specified by:
      toString in interface JavaType<J>
    • unwrap

      public <X> X unwrap(J 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<J>
      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> J 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<J>
      Type Parameters:
      X - The conversion type.
      Parameters:
      value - The value to wrap.
      options - The options
      Returns:
      The wrapped value.
    • getJavaTypeClass

      public Class<J> getJavaTypeClass()
      Description copied from interface: JavaType
      Get the Java type (the Class object) described by this JavaType.
      Specified by:
      getJavaTypeClass in interface JavaType<J>
      See Also: