question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When fetching a List backed by a NULL PostgreSQL array, a NPE is thrown

See original GitHub issue

I have PostgreSQL table with the following column:

previous_names VARCHAR(255)[] DEFAULT NULL

and mapped it to:

@Entity
@TypeDefs({
        @TypeDef(name = "string-array", typeClass = StringArrayType.class)
})
public class Project {

    @Column(name = "previous_names")
    @Type(type = "string-array")
    private List<String> previousNames = new ArrayList<>();
}

When querying this entity I get:

java.lang.NullPointerException: null
        at java.base/java.lang.reflect.Array.newArray(Native Method) ~[na:na]
        at java.base/java.lang.reflect.Array.newInstance(Array.java:78) ~[na:na]
        at com.vladmihalcea.hibernate.type.array.internal.ArrayUtil.unwrapArray(ArrayUtil.java:199) ~[hibernate-types-52-2.9.0.jar:na]
        at com.vladmihalcea.hibernate.type.array.internal.AbstractArrayTypeDescriptor.wrap(AbstractArrayTypeDescriptor.java:83) ~[hibernate-types-52-2.9.0.jar:na]
        at com.vladmihalcea.hibernate.type.array.internal.ArraySqlTypeDescriptor$2.doExtract(ArraySqlTypeDescriptor.java:55) ~[hibernate-types-52-2.9.0.jar:na]
        at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47) ~[hibernate-core-5.4.9.Final.jar:5.4.9.Final]

I just upgraded from 2.8.0 to 2.9.0 to be able to map List<String> types instead of String[].

Do I need some other configuration maybe?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
vladmihalceacommented, Jan 14, 2020

I released the 2.9.1 version. You can check it out from Maven Central as soon as it’s synced with Sonatype.

0reactions
marceloverdijkcommented, Jan 14, 2020

That would be appreciated (if you have time to do it).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting null pointer exception while mapping the jooq record ...
In the above scenario, the fetchSingle has to throw NoDataFoundException when there is no record to which matches the given criteria(user.id.eq( ...
Read more >
Documentation: 15: 8.15. Arrays - PostgreSQL
To set an element of an array constant to NULL, write NULL for the element value. (Any upper- or lower-case variant of NULL...
Read more >
Java NullPointerException - Detect, Fix, and Best Practices
Throwing null in the program; Accessing index or modifying value of an index ... NullPointerException when getting the length of null array.
Read more >
Hibernate ORM 5.4.33.Final User Guide - Red Hat on GitHub
For Hibernate mapping features not supported by JPA we will prefer Hibernate ... session) throws HibernateException, SQLException { if ( value == null...
Read more >
The jOOQ Release Note History
#11597, ArrayTable doesn't pass derived column list to ... #11750, TO_CHAR(x) without format is not natively supported in PostgreSQL.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found