public Integer getLength() { return getInternal().getLength(); }
/** * Accessor for the precision of data in the column. * @return The precision of data in the column */ private int getSQLPrecision() { int sqlPrecision = - 1; if (columnMetaData.getLength() != null && columnMetaData.getLength().intValue() > 0) { // User-provided length, so use it sqlPrecision = columnMetaData.getLength().intValue(); } else if (isUnlimitedLength()) { // Use the precision for "unlimited length" if defined int ulpv = getStoreManager().getDatastoreAdapter().getUnlimitedLengthPrecisionValue(typeInfo); if (ulpv > 0) { sqlPrecision = ulpv; } } // Databases like Derby that use BIT types for binary need to have the length expressed in bits, not bytes. if (typeInfo.getTypeName().toLowerCase().startsWith("bit")) { return sqlPrecision * 8; } return sqlPrecision; }
public final void checkString() throws ColumnDefinitionException { if (columnMetaData.getJdbcType() == null) { columnMetaData.setJdbcType(JdbcType.VARCHAR); } if (columnMetaData.getLength() == null) { // Use the default string length columnMetaData.setLength(getStoreManager().getIntProperty(RDBMSPropertyNames.PROPERTY_RDBMS_STRING_DEFAULT_LENGTH)); } }
Integer colLength = column.getColumnMetaData().getLength(); if (colLength != null && colLength.intValue() < value.length())
if (colmd.getJdbcType() == JdbcType.VARCHAR && colmd.getLength() == null)
/** * Initialise the mapping, setting any default precision. */ private void initialize() { // If the column has no precision specified, set its size. // If the user has already set their precision we do nothing here since they // want to control it. if (column != null && column.getColumnMetaData().getLength() == null) { // In case the default DECIMAL precision is less than the number of digits we need, set it manually if (getJavaTypeMapping().getJavaType().getName().equals(ClassNameConstants.JAVA_LANG_INTEGER)) { column.getColumnMetaData().setLength(INT_MAX_DECIMAL_DIGITS); column.checkDecimal(); } else { column.getColumnMetaData().setLength(Math.min(getTypeInfo().getPrecision(), LONG_MAX_DECIMAL_DIGITS)); column.checkDecimal(); } } initTypeInfo(); }
Integer colLength = column.getColumnMetaData().getLength(); if (colLength != null && colLength.intValue() < value.length())
if (column.getColumnMetaData().getLength() == null)
if (getJavaTypeMapping() instanceof SingleFieldMapping && column.getColumnMetaData().getLength() == null) if (column.getColumnMetaData().getLength().intValue() <= 0 || column.getColumnMetaData().getLength().intValue() > maxlength) throw new NucleusUserException("String max length of " + column.getColumnMetaData().getLength() + " is outside the acceptable range [0, " + maxlength + "] for column \"" + column.getIdentifier() + "\"");
if (getJavaTypeMapping() instanceof SingleFieldMapping && column.getColumnMetaData().getLength() == null)