FAQ
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!

Search Discussions

  • Andrus Adamchik at Sep 19, 2007 at 9:16 am
    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!
  • Chris Gamache at Sep 19, 2007 at 2:29 pm

    On 9/19/07, Andrus Adamchik 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.
  • Andrus Adamchik at Sep 19, 2007 at 2:45 pm

    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedSep 18, '07 at 5:46p
activeSep 19, '07 at 2:45p
posts4
users2
websitecayenne.apache.org

2 users in discussion

Andrus Adamchik: 2 posts Chris Gamache: 2 posts

People

Translate

site design / logo © 2022 Grokbase