Re: Custom array column types in EO model
Re: Custom array column types in EO model
- Subject: Re: Custom array column types in EO model
- From: Ramsey Gurley via Webobjects-dev <email@hidden>
- Date: Wed, 2 Nov 2022 07:25:17 +0000
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=practicemojo.com; dmarc=pass action=none header.from=practicemojo.com; dkim=pass header.d=practicemojo.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cBOMknv5ajCgqaUY+bNHOlpUd/3NJw34pcZLZ5xv0Wc=; b=kWSZq3ylwUjDdycM7FLy4SA6ns4lnkJQF0IYF9RIej2RYaTMwW5sH3GMwmRakgd5ax3EOu68NwgbtoIsUjRBy+/Z/Fajq7UPsTtMljFzJ8NBAnMIZn4QCWxdzW/fEOTQzMwbIVugxIQ4biGp7Xsq18L38KzyoKu3zSh4YVbNU8Nn2GNcjVSuiNWYZusKF1XuTEvlkagNtbiIG7CR83sinBSf5TdQHIEPit2IZIM1tUFNVtJ2aF/lWcdE5pnJjdzQr6Uj6F23UtkNlOX5T4sYqgxar86CNC8YkVKTSAMsHZLCSpOtgftraWEAzaw9vV9vQhLAjZE3kWjDnq4agV7hpw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CbDQtNtOoIX+Qt+xpEgk4Y51QgAoIbMQcqxQ8+MPylKHByDdLCGgOWpgGl8k1355yTDU61ZBKGAxEyahvRgFjwOL6Kk/yRd411kGQ5a4qfoAKNVSEaGiXdGs7cXzJiSRvkPCHg0dhn30+sLzB4VsIARd2k5gwfSoXGIvKa9A1CWtze9ay88KBjFj4HavxztC86hoeFFXaWN9lHG1161cXrvuUKWBpfXNriAEOdmPaB6oHprBQxCkMtzdNcRPnvPJqJmdGPVsqFWxpuJ9csejISju72QX7iY8Qut+FYQilRoQE6Y+I+dXpXrEIrKkP0KbizbL/zpwHFstW0MxfKMnXQ==
- Msip_labels:
- Thread-topic: Custom array column types in EO model
I can't say I remember, but if you look in
adaptorValueByConvertingAttributeValue on EOAttribute in ERAttributeExtension,
there's a bit at the end of the method where I let the date types slide by to
support Joda dates. You may have to add support for it there, as that is where
your exception appears to be emanating from.
________________________________
From: Paul Hoadley via Webobjects-dev <email@hidden>
Sent: Tuesday, November 1, 2022 10:43 PM
To: WebObjects-Dev List <email@hidden>
Subject: Custom array column types in EO model
Hello,
I'm trying to get this to work for PostgreSQL, though I suspect it would be
similar for any RDBMS that offered a type like "text[]":
https://www.postgresql.org/docs/current/arrays.html<https://nam12.safelinks.protection.outlook.com/?url=https://www.postgresql.org/docs/current/arrays.html&data=05|01|email@hidden|c1b9a30d9f6343ee9f1008dabc9530ad|de0a512999d34d35a92809047a134775|1|0|638029646218988341|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0=|3000|||&sdata=1zm7UcuY5fc9VNsK5UTok/UthdT0zyL7lK7HOq8Ix9Y=&reserved=0>
Ideally, I'd like to map an NSArray<String> attribute on the model side to a
text[] column in Postgres, though any variation on this would be a good start.
I can't quite get there, even with the smarts added by ERAttributeExtension.
This is as close as I can get:
{
adaptorValueConversionClassName =
"net.logicsquad.woextensions.eof.LSValueConversion";
adaptorValueConversionMethodName = stringArrayToPostgreSQLTextArray;
allowsNull = Y;
columnName = "metadata_key_list";
externalType = anyarray;
name = metadataKeyList;
valueClassName = "com.webobjects.foundation.NSArray";
valueFactoryClassName =
"net.logicsquad.woextensions.eof.LSValueConversion";
valueFactoryMethodName = arrayToStringArray;
},
I'm only working on the output side for the minute. LSValueConversion.
stringArrayToPostgreSQLTextArray(NSArray<String>) returns a subclass of
java.sql.Array, which I assume is what the Postgres JDBC driver wants. However,
when I try to save an object, it's EOAttribute that complains:
[2022-11-2 5:31:59 UTC] <main>
com.webobjects.eoaccess.EOGeneralAdaptorException: EOAttribute
adaptorValueByConvertingAttributeValue(Object): Unable to convert value of
class net.logicsquad.woextensions.eof.PostgresqlTextArray for attribute
'metadataKeyList' in entity 'DocumentVersion' to adaptor type
EOAttribute.AdaptorBytesType. Check the signature of the conversion method
com.webobjects.foundation.NSArray.stringArrayToPostgreSQLTextArray().
To my eye, that's suggesting that the conversion method is not producing an
object of type "bytes", which is true enough—it's a subclass of java.sql.Array.
It doesn't help to comment out the part of EOAttribute that's throwing that
exception, either:
2022-11-02 05:40:58.728 WARN NSLog - A fatal exception occurred: Unable to
create a byte representation for class
"net.logicsquad.woextensions.eof.PostgresqlTextArray"
At this point I'm out of ideas. Has anyone done this or anything like it?
--
Paul Hoadley
https://logicsquad.net/<https://nam12.safelinks.protection.outlook.com/?url=https://logicsquad.net/&data=05|01|email@hidden|c1b9a30d9f6343ee9f1008dabc9530ad|de0a512999d34d35a92809047a134775|1|0|638029646218988341|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0=|3000|||&sdata=/OeU7BTGMvw7tM1gbMkB73QMCiQHZAHYX3h54OGF6wY=&reserved=0>
https://www.linkedin.com/company/logic-squad/
________________________________
Confidentiality Notice: This email, including all attachments and replies
thereto, are covered by the Electronic Communications Privacy Act, 18 U.S.C.
Sections 2510-2521 and are legally privileged. This information is
confidential, and intended only for the use of the individuals or entities
named above. If you are not the intended recipient, you are hereby notified
that any disclosure, copying, distribution or the taking of any action in
reliance on the contents of this transmitted information is strictly
prohibited. Please notify us if you have received this transmission in error.
Thank you.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden