From: | Dave Cramer <davecramer(at)postgres(dot)rocks> |
---|---|
To: | Bhavesh Mistry <bhavesh(dot)mistry13(at)gmail(dot)com> |
Cc: | Discuss List Postgres <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Issue with PSQL JDBC Driver Null Pointer |
Date: | 2021-07-29 15:44:12 |
Message-ID: | CADK3HHL_7FHt6TqrB5ytE1kRyirHi2=J7HU1gszScSu8uoWk3g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, 29 Jul 2021 at 11:04, Bhavesh Mistry <bhavesh(dot)mistry13(at)gmail(dot)com>
wrote:
> Hello,
>
> I am getting an NPE exception in the JDBC driver 42.2.23.
>
> When the alias is null, NPE results. Is it possible to handle null value
> ? I have filled a bug against RCA
> https://github.com/vladmihalcea/hibernate-types/issues/335. But, I
> thought that PSQL Driver can handle it more gracefully.
>
> Caused by: java.lang.NullPointerException: null
> at org.postgresql.jdbc.TypeInfoCache.getTypeForAlias(TypeInfoCache.java:675)
> at org.postgresql.jdbc.TypeInfoCache.getPGArrayType(TypeInfoCache.java:519)
> at org.postgresql.jdbc.PgConnection.createArrayOf(PgConnection.java:1375)
> at org.postgresql.jdbc.PgConnection.createArrayOf(PgConnection.java:1399)
> at org.apache.commons.dbcp2.DelegatingConnection.createArrayOf(DelegatingConnection.java:827)
> at org.apache.commons.dbcp2.DelegatingConnection.createArrayOf(DelegatingConnection.java:827)
> at org.apache.commons.dbcp2.DelegatingConnection.createArrayOf(DelegatingConnection.java:827)
> at com.vladmihalcea.hibernate.type.array.internal.ArraySqlTypeDescriptor$1.doBind(ArraySqlTypeDescriptor.java:36)
> at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:73)
> at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:276)
> at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:271)
> at org.hibernate.type.AbstractSingleColumnStandardBasicType.nullSafeSet(AbstractSingleColumnStandardBasicType.java:39)
> at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2995)
> at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3292)
> at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3828)
> at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:107)
> at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
> at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:478)
> at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
> at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:475)
> at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:348)
> at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:40)
> at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:102)
> at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1362)
> at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:453)
> at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3212)
> at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2380)
> at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:447)
> at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:183)
> at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:40)
> at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:281)
> at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101)
> ... 123 common frames omitted
>
> public String getTypeForAlias(String alias) {
> String type = typeAliases.get(alias);
> if (type != null) {
> return type;
> }
> if (alias.indexOf('"') == -1) { *// THIS LINE THROWS NPE SINCE alias is null ** *
> type = typeAliases.get(alias.toLowerCase());
> if (type != null) {
> return type;
> }
> }
> return alias;
> }
>
>
> It would appear that improv: type alias handling in TypeInfoCache by
bokken · Pull Request #1986 · pgjdbc/pgjdbc (github.com)
<https://github.com/pgjdbc/pgjdbc/pull/1986>
should be backpatched into 42.2.24 which should solve this problem
Thanks,
Dave
>
> --
> Thanks,
>
> Bhavesh
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Matthias Apitz | 2021-07-29 17:30:00 | Re: PostgreSQL reference coffee mug |
Previous Message | Tom Kazimiers | 2021-07-29 15:12:48 | Re: Updating PK and all FKs to it in CTE |