1 Reply Latest reply on Nov 5, 2003 7:32 AM by randahl

    Persisting immutable objects

    randahl

      Hi

      I would like to persist immutable objects as rows in my database tables without using BLOBs. As we all know, Strings are immutable, and JBoss stores them as varchars. URLs are immutable too, and I would like JBoss to store them as varchars containing the textual representation of the URL ("http://asdfasdf.com") instead of putting a BLOB in my URL column.

      Is this possible?

      My own idea is to have two properties on my EJB, one called "url" and one called "urlString". The "urlString" is a CMP field of type "String", and the "url" property is of type URL and simply takes care of converting from the String property to a real URL. Quite easy, but I would prefer if this could be handled by configuration like when you configure dependent value classes.


      Thanks

      Randahl

        • 1. Re: Persisting immutable objects
          randahl

          and let me add: I would like to use this for storing type safe enumerations aswell. Lets say you have an enumeration called Level with values like

          Level.HIGH
          Level.MEDIUM
          Level.LOW

          I would like to know the best way to get this into a database column of an EJB containing the string values "HIGH", "MEDIUM", "LOW" instead of a BLOB.


          Randahl