[ http://jira.andromda.org/browse/CORE-95?page=comments#action_12263 ] Tomasz Bech commented on CORE-95: ---------------------------------
I had this idea, but it is painfull and hardly maintenable for one reason - for all possible varchar length-ranges the SpecialString should be created. And the developer should remember the exact length-range for the type. Example: SmallString, length: 1-254 (oracle-varchar, informix-varchar) MediumString, length 255-4000 (oracle-varchar, informix-lvarchar) LongerMediumString :), length 4001-32727 (oracle-clob, informix-lvarchar) LongString, length 32728- (oracle-clob, informix-text/clob) What if on some stage I have to generate the hibernate for database X which has following support: varchar, length 1-1000 clob, length 1001- ? So the MediumString should be divided more for: Medium1String, length 255-1000 Medium2String, length 1001-4000 And the model changed in every case when MediumString appears. So for now I decided to handle the conditional type based on length on Velocity template level in some hardcoded way, so there will be no need to modify model. BTW: My first idea was to let the hibernate to choose the type, but they don't do such handling unluckily, what a pity. > Better handling short, long, very long String types per DB type > --------------------------------------------------------------- > > Key: CORE-95 > URL: http://jira.andromda.org/browse/CORE-95 > Project: AndroMDA Core > Type: Improvement > Reporter: Tomasz Bech > Assignee: Chad Brandon > > 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