more docs for type package

This commit is contained in:
Gavin 2022-12-29 21:57:30 +01:00 committed by Gavin King
parent c829c84d55
commit aef9d064db
2 changed files with 28 additions and 6 deletions

View File

@ -55,7 +55,8 @@
* These two approaches cannot be used together. A {@code UserType} always takes precedence
* over the compositional approach.
* <p>
* Please see the User Guide for a more in-depth discussion.
* Please see the <em>User Guide</em> or the package {@link org.hibernate.type} for a more
* in-depth discussion.
*
* <h2 id="basic-value-mapping">Dialect-specific native SQL</h2>
*

View File

@ -6,14 +6,35 @@
*/
/**
* A Hibernate {@link org.hibernate.type.Type} is a strategy for mapping
* a Java property type to a JDBC type or types. In modern Hibernate,
* {@code Type} itself is now of receding importance, and we prefer to
* work directly with the combination of:
* A Hibernate {@link org.hibernate.type.Type} is a strategy for mapping a Java
* property type to a JDBC type or types. In modern Hibernate, {@code Type} itself
* is now of receding importance, and we prefer to work directly with the combination
* of:
* <ul>
* <li>a {@link org.hibernate.type.descriptor.java.JavaType}, with a
* <li>a {@link org.hibernate.type.descriptor.java.JavaType}, with
* <li>a {@link org.hibernate.type.descriptor.jdbc.JdbcType}.
* </ul>
* <p>
* A {@code JdbcType} is able to read and write a single Java type to one, or
* sometimes several, {@linkplain org.hibernate.type.SqlTypes JDBC types}.
* <p>
* A {@code JavaType} is able to determine if an attribute of a given Java type is
* dirty, and then convert it to one of several other equivalent Java representations
* at the request of its partner {@code JdbcType}.
* <p>
* For example, if an entity attribute of Java type {@code BigInteger} is mapped to
* the JDBC type {@link java.sql.Types#VARCHAR}, the
* {@link org.hibernate.type.descriptor.jdbc.VarcharJdbcType} will ask its
* {@link org.hibernate.type.descriptor.java.BigIntegerJavaType} to convert instances
* of {@code BigInteger} to and from {@code String} when writing to and reading from
* JDBC statements and result sets.
* <p>
* This approach provides quite some flexibility in allowing a given Java type to
* map to a range of JDBC types. However, when the built-in conversions don't handle
* a particular mapping, a
* {@link org.hibernate.metamodel.model.convert.spi.BasicValueConverter} may assist
* in the conversion process. For example, a JPA
* {@link jakarta.persistence.AttributeConverter} might be provided.
*
* @see org.hibernate.type.Type
* @see org.hibernate.type.SqlTypes