Re: Persisting a HashTable

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Jun 16 2005 - 17:51:02 EDT

  • Next message: Mike Kienenberger: "vertical inheritance by templating"

    On Jun 16, 2005, at 3:16 PM, Dhruti Ramani wrote:

    > Hi,
    >
    > I would like to persist a hashtable that will map strings to
    > Booleans("option1",new Boolean(true)). Is there a way to do this in
    > cayenne? Or is there any other way to store key and value ?
    > Database that I am using is postgresql.
    >
    > Thanks,
    >
    > Denna

    Denna,

    If you don't need to query on individual keys, you can serialize the
    whole hashtable as a CLOB field. You can use java.util.Properties
    class (or any of the open source enhancements of it), but if you know
    that all your fields are always boolean, you can create a much
    simpler custom serialization scheme. E.g. store key/value pairs as a
    delimited string ( key1=1;key2=0;key3=0... etc..)

    Or you can define two tables - one to store each hashtable (really
    just an id), and another one to store its key/value pairs. table1
    will have a one-to-many relationship to table2.

    Andrus



    This archive was generated by hypermail 2.0.0 : Thu Jun 16 2005 - 17:51:04 EDT