1 10 11 package com.triactive.jdo.store; 12 13 import com.triactive.jdo.PersistenceManager; 14 import java.sql.PreparedStatement ; 15 import java.sql.ResultSet ; 16 import java.sql.Types ; 17 18 19 public class OracleStringMapping extends StringMapping 20 { 21 static final String EMPTY_STRING_SURROGATE = "\u0001"; 22 23 public OracleStringMapping(DatabaseAdapter dba, Class type) 24 { 25 super(dba, type); 26 } 27 28 public OracleStringMapping(Column col) 29 { 30 super(col); 31 } 32 33 public OracleStringMapping(ClassBaseTable table, int relativeFieldNumber) 34 { 35 this(table.newColumn(relativeFieldNumber)); 36 } 37 38 protected TypeInfo getTypeInfo() 39 { 40 TypeInfo ti; 41 42 if (col == null) 43 ti = dba.getTypeInfo(Types.VARCHAR); 44 else 45 { 46 switch (col.getLengthType()) 47 { 48 case Column.FIXED_LENGTH: 49 ti = dba.getTypeInfo(Types.CHAR); 50 break; 51 52 case Column.MAXIMUM_LENGTH: 53 default: 54 ti = dba.getTypeInfo(Types.VARCHAR); 55 break; 56 } 57 } 58 59 return ti; 60 } 61 62 63 public void setString(PersistenceManager pm, PreparedStatement ps, int param, String value) 64 { 65 if (value != null && value.length() == 0) 66 value = EMPTY_STRING_SURROGATE; 67 68 super.setString(pm, ps, param, value); 69 } 70 71 public String getString(PersistenceManager pm, ResultSet rs, int param) 72 { 73 String value = super.getString(pm, rs, param); 74 75 if (value != null && value.equals(EMPTY_STRING_SURROGATE)) 76 value = ""; 77 78 return value; 79 } 80 } 81 | Popular Tags |