public String getName() { return getInternal().getName(); }
public String getColumn() { ColumnMetaData[] colmds = getInternal().getColumnMetaData(); if (colmds != null && colmds.length > 0) { return colmds[0].getName(); } return null; }
/** * * Returns the name of a column as specified in a JPA annotation (can possibly be {@code null}). * * @param ammd the metadata object for the field we're retrieving a name for * @return {@code null} if the field name is not defined by a JPA annotation, otherwise return the field name */ public static String getFieldNameFromJPAAnnotation(AbstractMemberMetaData ammd) { String fieldName = null; // Try the first column if specified ColumnMetaData[] colmds = ammd.getColumnMetaData(); ElementMetaData elemmd; if (colmds != null && colmds.length > 0) { fieldName = colmds[0].getName(); // In some cases (for example Collections and Arrays) // the ColumnMetaData will be embedded in ElementMetaData } else if ((elemmd = ammd.getElementMetaData()) != null) { colmds = elemmd.getColumnMetaData(); if (colmds != null && colmds.length > 0) { fieldName = colmds[0].getName(); } } return fieldName; } }
/** * * Returns the name of a column as specified in a JPA annotation (can possibly be {@code null}). * * @param ammd the metadata object for the field we're retrieving a name for * @return {@code null} if the field name is not defined by a JPA annotation, otherwise return the field name */ public static String getFieldNameFromJPAAnnotation(AbstractMemberMetaData ammd) { String fieldName = null; // Try the first column if specified ColumnMetaData[] colmds = ammd.getColumnMetaData(); ElementMetaData elemmd; if (colmds != null && colmds.length > 0) { fieldName = colmds[0].getName(); // In some cases (for example Collections and Arrays) // the ColumnMetaData will be embedded in ElementMetaData } else if ((elemmd = ammd.getElementMetaData()) != null) { colmds = elemmd.getColumnMetaData(); if (colmds != null && colmds.length > 0) { fieldName = colmds[0].getName(); } } return fieldName; } }
private static void checkColumnOrFieldName(String expectedName, AbstractMemberMetaData ammd, String fieldName, Class<?> clazz, String message1, String message2, AbstractClassMetaData cmd) { ColumnMetaData[] columnMD = ammd.getColumnMetaData(); if (columnMD != null && columnMD.length > 0 && columnMD[0].getName() != null) { if (!expectedName.equalsIgnoreCase(columnMD[0].getName())) { throw new NucleusUserException(message1 + cmd.getFullClassName()); } } else if (!expectedName.equalsIgnoreCase(fieldName)) { throw new NucleusUserException(message1 + cmd.getFullClassName()); } if (!clazz.isAssignableFrom(ammd.getType())) { throw new NucleusUserException(message2 + cmd.getFullClassName()); } }
private static void checkColumnOrFieldName(String expectedName, AbstractMemberMetaData ammd, String fieldName, Class<?> clazz, String message1, String message2, AbstractClassMetaData cmd) { ColumnMetaData[] columnMD = ammd.getColumnMetaData(); if (columnMD != null && columnMD.length > 0 && columnMD[0].getName() != null) { if (!expectedName.equalsIgnoreCase(columnMD[0].getName())) { throw new NucleusUserException(message1 + cmd.getFullClassName()); } } else if (!expectedName.equalsIgnoreCase(fieldName)) { throw new NucleusUserException(message1 + cmd.getFullClassName()); } if (!clazz.isAssignableFrom(ammd.getType())) { throw new NucleusUserException(message2 + cmd.getFullClassName()); } }
/** * Accessor for the property name to use for the discriminator. * @param idFactory Identifier factory * @param dismd Discriminator metadata * @return The property name */ public static String getDiscriminatorPropertyName( IdentifierFactory idFactory, DiscriminatorMetaData dismd) { ColumnMetaData columnMetaData = dismd.getColumnMetaData(); if (columnMetaData == null) { return idFactory.newDiscriminatorFieldIdentifier().getIdentifierName(); } return columnMetaData.getName(); }
/** * Accessor for the property name to use for the version. * @param idFactory Identifier factory * @param vmd Version metadata * @return The property name */ public static String getVersionPropertyName( IdentifierFactory idFactory, VersionMetaData vmd) { ColumnMetaData columnMetaData = vmd.getColumnMetaData(); if (columnMetaData == null) { return idFactory.newVersionFieldIdentifier().getIdentifierName(); } return columnMetaData.getName(); }
private String getPropertyName() { AbstractMemberMetaData ammd = field.getMemberMetaData(); if (ammd != null) { return EntityUtils.getPropertyName(storeMgr.getIdentifierFactory(), ammd); } else { return field.getColumnMetaData().getName(); } }
DatastoreIdentifier colIdentifier = idFactory.newIdentifier(IdentifierType.COLUMN, colmd.getName()); Column col = addColumn(null, colIdentifier, null, colmd); SQLTypeInfo sqlTypeInfo = storeMgr.getSQLTypeInfoForJDBCType(dba.getJDBCTypeForName(colmd.getJdbcTypeName()));
if (colmds != null && colmds.length > 0) columnName = colmds[0].getName();
/** * Accessor for the (LDAP) attribute name for the specified field. Uses the extension "dn" if specified * (deprecated), else the extension "attribute" if specified, else the "column" if specified, else uses the field * name. * @param mmd MetaData for the field * @return The attribute */ public static String getAttributeNameForField(AbstractMemberMetaData mmd) { String name = mmd.getName(); if (mmd.hasExtension("dn")) { name = mmd.getValueForExtension("dn"); } else if (mmd.hasExtension("attribute")) { name = mmd.getValueForExtension("attribute"); } else if (mmd.getColumnMetaData() != null && mmd.getColumnMetaData().length > 0) { name = mmd.getColumnMetaData()[0].getName(); } return name; }
/** * Method to return the property name to use for storing the specified member. * @param idFactory IdentifierFactory * @param ammd Metadata for the field/property * @return The property name to use in the datastore */ public static String getPropertyName(IdentifierFactory idFactory, AbstractMemberMetaData ammd) { AbstractClassMetaData acmd = ammd.getAbstractClassMetaData(); VersionMetaData vermd = acmd.getVersionMetaDataForClass(); if (acmd.isVersioned() && ammd.getName().equals(vermd.getFieldName())) { return getVersionPropertyName(idFactory, acmd.getVersionMetaData()); } // If a column name was explicitly provided, use that as the property name. if (ammd.getColumn() != null) { return ammd.getColumn(); } if (ammd.getColumnMetaData() != null && ammd.getColumnMetaData().length > 0 && ammd.getColumnMetaData()[0].getName() != null) { if (ammd.getColumnMetaData().length != 1) { throw new NucleusUserException("Field " + ammd.getFullFieldName() + " has been specified with more than 1 column! This is unsupported with GAE/J"); } return ammd.getColumnMetaData()[0].getName(); } // Use the IdentifierFactory to convert from the name of the field into a property name. return idFactory.newDatastoreFieldIdentifier(ammd.getName()).getIdentifierName(); }
private String determinePropertyName(AbstractMemberMetaData ammd) { if (ammd.hasExtension(DatastoreManager.PK_ID) || ammd.hasExtension(DatastoreManager.PK_NAME)) { // the datsatore doesn't support filtering or sorting by the individual // components of the key, so if the field corresponds to one of these // components it's a mistake by the user throw new org.datanucleus.exceptions.NucleusFatalUserException(query.getSingleStringQuery() + ": Field " + ammd.getFullFieldName() + " is a sub-component of the primary key. The " + "datastore does not support filtering or sorting by primary key components, only the " + "entire primary key."); } if (ammd.getColumn() != null) { return ammd.getColumn(); } else if (ammd.getColumnMetaData() != null && ammd.getColumnMetaData().length != 0) { return ammd.getColumnMetaData()[0].getName(); } else if (ammd.getElementMetaData() != null && ammd.getElementMetaData().getColumnMetaData() != null && ammd.getElementMetaData().getColumnMetaData().length != 0) { return ammd.getElementMetaData().getColumnMetaData()[0].getName(); } else { return getIdentifierFactory().newDatastoreFieldIdentifier(ammd.getName()).getIdentifierName(); } }
private String getIndexPropertyName() { String propertyName; if (orderMapping.getMemberMetaData() == null) { // I'm not sure what we should do if this mapping doesn't exist so for now we'll just blow up. propertyName = orderMapping.getDatastoreMappings()[0].getDatastoreField().getIdentifier().getIdentifierName(); } else { propertyName = orderMapping.getMemberMetaData().getName(); AbstractMemberMetaData ammd = orderMapping.getMemberMetaData(); if (ammd.getColumn() != null) { propertyName = ammd.getColumn(); } else if (ammd.getColumnMetaData() != null && ammd.getColumnMetaData().length == 1) { propertyName = ammd.getColumnMetaData()[0].getName(); } } return propertyName; }
for (int i=0;i<pkCols.length;i++) String colName = pkCols[i].getName(); boolean found = false; for (int j=0;j<ownerMapping.getNumberOfDatastoreMappings();j++)
private void updateListOfMissingFields() { for (AbstractMemberMetaData ammd : findAllFields()) { validateColumn(ammd, storeManager.getOMFContext()); AbstractClassMetaData relatedEntity = storeManager.getMetaDataManager().getMetaDataForEntityName(ammd.getType().getSimpleName()); if (relatedEntity != null && relatedEntity.isEmbeddedOnly()) { // Add all embedded fields to embedding entity for (AbstractMemberMetaData eammd : ammd.getEmbeddedMetaData().getMemberMetaData()) { addFieldToListIfAbsent(eammd, storeManager); } } else { addFieldToListIfAbsent(ammd, storeManager); } } // If there is a discriminator column add that too if (cmd.getSuperAbstractClassMetaData() == null && cmd.getDiscriminatorMetaData() != null && cmd.getDiscriminatorMetaData().getColumnMetaData() != null) { ColumnMetaData colmd = cmd.getDiscriminatorMetaData().getColumnMetaData(); addFieldToListIfAbsent(new ForceMemberMetaData(colmd, colmd.getName()) { @Override public Class<?> getType() { return String.class; } }, storeManager); } }
private void updateListOfMissingFields() { for (AbstractMemberMetaData ammd : findAllFields()) { validateColumn(ammd, storeManager.getOMFContext()); AbstractClassMetaData relatedEntity = storeManager.getMetaDataManager().getMetaDataForEntityName(ammd.getType().getSimpleName()); if (relatedEntity != null && relatedEntity.isEmbeddedOnly()) { // Add all embedded fields to embedding entity for (AbstractMemberMetaData eammd : ammd.getEmbeddedMetaData().getMemberMetaData()) { addFieldToListIfAbsent(eammd, storeManager); } } else { addFieldToListIfAbsent(ammd, storeManager); } } // If there is a discriminator column add that too if (cmd.getSuperAbstractClassMetaData() == null && cmd.getDiscriminatorMetaData() != null && cmd.getDiscriminatorMetaData().getColumnMetaData() != null) { ColumnMetaData colmd = cmd.getDiscriminatorMetaData().getColumnMetaData(); addFieldToListIfAbsent(new ForceMemberMetaData(colmd, colmd.getName()) { @Override public Class<?> getType() { return String.class; } }, storeManager); } }