Better handling short, long, very long String types per DB type
---------------------------------------------------------------

         Key: HIB-149
         URL: http://jira.andromda.org/browse/HIB-149
     Project: Hibernate Cartridge
        Type: Improvement
    Versions: 3.1-RC1    
    Reporter: Tomasz Bech
 Assigned to: Carlos Cuenca 


Different databases have different support for the varchar type. For example:
Oracle: VARCHAR to 4000, longer texts must be as CLOB
Informix: VARCHAR to 254, longer texts as CLOB or TEXT or LVARCHAR.
But currently there is no way to have one model and several mapping for DB as 
there is no conditional mapping in Mapping file.
It would be nice to achieve:
    <mapping>
        <from>datatype::String</from>
        <to>VARCHAR2(255)</to>
        <condition>columnLength < 255</condition>
    </mapping>
    <mapping>
        <from>datatype::String</from>
        <to>VARCHAR2(4000)</to>
        <condition>columnLength <= 4000</condition>
    </mapping>
    <mapping>
        <from>datatype::String</from>
        <to>CLOB</to>
        <condition>columnLength >4000</condition>
    </mapping>
And for Informix database (btw. there is no Informix support currently in 
AndorMDA, but the same issue is for PostgreSQL):
    <mapping>
        <from>datatype::String</from>
        <to>VARCHAR2(255)</to>
        <condition>columnLength < 255</condition>
    </mapping>
    <mapping>
        <from>datatype::String</from>
        <to>LVARCHAR2(32726)</to>
        <condition>columnLength <= 32726</condition>
    </mapping>
    <mapping>
        <from>datatype::String</from>
        <to>CLOB</to>
        <condition>columnLength > 32726</condition>
    </mapping>

IMO is should be done in mapping file and not hardcoded in java. The above is 
just suggestion, maybe there is simpler way to achieve this feature.




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php

Reply via email to