1 package org.apache.ojb.broker.platforms; 2 3 17 18 import java.sql.PreparedStatement ; 19 import java.sql.SQLException ; 20 import java.sql.Types ; 21 import java.util.Properties ; 22 23 import org.apache.ojb.broker.util.sequence.SequenceManagerHelper; 24 25 120 public class PlatformSapdbImpl extends PlatformDefaultImpl 121 { 122 public void setObjectForStatement( 123 PreparedStatement ps, 124 int index, 125 Object value, 126 int sqlType) 127 throws SQLException 128 { 129 if(((sqlType == Types.VARBINARY) || (sqlType == Types.LONGVARBINARY)) 130 && (value instanceof byte[])) 131 { 132 byte buf[] = (byte[]) value; 133 ps.setBytes(index, buf); 134 } 135 else 136 { 137 super.setObjectForStatement(ps, index, value, sqlType); 138 } 139 } 140 141 144 public byte getJoinSyntaxType() 145 { 146 return ORACLE_JOIN_SYNTAX; 147 } 148 149 154 public boolean useCountForResultsetSize() 155 { 156 return true; 157 } 158 159 public String createSequenceQuery(String sequenceName) 160 { 161 return "CREATE SEQUENCE " + sequenceName; 162 } 163 164 public String createSequenceQuery(String sequenceName, Properties prop) 165 { 166 176 StringBuffer query = new StringBuffer (createSequenceQuery(sequenceName)); 177 if(prop != null) 178 { 179 Boolean b; 180 Long value; 181 182 value = SequenceManagerHelper.getSeqIncrementBy(prop); 183 if(value != null) 184 { 185 query.append(" INCREMENT BY ").append(value.longValue()); 186 } 187 188 value = SequenceManagerHelper.getSeqStart(prop); 189 if(value != null) 190 { 191 query.append(" START WITH ").append(value.longValue()); 192 } 193 194 value = SequenceManagerHelper.getSeqMaxValue(prop); 195 if(value != null) 196 { 197 query.append(" MAXVALUE ").append(value.longValue()); 198 } 199 200 value = SequenceManagerHelper.getSeqMinValue(prop); 201 if(value != null) 202 { 203 query.append(" MINVALUE ").append(value.longValue()); 204 } 205 206 b = SequenceManagerHelper.getSeqCycleValue(prop); 207 if(b != null) 208 { 209 if(b.booleanValue()) query.append(" CYCLE"); 210 else query.append(" NOCYCLE"); 211 } 212 213 value = SequenceManagerHelper.getSeqCacheValue(prop); 214 if(value != null) 215 { 216 query.append(" CACHE ").append(value.longValue()); 217 } 218 219 b = SequenceManagerHelper.getSeqOrderValue(prop); 220 if(b != null) 221 { 222 if(b.booleanValue()) query.append(" ORDER"); 223 else query.append(" NOORDER"); 224 } 225 } 226 return query.toString(); 227 } 228 229 public String nextSequenceQuery(String sequenceName) 230 { 231 return "select " + sequenceName + ".nextval from dual"; 232 } 233 234 public String dropSequenceQuery(String sequenceName) 235 { 236 return "drop sequence " + sequenceName; 237 } 238 239 242 public void addPagingSql(StringBuffer anSqlString) 243 { 244 anSqlString.append(" ROWNO <= ? "); 245 } 246 247 250 public int bindPagingParameters(PreparedStatement ps, int index, int startAt, int endAt) throws SQLException 251 { 252 253 ps.setInt(index, endAt - 1); index++; 255 return index; 256 } 257 258 261 public boolean supportsPaging() 262 { 263 return true; 264 } 265 } 266 | Popular Tags |