You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Chris Gamache <cg...@gmail.com> on 2007/09/18 19:45:40 UTC

PostgreSQL custom data type

I'm having a terrible time getting Cayenne to properly handle columns
of type uniqueidentifier. I can select data from columns which are
type uniqueidentifier, but I can not insert. I've tried different
combinations of Java type String versus Java type UUID and
Types.VARCHAR versus Types.OTHER.

Please help if you can! Thanks!

Re: PostgreSQL custom data type

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Sep 19, 2007, at 5:29 PM, Chris Gamache wrote:

> I think I have this cat skinned... After exhausting all avenues of
> getting this to work without any modifications, I broke down and
> created and registered a new ExtendedType to process java.util.UUID.
> It wasn't difficult at all. (That's a hallmark of a good, extendable,
> design and easy to read docs. Kudos to the Cayenne developers!)

Very cool. Yeah - if there is a way to read/write a value via JDBC,  
Cayenne should be able to accommodate it.

So are you simply using PreparedStatement.setObject(..) and pass  
UUID, or you convert UUID to something else (String?) before doing that?

> I'd be happy to make my ExtendedType class available to anyone who
> might like to use it.

I was thinking of including an ExtendedType for UUID in Cayenne core.  
Although I guess we'll have to convert it to a "JDBC primitive" for  
DB's other than Postgres. So I guess you can open an improvement  
request in Jira and attach your code to it.

Thanks
Andrus

Re: PostgreSQL custom data type

Posted by Chris Gamache <cg...@gmail.com>.
On 9/19/07, Andrus Adamchik <an...@objectstyle.org> wrote:
> Hi Chris,
>
> I couldn't find definitive docs on the nature of uniqueidentifier
> type (Is there any?) From what little I've found, "uniqueidentifier"
> is a binary value. So could you try to map it a Types.VARBINARY on DB
> end and "byte[]" on the Java end?

No really good docs. I'm currently using the contrib version of
uniqueidentifier (heavily patched), but there will be a native
uniqueidentifier type in the next release probably not based on the
contrib code.

I think I have this cat skinned... After exhausting all avenues of
getting this to work without any modifications, I broke down and
created and registered a new ExtendedType to process java.util.UUID.
It wasn't difficult at all. (That's a hallmark of a good, extendable,
design and easy to read docs. Kudos to the Cayenne developers!)

First, I'm using the JDBC connection string parameter
"stringtype=unspecified" to leave off the direct casting for quoted
strings. I'm using Types.OTHER when communicating with JDBC.

It has passed my unit tests heretofore.

I'd be happy to make my ExtendedType class available to anyone who
might like to use it.

The only thing missing is the ability to register the ExtendedType in
the XML config, which the docs report is a feature which is planned
for the future.

Re: PostgreSQL custom data type

Posted by Andrus Adamchik <an...@objectstyle.org>.
Hi Chris,

I couldn't find definitive docs on the nature of uniqueidentifier  
type (Is there any?) From what little I've found, "uniqueidentifier"  
is a binary value. So could you try to map it a Types.VARBINARY on DB  
end and "byte[]" on the Java end?

Let us know how that worked.

Andrus


On Sep 18, 2007, at 8:45 PM, Chris Gamache wrote:

> I'm having a terrible time getting Cayenne to properly handle columns
> of type uniqueidentifier. I can select data from columns which are
> type uniqueidentifier, but I can not insert. I've tried different
> combinations of Java type String versus Java type UUID and
> Types.VARCHAR versus Types.OTHER.
>
> Please help if you can! Thanks!
>