2 Replies Latest reply on Aug 11, 2006 8:57 AM by Dominique CLAIRAC

    How to set default mapping to TEXT instead of VARCHAR(255)

    Matt C Newbie

      How do I set the default mapping of entity bean fields of type String to VARCHAR or TEXT instead of VARCHAR(255) on PostgreSQL and MySQL databases?
      I do not want an arbitrary 255 char limit to the length of a varchar string.

      I read a post which suggested using an annotation to set the @Length to 256 or greater which makes it use a text field, but I do not want to declare this on every string field.

        • 1. Re: How to set default mapping to TEXT instead of VARCHAR(25
          Matt C Newbie

          Rather than TEXT I meant I want to set the default to VARCHAR(unlimited length).

          Is this possible?

          • 2. Re: How to set default mapping to TEXT instead of VARCHAR(25
            Dominique CLAIRAC Newbie

            I have the same problem (I have to store a VARCHAR(5000) on MySQL 4 (witch as WARCHAR limited to 255)).

            I'm not sure it will work but I have found that the mapping file is in :

            $JBOSS_HOME\serveur\default\conf\standardjbosscmp-jdbc.xml

            You have the mapping for each type of Bdd.
            For my case, I have change the

            <type-mapping>
             <name>mySQL</name>
             ...
             <mapping>
             <java-type>java.lang.String</java-type>
             <jdbc-type>VARCHAR</jdbc-type>
             <sql-type>VARCHAR(250) BINARY</sql-type>
             </mapping>
            </type-mapping>

            by :
            <type-mapping>
             <name>mySQL</name>
             ...
             <mapping>
             <java-type>java.lang.String</java-type>
             <jdbc-type>VARCHAR</jdbc-type>
             <sql-type>TEXT</sql-type>
             </mapping>
            </type-mapping>

            It seams to work fine after a Jboss reboot.

            Dont forget to select your database type in your xxx-ds.xml file
            <metadata>
             <type-mapping>mySQL</type-mapping>
            </metadata>