Re: Register arbitrary types Framework

From: Kris Jurka <books(at)ejurka(dot)com>
To: Markus Schaber <schabios(at)logi-track(dot)com>
Cc: PostGreSQL JDBC <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Register arbitrary types Framework
Date: 2004-03-11 05:55:20
Message-ID: Pine.BSO.4.56.0403110045001.101@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Wed, 10 Mar 2004, Markus Schaber wrote:

> Hello @all,
>
> For my project, I need to register third-party classes as postgres
> classes, (specifically, I want JTS objects to be directly created when
> calling getObject(int)) and it is not eligible to patch those
> third-party classes.
>
> However, the current user-type register system only allows subtypes of
> PGObject to be registered. I have two Ideas on how to change this,
> whereas I would prefer the second one, and am willing to write and
> provide patches for both of them if they are to be accepted:
>
> - When a registered object is no subclass of PGObject, use the
> constructor that uses a single String as arguments for reading and
> toString() for writing.
>
> - Allow instances of a factory Interface to be registered to the
> PostGreSQL connection. Then, when reading this type, a creator function
> of the factory is called, and when writing, we can use a map to find the
> factory from the object's class.
>

I see what you are getting at, but I don't see this as all that useful.
How is this much better than creating a PGObject adapter class to bridge
the differences between your object and the driver? Wouldn't you need to
make some kind of modification to the JTS object when doing a setObject()
call? I find it difficult to see its toString() implementation mapping
directly to a pg server side type.

The JDBC spec provides another type mapping interface based on SQLData.
This is more focused on complex types, but we could do something like only
allowing one read or write call per SQLInput/SQLOutput object. This still
doesn't solve your problem because it needs to implement SQLData.

Perhaps you could give us some more specifics on the database types
involved and why getObject has to return an instance of your object
instead of an intermediary.

Kris Jurka

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Markus Schaber 2004-03-11 12:27:22 Re: Register arbitrary types Framework
Previous Message Dave Cramer 2004-03-10 19:15:39 Re: Backup of users and groups?