public boolean isUnlimitedLength() { // TODO Enable the two commented out lines so that we can allow people to have "BLOB(1024)" etc if (columnMetaData.getJdbcType() != null && (columnMetaData.getJdbcType() == JdbcType.BLOB || columnMetaData.getJdbcType() == JdbcType.CLOB)/* && !typeInfo.isAllowsPrecisionSpec()*/) { // Allow for jdbc-type=BLOB/CLOB return true; } else if (columnMetaData.getSqlType() != null && columnMetaData.getSqlType().toLowerCase().indexOf("lob") > 0/* && !typeInfo.isAllowsPrecisionSpec()*/) { // Allow for sql-type=BLOB/CLOB return true; } return false; }
if (colmd.getJdbcType() == JdbcType.VARCHAR && colmd.getLength() == null) NucleusLogger.DATASTORE_SCHEMA.debug(Localiser.msg("057011", col.toString(), colmd.getJdbcType()));
return FieldType.Picklist; String type = md.getJdbcType() != null ? md.getJdbcType() : md.getSqlType(); if (type == null) { return null;
return FieldType.Picklist; String type = md.getJdbcType() != null ? md.getJdbcType() : md.getSqlType(); if (type == null) { return null;
if (MetaDataUtils.isJdbcTypeString(colmd.getJdbcType()))
/** * Accessor for the name of the java-type actually used when mapping the particular datastore field. This java-type must have an entry in the datastore mappings. * @param index requested datastore field index. * @return the name of java-type for the requested datastore field. */ public String getJavaTypeForDatastoreMapping(int index) { if (containerIsStoredInSingleColumn()) { if (mmd.hasCollection() || mmd.hasArray()) { ColumnMetaData[] colmds = (mmd.getElementMetaData() != null ? mmd.getElementMetaData().getColumnMetaData() : null); if (colmds != null && colmds.length == 1 && colmds[0].getJdbcType() != null && colmds[0].getJdbcType().equals(JdbcType.ARRAY)) { // Element column using JDBC ARRAY type return Collection.class.getName(); } // Check if they specified just @Column since storing in single column in owner table colmds = mmd.getColumnMetaData(); if (colmds != null && colmds.length == 1 && colmds[0].getJdbcType() != null && colmds[0].getJdbcType().equals(JdbcType.ARRAY)) { // Column using JDBC ARRAY type return Collection.class.getName(); } } // Serialised container so just return serialised return ClassNameConstants.JAVA_IO_SERIALIZABLE; } return super.getJavaTypeForDatastoreMapping(index); }
/** * * A check to see if a field has an ordinal enum type, meaning it's annotated with * {@code @Enumerated(EnumType.ORDINAL)}. Callers of this method should have already verified * ammd to be a picklist field. * * @param ammd the metadata object of a picklist field * @return {@code true} if the field is an ordinal enum */ public static boolean isOrdinalEnum(AbstractMemberMetaData ammd) { ColumnMetaData[] cmds = ammd.getColumnMetaData(); if (cmds != null && cmds.length > 0 && "INTEGER".equals(cmds[0].getJdbcType())) return true; // If the fast method fails take the slow route Enumerated enumerated = ((AccessibleObject) ammd.getMemberRepresented()).getAnnotation(Enumerated.class); return enumerated != null && (enumerated.value() == null || enumerated.value() == EnumType.ORDINAL); }
private void initializeDiscriminatorMapping(DiscriminatorMetaData dismd) { if (dismd != null) { discriminatorMetaData = dismd; if (dismd.getStrategy() == DiscriminatorStrategy.CLASS_NAME) { discriminatorMapping = new DiscriminatorStringMapping( dba, this, dba.getMappingManager(storeMgr).getMapping(String.class)); } else if (dismd.getStrategy() == DiscriminatorStrategy.VALUE_MAP) { ColumnMetaData disColmd = dismd.getColumnMetaData(); if (disColmd != null && disColmd.getJdbcType() != null) { if (disColmd.getJdbcType().equalsIgnoreCase("INTEGER") || disColmd.getJdbcType().equalsIgnoreCase("BIGINT") || disColmd.getJdbcType().equalsIgnoreCase("NUMERIC")) { discriminatorMapping = new DiscriminatorLongMapping(dba, this, dba .getMappingManager(storeMgr).getMapping(Long.class)); } else { discriminatorMapping = new DiscriminatorStringMapping( dba, this, dba.getMappingManager(storeMgr).getMapping(String.class)); } } else { discriminatorMapping = new DiscriminatorStringMapping( dba, this, dba.getMappingManager(storeMgr).getMapping(String.class)); } } } }
/** * * A check to see if a field has an ordinal enum type, meaning it's annotated with * {@code @Enumerated(EnumType.ORDINAL)}. Callers of this method should have already verified * ammd to be a picklist field. * * @param ammd the metadata object of a picklist field * @return {@code true} if the field is an ordinal enum */ public static boolean isOrdinalEnum(AbstractMemberMetaData ammd) { ColumnMetaData[] cmds = ammd.getColumnMetaData(); if (cmds != null && cmds.length > 0 && "INTEGER".equals(cmds[0].getJdbcType())) return true; // If the fast method fails take the slow route Enumerated enumerated = ((AccessibleObject) ammd.getMemberRepresented()).getAnnotation(Enumerated.class); return enumerated != null && (enumerated.value() == null || enumerated.value() == EnumType.ORDINAL); }
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)); } }
if (mmd.getColumnMetaData()[0].getJdbcType() == JdbcType.BLOB) else if (mmd.getColumnMetaData()[0].getJdbcType() == JdbcType.CLOB)
if (this.columnMetaData.getJdbcType() != null) col.columnMetaData.setJdbcType(this.columnMetaData.getJdbcType());
if (disColmd != null && disColmd.getJdbcType() != null) if (MetaDataUtils.isJdbcTypeNumeric(disColmd.getJdbcType())) if (disColmd != null && disColmd.getJdbcType() != null) if (MetaDataUtils.isJdbcTypeNumeric(disColmd.getJdbcType()))
String jdbcType = ammd.getColumnMetaData()[0].getJdbcType(); if (jdbcType != null && jdbcType.equalsIgnoreCase("integer")) {
ColumnMetaData colmd = childAcmd.getIdentityMetaData().getColumnMetaData(); if (colmd != null && ("varchar".equalsIgnoreCase(colmd.getJdbcType()) || "char".equalsIgnoreCase(colmd.getJdbcType()))) { pkType = String.class;
public void storeStringField(int fieldNumber, String value) { if (isPK(fieldNumber)) { storeStringPKField(fieldNumber, value); } else if (MetaDataUtils.isParentPKField(getClassMetaData(), fieldNumber)) { storeParentStringField(value); } else if (MetaDataUtils.isPKNameField(getClassMetaData(), fieldNumber)) { storePKNameField(fieldNumber, value); } else { // could be a JPA "lob" field, in which case we want to store it as Text. // DataNucleus sets a cmd with a jdbc type of CLOB if this is the case. Object valueToStore = value; AbstractMemberMetaData mmd = getMetaData(fieldNumber); if (mmd.getColumnMetaData() != null && mmd.getColumnMetaData().length == 1) { if ("CLOB".equals(mmd.getColumnMetaData()[0].getJdbcType())) { valueToStore = new Text(value); }/* else if (mmd.getColumnMetaData()[0].getLength() > 500) { // Can only store up to 500 characters in String, so use Text valueToStore = new Text(value); }*/ } storeFieldInEntity(fieldNumber, valueToStore); } }
if (colmd.getJdbcType() != null) columnMetaData.setJdbcType(colmd.getJdbcType());
JdbcType jdbcType = colmds[0].getJdbcType(); if (jdbcType != null)
if (idmd != null && idmd.getColumnMetaData() != null && MetaDataUtils.isJdbcTypeString(idmd.getColumnMetaData().getJdbcType()))
if (isNumericJdbcType(colmds[0].getJdbcType()))