# Some Hibernatw 6.0+ changes in Types, the point of which I don't understand

**URL:** <https://discourse.hibernate.org/t/some-hibernatw-6-0-changes-in-types-the-point-of-which-i-dont-understand/8924>\
**Category:** Hibernate ORM\
**Created:** [January 29, 2024, 12:08pm UTC](https://discourse.hibernate.org/t/some-hibernatw-6-0-changes-in-types-the-point-of-which-i-dont-understand/8924 "2024-01-29T12:08:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ralin](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/ralin/32/3212_2.png) [@Ralin](https://discourse.hibernate.org/u/Ralin)\
**Post date:** [January 29, 2024, 12:08pm UTC](https://discourse.hibernate.org/t/some-hibernatw-6-0-changes-in-types-the-point-of-which-i-dont-understand/8924/1 "2024-01-29T12:08:51Z")

</div>

I am in the process of migrating a project from 5.6 to Hibernate 6.3 and I am surprised by some of the changes. I will list them in order:

1. Why Type.class now doesn’t have the nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) method, although UserType.class kept it?
2. Why do StandardBasicTypes now contain instances of BasicTypeReference instead of AbstractStandardBasicType inheritors? As far as I understand from User Guide, AbstractStandardBasicType inheritors (e.g. StringType) have been replaced by NamedBasicTypeImpl. If I understand the meaning correctly, why are not their instances in StandardBasicTypes?
3. Why does CustomType now require explicit passing of TypeConfiguration? It’s not very convenient to get it to create custom types.

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [January 29, 2024, 12:53pm UTC](https://discourse.hibernate.org/t/some-hibernatw-6-0-changes-in-types-the-point-of-which-i-dont-understand/8924/2 "2024-01-29T12:53:55Z")

</div>

Read the [6.0 migration guide](https://github.com/hibernate/hibernate-orm/blob/6.0/migration-guide.adoc#type) which will answer a few of your questions.  
Overall, the design simply changed from `BasicType` driving the binding/extraction to fully splitting up the responsibility into `JavaType` and `JdbcType`. This means `BasicType` is not special anymore and that instances of such types are registered in the `BasicTypeRegistry` under the tuple of `JavaType`/`JdbcType`.  
You’re not supposed to create `CustomType` yourself. This is just a contract that Hibernate ORM uses internally to wrap the `UserType` into this type system, so that you don’t have to implement so many methods.

A lot has changed in ORM 6, so maybe you should start rethinking what you are doing and learn the new features to understand if you can rather use these to implement what you desire.

---

<div class="post-metadata">

**Author:** ![Ralin](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/ralin/32/3212_2.png) [@Ralin](https://discourse.hibernate.org/u/Ralin)\
**Post date:** [January 29, 2024, 1:25pm UTC](https://discourse.hibernate.org/t/some-hibernatw-6-0-changes-in-types-the-point-of-which-i-dont-understand/8924/3 "2024-01-29T13:25:46Z")

</div>

Thank you for your reply, I generally understand the gist of the changes you have written ( I have read the 6.0 migration guide), however the individual points present issues.

The one I wrote about NamedBasicTypeImpl. Despite the fact that this class, as stated in the migration guide, takes the role of BasicType implementations, it doesn’t have for example the nullSafeGet method I need, which takes an argument of ResultSet type. Why is it missing now? Previously, any BasicType had this variant nullSafeGet

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [January 29, 2024, 2:35pm UTC](https://discourse.hibernate.org/t/some-hibernatw-6-0-changes-in-types-the-point-of-which-i-dont-understand/8924/4 "2024-01-29T14:35:17Z")

</div>

Because `BasicType` is not in charge of binding/extraction anymore. The `JdbcType` along with the `JavaType` is now responsible for this.  
So if you want to adjust how Hibernate ORM interacts with `PreparedStatement`/`ResultSet`, you will have to either override an existing `JdbcType` or register a new one. You can either force a specific `JdbcType` by using e.g. `@JdbcType(MyJdbcType.class)` on an entity attribute, or register it under a type code, which is just a unique integer value usually corresponding to constants in `java.sql.Types`/`org.hibernate.type.SqlTypes`. Under that same code you can also register a custom `DdlType` and all of that through e.g. a `org.hibernate.boot.model.TypeContributor`.
