|
|
|
|
Re: Saving to array not working [message #1804165 is a reply to message #1742461] |
Tue, 19 March 2019 15:30 |
Satya R Messages: 4 Registered: January 2018 |
Junior Member |
|
|
I am testing with EclipseLink 2.7.4 and PostgreSQL JDBC driver 42.2.5 with Spring Boot 2.1.3.
This feature if worked would have been great to avoid lot of boilerplate converter code. However this is not working (atleast for me)
If I declare the entity with
@Array(databaseType = "text[]")
private List<String> plans;
The JDBC driver method createArrayOf in org.postgresql.jdbc.PgConnection complains.
public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
checkClosed();
int oid = getTypeInfo().getPGArrayType(typeName);
if (oid == Oid.UNSPECIFIED) {
throw new PSQLException(
GT.tr("Unable to find server array type for provided name {0}.", typeName),
PSQLState.INVALID_NAME);
}
So I changed to
@Array(databaseType = "text")
private List<String> plans;
However, beyond that when null/empty collection is being set to this, the code in EclipseLink seems to loose type info:
org.eclipse.persistence.mappings.foundation.AbstractCompositeDirectCollectionMapping.writeFromObjectIntoRow(...)
line 623:
Object fieldValue = null;
if (!elements.isEmpty()) {
fieldValue = this.getDescriptor().buildFieldValueFromDirectValues(elements, elementDataTypeName, session);
}
row.put(this.getField(), fieldValue);
on db side:
column "plans" is of type text[] but expression is of type text at character 211
If I force in debug session to compute fieldValue, the error isn't coming.
Anyways, these are observations spending couple of hours. Question is, is this working as documented?
Can this be addressed?
|
|
|
|
Re: Saving to array not working [message #1805193 is a reply to message #1804171] |
Tue, 09 April 2019 16:20 |
Chris Delahunt Messages: 1389 Registered: July 2009 |
Senior Member |
|
|
Have you tried using the @Array(databaseType="varchar") annotation mentioned above? You might still get the null issue as EclipseLink doesn't know NULL is a collection type, and only has the field type to go by ('text' or 'varchar') to pass to the driver for null typing.
What JDBC driver versions are you using, and how do they state to specify the type?
> edit, I didn't notice you posted the JDBC driver version. EclipseLink docs though haven't been updated in quite some time, so this might be due to behaviour changes from when the feature was first added/tested within the driver itself.
[Updated on: Tue, 09 April 2019 16:24] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04884 seconds