FieldTypeDefinition fieldType; if (type != null) { //translate Java 'type' fieldType = platform.getFieldTypeDefinition(type); if (fieldType == null) { throw ValidationException.javaTypeIsNotAValidDatabaseType(type); final Map<String, Class> fieldTypes = platform.getClassTypes(); final Class typeFromName = fieldTypes.get(name); if (typeFromName == null) { // if unknown type name, use as it is fieldType = new FieldTypeDefinition(name); } else { fieldType = platform.getFieldTypeDefinition(typeFromName); if (fieldType == null) { throw ValidationException.javaTypeIsNotAValidDatabaseType(typeFromName);
= getFieldTypeDefinition(session, argument.type, argument.typeName); writer.write(platform.getProcedureArgumentString()); if (platform.shouldPrintOutputTokenAtStart()) { writer.write(" "); writer.write(platform.getCreationOutputProcedureToken()); writer.write(" "); if ((!platform.shouldPrintOutputTokenAtStart()) && platform.shouldPrintOutputTokenBeforeType()) { writer.write(" "); writer.write(platform.getCreationOutputProcedureToken()); if (fieldType.isSizeAllowed() && platform.allowsSizeInProcedureArguments() && ((argument.size != 0) || (fieldType.isSizeRequired()))) { writer.write("("); if ((!platform.shouldPrintOutputTokenAtStart()) && !platform.shouldPrintOutputTokenBeforeType()) { writer.write(" "); writer.write(platform.getCreationOutputProcedureToken());
appendCalendar((Calendar)parameter, writer); return nBoundParameters; Object dbValue = convertToDatabaseType(parameter); if (usesStringBinding() && (((String)dbValue).length() >= getStringBindingSize())) { databaseCall.bindParameter(writer, dbValue); nBoundParameters = 1; } else { appendString((String)dbValue, writer); appendNumber((Number)dbValue, writer); } else if (dbValue instanceof java.sql.Time) { appendTime((java.sql.Time)dbValue, writer); } else if (dbValue instanceof java.sql.Timestamp) { appendTimestamp((java.sql.Timestamp)dbValue, writer); } else if (dbValue instanceof java.sql.Date) { appendDate((java.sql.Date)dbValue, writer); } else if (dbValue == null) { writer.write("NULL"); } else if (dbValue instanceof Boolean) { appendBoolean((Boolean)dbValue, writer); } else if (dbValue instanceof byte[]) { if (usesByteArrayBinding()) { databaseCall.bindParameter(writer, dbValue); nBoundParameters = 1; } else { appendByteArray((byte[])dbValue, writer);
/** * INTERNAL: * In case shouldBindLiterals is true, instead of null value a DatabaseField * value may be passed (so that it's type could be used for binding null). */ public void appendLiteralToCall(Call call, Writer writer, Object literal) { if(shouldBindLiterals()) { appendLiteralToCallWithBinding(call, writer, literal); } else { int nParametersToAdd = appendParameterInternal(call, writer, literal); for(int i=0; i < nParametersToAdd; i++ ) { ((DatabaseCall)call).getParameterTypes().addElement(DatabaseCall.LITERAL); } } }
fieldType = platform.getFieldTypeDefinition(getType()); if (fieldType == null) { throw ValidationException.javaTypeIsNotAValidDatabaseType(getType()); Map<String, Class> fieldTypes = platform.getClassTypes(); Class type = fieldTypes.get(getTypeName()); if (type == null) { // if unknown type name, use as it is fieldType = new FieldTypeDefinition(getTypeName()); } else { fieldType = platform.getFieldTypeDefinition(type); if (fieldType == null) { throw ValidationException.javaTypeIsNotAValidDatabaseType(type); boolean shouldPrintFieldIdentityClause = isIdentity() && platform.shouldPrintFieldIdentityClause(session, qualifiedName); platform.printFieldTypeSize(writer, this, fieldType, shouldPrintFieldIdentityClause); platform.printFieldIdentityClause(writer); platform.printFieldNullClause(writer); } else { platform.printFieldNotNullClause(writer); if (platform.supportsUniqueColumns()) { platform.printFieldUnique(writer, shouldPrintFieldIdentityClause); } else { String constraintName = table.buildUniqueKeyConstraintName(table.getName(), table.getFields().indexOf(this), platform.getMaxUniqueKeyNameSize()); table.addUniqueKeyConstraint(constraintName, getName());
= getFieldTypeDefinition(session, argument.type, argument.typeName); writer.write(platform.getProcedureArgumentString()); if (platform.shouldPrintOutputTokenAtStart()) { writer.write(" "); writer.write(platform.getCreationInOutputProcedureToken()); writer.write(" "); if ((!platform.shouldPrintOutputTokenAtStart()) && platform.shouldPrintOutputTokenBeforeType()) { writer.write(" "); writer.write(platform.getCreationInOutputProcedureToken()); if (fieldType.isSizeAllowed() && platform.allowsSizeInProcedureArguments() && ((argument.size != 0) || (fieldType.isSizeRequired()))) { writer.write("("); if ((!platform.shouldPrintOutputTokenAtStart()) && (!platform.shouldPrintOutputTokenBeforeType())) { writer.write(" "); writer.write(platform.getCreationInOutputProcedureToken());
= getFieldTypeDefinition(session, argument.type, argument.typeName); writer.write(platform.getProcedureArgumentString()); if (platform.shouldPrintInputTokenAtStart()) { writer.write(" "); writer.write(platform.getInputProcedureToken()); writer.write(" "); writer.write(fieldType.getName()); if (fieldType.isSizeAllowed() && platform.allowsSizeInProcedureArguments() && ((argument.size != 0) || (fieldType.isSizeRequired()))) { writer.write("(");
/** * INTERNAL: * Print SQL using the operator. */ public void printSQL(ExpressionSQLPrinter printer) { // If all children are parameters, some databases don't allow binding. if (printer.getPlatform().isDynamicSQLRequiredForFunctions() && !this.children.isEmpty()) { boolean allParams = true; for (Iterator iterator = this.children.iterator(); iterator.hasNext(); ) { Expression child = (Expression)iterator.next(); if (!(child.isParameterExpression() || child.isConstantExpression())) { allParams = false; } } if (allParams) { printer.getCall().setUsesBinding(false); } } ExpressionOperator realOperator; realOperator = getPlatformOperator(printer.getPlatform()); realOperator.printCollection(this.children, printer); }
try { DatabasePlatform platform = session.getPlatform(); boolean shouldUnwrapConnection = platform.usesNativeBatchWriting(); statement = (PreparedStatement)this.databaseAccessor.prepareStatement(this.previousCall, session, shouldUnwrapConnection); platform.prepareBatchStatement(statement, this.maxBatchSize); if (this.queryTimeoutCache > DescriptorQueryManager.NoTimeout) { int size = parameterList.size(); for (int index = 0; index < size; index++) { platform.setParameterValueInDatabaseCall(parameterList.get(index), statement, index+1, session); this.executionCount += platform.addBatch(statement);
statement = (PreparedStatement)this.databaseAccessor.prepareStatement(this.previousCall, session, shouldUnwrapConnection); databaseAccessor.getPlatform().prepareBatchStatement(statement); if(queryTimeoutCache > DescriptorQueryManager.NoTimeout) { executionCount += this.databaseAccessor.getPlatform().addBatch(statement);
public static Class<?> getClassFromJDBCType(String typeName, DatabasePlatform databasePlatform) { Class<?> clz = databasePlatform.getClassTypes().get(typeName); if (clz == null) { return Object_Class; } return clz; }
/** * INTERNAL: */ protected void processStructConverterConfig(StructConverterConfig converterClassConfig, DatabaseLogin login) { if (converterClassConfig != null) { Platform platform = login.getDatasourcePlatform(); if (platform instanceof DatabasePlatform){ Iterator i = converterClassConfig.getStructConverterClasses().iterator(); while (i.hasNext()) { String converterClassName = (String)i.next(); try { Class converterClass = m_classLoader.loadClass(converterClassName); StructConverter converter = null; if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try{ converter = (StructConverter)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(converterClass)); }catch (PrivilegedActionException ex){ throw (Exception)ex.getCause(); } }else{ converter = (StructConverter)PrivilegedAccessHelper.newInstanceFromClass(converterClass); } ((DatabasePlatform)platform).addStructConverter(converter); } catch (Exception exception) { throw SessionLoaderException.failedToLoadTag("struct-converter", converterClassName, exception); } } } } }
= getFieldTypeDefinition(session, argument.type, argument.typeName); writer.write(platform.getProcedureArgumentString()); if (platform.shouldPrintOutputTokenAtStart()) { writer.write(" "); writer.write(platform.getCreationInOutputProcedureToken()); writer.write(" "); if ((!platform.shouldPrintOutputTokenAtStart()) && platform.shouldPrintOutputTokenBeforeType()) { writer.write(" "); writer.write(platform.getCreationInOutputProcedureToken()); if (fieldType.isSizeAllowed() && platform.allowsSizeInProcedureArguments() && ((argument.size != 0) || (fieldType.isSizeRequired()))) { writer.write("("); if ((!platform.shouldPrintOutputTokenAtStart()) && (!platform.shouldPrintOutputTokenBeforeType())) { writer.write(" "); writer.write(platform.getCreationInOutputProcedureToken());
= getFieldTypeDefinition(session, argument.type, argument.typeName); writer.write(platform.getProcedureArgumentString()); if (platform.shouldPrintInputTokenAtStart()) { writer.write(" "); writer.write(platform.getInputProcedureToken()); writer.write(" "); writer.write(fieldType.getName()); if (fieldType.isSizeAllowed() && platform.allowsSizeInProcedureArguments() && ((argument.size != 0) || (fieldType.isSizeRequired()))) { writer.write("(");
/** * INTERNAL: * Print SQL using the operator. */ public void printSQL(ExpressionSQLPrinter printer) { // If all children are parameters, some databases don't allow binding. if (printer.getPlatform().isDynamicSQLRequiredForFunctions() && !this.children.isEmpty()) { boolean allParams = true; for (Iterator iterator = this.children.iterator(); iterator.hasNext(); ) { Expression child = (Expression)iterator.next(); if (!(child.isParameterExpression() || child.isConstantExpression())) { allParams = false; } } if (allParams) { printer.getCall().setUsesBinding(false); } } ExpressionOperator realOperator; realOperator = getPlatformOperator(printer.getPlatform()); realOperator.printCollection(this.children, printer); }
try { DatabasePlatform platform = session.getPlatform(); boolean shouldUnwrapConnection = platform.usesNativeBatchWriting(); statement = (PreparedStatement)this.databaseAccessor.prepareStatement(this.previousCall, session, shouldUnwrapConnection); platform.prepareBatchStatement(statement, this.maxBatchSize); if (this.queryTimeoutCache > DescriptorQueryManager.NoTimeout) { int size = parameterList.size(); for (int index = 0; index < size; index++) { platform.setParameterValueInDatabaseCall(parameterList.get(index), statement, index+1, session); this.executionCount += platform.addBatch(statement);
/** * INTERNAL: * In case shouldBindLiterals is true, instead of null value a DatabaseField * value may be passed (so that it's type could be used for binding null). */ public void appendLiteralToCall(Call call, Writer writer, Object literal) { if(shouldBindLiterals()) { appendLiteralToCallWithBinding(call, writer, literal); } else { int nParametersToAdd = appendParameterInternal(call, writer, literal); for (int i = 0; i < nParametersToAdd; i++) { ((DatabaseCall)call).getParameterTypes().add(DatabaseCall.LITERAL); } } }
public static Class<?> getClassFromJDBCType(String typeName, DatabasePlatform databasePlatform) { Class<?> clz = (Class<?>)databasePlatform.getClassTypes().get(typeName); if (clz == null) { return Object_Class; } return clz; }
converter = (StructConverter)PrivilegedAccessHelper.newInstanceFromClass(converterClass); ((DatabasePlatform)platform).addStructConverter(converter); } catch (Exception exception) { throw SessionLoaderException.failedToLoadTag("struct-converter", converterClassName, exception);
appendCalendar((Calendar)parameter, writer); return nBoundParameters; Object dbValue = convertToDatabaseType(parameter); if (usesStringBinding() && (((String)dbValue).length() >= getStringBindingSize())) { databaseCall.bindParameter(writer, dbValue); nBoundParameters = 1; } else { appendString((String)dbValue, writer); appendNumber((Number)dbValue, writer); } else if (dbValue instanceof java.sql.Time) { appendTime((java.sql.Time)dbValue, writer); } else if (dbValue instanceof java.sql.Timestamp) { appendTimestamp((java.sql.Timestamp)dbValue, writer); } else if (dbValue instanceof java.sql.Date) { appendDate((java.sql.Date)dbValue, writer); } else if (dbValue == null) { writer.write("NULL"); } else if (dbValue instanceof Boolean) { appendBoolean((Boolean)dbValue, writer); } else if (dbValue instanceof byte[]) { if (usesByteArrayBinding()) { databaseCall.bindParameter(writer, dbValue); nBoundParameters = 1; } else { appendByteArray((byte[])dbValue, writer);