When fetching a List backed by a NULL PostgreSQL array, a NPE is thrown
See original GitHub issueI 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:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I released the
2.9.1
version. You can check it out from Maven Central as soon as it’s synced with Sonatype.That would be appreciated (if you have time to do it).