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