Class YearMonthJavaType

java.lang.Object
org.hibernate.type.descriptor.java.AbstractClassJavaType<YearMonth>
io.leandev.appfuse.internal.jpa.YearMonthJavaType
All Implemented Interfaces:
Serializable, org.hibernate.type.descriptor.java.BasicJavaType<YearMonth>, org.hibernate.type.descriptor.java.JavaType<YearMonth>

public final class YearMonthJavaType extends org.hibernate.type.descriptor.java.AbstractClassJavaType<YearMonth>

YearMonth 的 Hibernate 基本型別映射:以 ISO 8601 YYYY-MM 字串存成 VARCHAR(7)。

Hibernate 沒有內建 YearMonth 映射,未處理時會退回 Java 序列化存成二進位欄位, 無法以 SQL 比較或排序。YYYY-MM 與 JSON wire format 一致,且字典序等於時間序, 區間查詢與排序可直接在資料庫進行。

刻意不用 JPA @Converter(autoApply = true):converter 會被應用的 entity scan 掃到, 與框架自動註冊重複時 Hibernate 拒絕啟動;JavaType 不參與 entity scan。

See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.hibernate.type.descriptor.java.JavaType

    org.hibernate.type.descriptor.java.JavaType.CoercionContext
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final YearMonthJavaType
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    long
    getDefaultSqlLength(org.hibernate.dialect.Dialect dialect, org.hibernate.type.descriptor.jdbc.JdbcType jdbcType)
     
    org.hibernate.type.descriptor.jdbc.JdbcType
    getRecommendedJdbcType(org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators indicators)
     
     
    <X> X
    unwrap(YearMonth value, Class<X> type, org.hibernate.type.descriptor.WrapperOptions options)
     
    wrap(X value, org.hibernate.type.descriptor.WrapperOptions options)
     

    Methods inherited from class org.hibernate.type.descriptor.java.AbstractClassJavaType

    areEqual, extractHashCode, extractLoggableRepresentation, getComparator, getJavaType, getJavaTypeClass, getMutabilityPlan, unknownUnwrap, unknownWrap

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.hibernate.type.descriptor.java.JavaType

    appendEncodedString, cast, coerce, createJavaType, fromEncodedString, fromEncodedString, getCheckCondition, getDefaultSqlPrecision, getDefaultSqlScale, getDefaultValue, getLongSqlLength, getReplacement, getTypeName, isInstance, isTemporalType, isWider, useObjectEqualsHashCode
  • Field Details

  • Method Details

    • getRecommendedJdbcType

      public org.hibernate.type.descriptor.jdbc.JdbcType getRecommendedJdbcType(org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators indicators)
    • getDefaultSqlLength

      public long getDefaultSqlLength(org.hibernate.dialect.Dialect dialect, org.hibernate.type.descriptor.jdbc.JdbcType jdbcType)
    • toString

      public String toString(YearMonth value)
    • fromString

      public YearMonth fromString(CharSequence string)
    • unwrap

      public <X> X unwrap(YearMonth value, Class<X> type, org.hibernate.type.descriptor.WrapperOptions options)
    • wrap

      public <X> YearMonth wrap(X value, org.hibernate.type.descriptor.WrapperOptions options)