2 Replies Latest reply on Sep 2, 2001 9:11 AM by Colin Vella

    Custom data types

    Colin Vella Newbie

      [Using Jboss 2.2.2 with mySQL]
      I am in the understanding that it is possible to have bean attributes that are not "primitive" types and these are typically mapped to BLOB fields in a database.

      I would like to have such a data type, essentially a multi-lingual string that contains text in various languages. I would like to have this stored as a mySQL TEXT or BIGTEXT database column so I can easily import,export or view the data if required. I was thinking of an XML format like


      The Horse
      Le Cheval
      Il Cavallo


      Has anybody worked with custom data types on Jboss.. the documentation seems very terse on this topic!

      Actual pieces of code would be most welcome!

      Cheers,
      Nemesis

        • 1. Re: Custom data types
          Jason Newbie

          Hi!

          I know this totally isn't the answer you were looking for, but I wanted to make a quick comment... I think that rather than creating a custom datatype it would be a lot easier and possibly more efficient to just utilize another column or table in your DB to represent the different languages... For example:


          LanguageTable:
          LanguageID
          Language


          WordTable:
          WordID
          LanguageID (FK from LanguageTable)
          Word

          ..the primary key in WordTable would be a combination of WordID and LanguageID.... Here is an example of what might be in the tables:

          LanguageTable:
          1 | English
          2 | French
          3 | Italian

          WordTable:
          1 | 1 | Horse
          1 | 2 | Le Cheval
          1 | 3 | Il Cavallo
          2 | 1 | Mouse
          2 | 2 | Le Souris


          ....etc. (I have to stop there because I don't know the italian for mouse lol)

          An advantage of achieving your goal this way (or a similar way, depending on your application) would give you the added benefit of Indexes and ability to search and use relationships, which is really what the DB is best at...

          Not sure if you are hardcore about making your new datatype, but I wanted to post this as an alternative. If you do find a solution, please be sure and let us all know!

          • 2. Re: Custom data types
            Colin Vella Newbie

            Jason,

            Thanks for your comments. I actually did consider an idea similar to yours, however, since I will have several entities (i.e. tables) all of which require fields with multi-lingual text, it would at least double my database schema in size and incur several extra relationships complicating matters further.

            So far I have managed to set up a new data type in JAWS that mapps a new String type (LongString) to a TEXT type in mySQL. The problem is now to override the serialization methods so they don't store all the class signatures etc apart from the data! I'm posting a new question on the matter: "Persistence of Custom Data Types".