Thread: Correct way to send a composite type to Postgres
I have a composite type that is an IN parameter for a Stored Function. How do I construct the type in Java?
I know in Postgres I can do row(...) I was hoping for something a little more Javaish instead to having to build that String.
Can I extend PGObject to accomplish this?
Thanks,
Jason Tesser
dotCMS Lead Development Manager
1-305-858-1422
I know in Postgres I can do row(...) I was hoping for something a little more Javaish instead to having to build that String.
Can I extend PGObject to accomplish this?
Thanks,
Jason Tesser
dotCMS Lead Development Manager
1-305-858-1422
On Tue, 16 Feb 2010, Jason Tesser wrote: > I have a composite type that is an IN parameter for a Stored Function. How > do I construct the type in Java? > > I know in Postgres I can do row(....) I was hoping for something a little > more Javaish instead to having to build that String. > > Can I extend PGObject to accomplish this? Currently there isn't a great way to do this with the PG JDBC driver. You can encapsulate the ugliness with PGObject, but you can't avoid it. If you have a type that extends PGObject all you need to do is override the toString method to format the data as the server expects it. Kris Jurka
yea that is what i did. I was wondering though if there are gotchas here for escaping? Are here are Utilities in the driver I can use to make sure the data is escaped ok? any thoughts here.
I mean basically i did
public String getValue() {
return "(" + person.getId() + "," + person.getFirstName() + "," + person.getLastName() + "," + person.getMiddleName() + ")";
}
I mean basically i did
public String getValue() {
return "(" + person.getId() + "," + person.getFirstName() + "," + person.getLastName() + "," + person.getMiddleName() + ")";
}
On Thu, Feb 18, 2010 at 12:17 AM, Kris Jurka <books@ejurka.com> wrote:
Currently there isn't a great way to do this with the PG JDBC driver. You can encapsulate the ugliness with PGObject, but you can't avoid it. If you have a type that extends PGObject all you need to do is override the toString method to format the data as the server expects it.
On Tue, 16 Feb 2010, Jason Tesser wrote:I have a composite type that is an IN parameter for a Stored Function. How
do I construct the type in Java?
I know in Postgres I can do row(....) I was hoping for something a little
more Javaish instead to having to build that String.
Can I extend PGObject to accomplish this?
Kris Jurka