# NPE when using CompositeUserType with generic fields in Hibernate 6

**URL:** <https://discourse.hibernate.org/t/npe-when-using-compositeusertype-with-generic-fields-in-hibernate-6/8121>\
**Category:** Hibernate ORM\
**Created:** [August 14, 2023, 11:06am UTC](https://discourse.hibernate.org/t/npe-when-using-compositeusertype-with-generic-fields-in-hibernate-6/8121 "2023-08-14T11:06:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![inflo](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@inflo](https://discourse.hibernate.org/u/inflo)\
**Post date:** [August 14, 2023, 11:06am UTC](https://discourse.hibernate.org/t/npe-when-using-compositeusertype-with-generic-fields-in-hibernate-6/8121/1 "2023-08-14T11:06:55Z")

</div>

After migrating from hiberante 5.1.2 to hibernate 6.2.6 as i understand it, i must used CompositeUserType (instead of userType) to map 2 columns to one object. It’s all working great BUT if this object contains generic fields then i get NPE:

```auto
Caused by: java.lang.NullPointerException: Cannot invoke "[I.clone()" because "original.originalPropertyOrder" is null
	at org.hibernate.mapping.Component.<init>(Component.java:121) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
	at org.hibernate.mapping.Component.copy(Component.java:137) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
	at org.hibernate.boot.model.internal.ClassPropertyHolder.handleGenericComponentProperty(ClassPropertyHolder.java:246) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
	at org.hibernate.boot.model.internal.ClassPropertyHolder.addPropertyToPersistentClass(ClassPropertyHolder.java:264) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
	at org.hibernate.boot.model.internal.ClassPropertyHolder.addProperty(ClassPropertyHolder.java:217) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]

```

Sample code:  
Entity:

```auto
 @CompositeType(value = FooUserType.class)
    @AttributeOverrides({
            @AttributeOverride(name = "type", column = @Column(name = "column1", updatable = false)),
            @AttributeOverride(name = "json", column = @Column(name = "column2", updatable = false, columnDefinition = "clob"))
    })
    protected Foo foo;

```

FooUserType:

```auto
public class FooUserType implements CompositeUserType<Foo> {
}

```

Foo:

```auto
public class Foo<T extends Enum<T>> implements AnotherInterface<T> {

    private final T type;

    private String revision;

```

---

<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:** [August 14, 2023, 1:38pm UTC](https://discourse.hibernate.org/t/npe-when-using-compositeusertype-with-generic-fields-in-hibernate-6/8121/2 "2023-08-14T13:38:21Z")

</div>

Looks like a bug. Please create an issue in the issue tracker([https://hibernate.atlassian.net](https://hibernate.atlassian.net)) with a test case([https://github.com/hibernate/hibernate-test-case-templates/blob/master/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java](https://github.com/hibernate/hibernate-test-case-templates/blob/master/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java)) that reproduces the issue.

---

<div class="post-metadata">

**Author:** ![inflo](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@inflo](https://discourse.hibernate.org/u/inflo)\
**Post date:** [August 14, 2023, 2:51pm UTC](https://discourse.hibernate.org/t/npe-when-using-compositeusertype-with-generic-fields-in-hibernate-6/8121/3 "2023-08-14T14:51:11Z")

</div>

[https://hibernate.atlassian.net/browse/BVAL-788](https://hibernate.atlassian.net/browse/BVAL-788)

---

<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:** [August 15, 2023, 7:46am UTC](https://discourse.hibernate.org/t/npe-when-using-compositeusertype-with-generic-fields-in-hibernate-6/8121/4 "2023-08-15T07:46:02Z")

</div>

Thanks, but for the next time, please make sure the correct project is selected for an issue that you want to create. The Hibernate ORM project (short name HHH in JIRA) is what you should have selected. The Bean Validation project is for Jakarta Bean Validation specification topics.

---

<div class="post-metadata">

**Author:** ![inflo](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@inflo](https://discourse.hibernate.org/u/inflo)\
**Post date:** [August 16, 2023, 6:29am UTC](https://discourse.hibernate.org/t/npe-when-using-compositeusertype-with-generic-fields-in-hibernate-6/8121/5 "2023-08-16T06:29:03Z")

</div>

My mistake. I will pay attention next time
