Re: Store BitSet

From: Tore Halset (halse..vv.ntnu.no)
Date: Fri Mar 09 2007 - 15:07:30 EST

  • Next message: Peter Karich: "Re: AW: Store BitSet"

    Hello Peter.

    On Mar 8, 2007, at 23:39, Peter Karich wrote:

    > I want to store (and read) a BitSet into (from) the database.
    > The long[] array is private and I don't want to hack it by using
    > reflection or even store this as String with toString :-)

    It depend on how you want to store it in the database. PostgreSQL has
    a bit string datatype

    http://www.postgresql.org/docs/8.2/interactive/datatype-bit.html

    Then you create a Extended Type to tell cayenne how to store and
    fetch this data type in your application

    http://cayenne.apache.org/doc20/extended-types.html

    Depending on your jdbc-driver, you may have to encode the bits as a
    String in your Extended Type before sending it to the database. This
    is currently the case for PostgreSQL, but this may change in the future.

    > So, how can I transform any object to a byte[] array and vice versa??

    Serialization, but your data will then only be usable from java. You
    can not use it in a (db-side) query and so on.

    Good luck!

    Regards,
      - Tore.



    This archive was generated by hypermail 2.0.0 : Fri Mar 09 2007 - 15:07:52 EST