use of org.datanucleus.metadata.UniqueMetaData in project datanucleus-api-jdo by datanucleus.
the class ValueMetadataImpl method newUniqueMetadata.
/* (non-Javadoc)
* @see javax.jdo.metadata.ValueMetadata#newUniqueMetadata()
*/
public UniqueMetadata newUniqueMetadata() {
UniqueMetaData internalUnimd = getInternal().newUniqueMetaData();
UniqueMetadataImpl unimd = new UniqueMetadataImpl(internalUnimd);
unimd.parent = this;
return unimd;
}
use of org.datanucleus.metadata.UniqueMetaData in project datanucleus-rdbms by datanucleus.
the class ElementContainerTable method getExpectedCandidateKeys.
/**
* Accessor for the candidate keys for this table.
* @return The indices
*/
protected List getExpectedCandidateKeys() {
// The indices required by foreign keys (BaseTable)
List candidateKeys = super.getExpectedCandidateKeys();
if (elementMapping instanceof EmbeddedElementPCMapping) {
// Add all candidate keys required by fields of the embedded element
EmbeddedElementPCMapping embMapping = (EmbeddedElementPCMapping) elementMapping;
for (int i = 0; i < embMapping.getNumberOfJavaTypeMappings(); i++) {
JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i);
UniqueMetaData umd = embFieldMapping.getMemberMetaData().getUniqueMetaData();
if (umd != null) {
CandidateKey ck = TableUtils.getCandidateKeyForField(this, umd, embFieldMapping);
if (ck != null) {
candidateKeys.add(ck);
}
}
}
}
if (mmd.getJoinMetaData() != null && mmd.getJoinMetaData().getUniqueMetaData() != null) {
// User has defined a unique key on the join table
UniqueMetaData unimd = mmd.getJoinMetaData().getUniqueMetaData();
if (unimd.getNumberOfColumns() > 0) {
String[] columnNames = unimd.getColumnNames();
CandidateKey uniKey = new CandidateKey(this, null);
String unimdName = unimd.getName();
if (!StringUtils.isWhitespace(unimdName)) {
uniKey.setName(unimd.getName());
}
IdentifierFactory idFactory = storeMgr.getIdentifierFactory();
for (String columnName : columnNames) {
Column col = getColumn(idFactory.newColumnIdentifier(columnName));
if (col != null) {
uniKey.addColumn(col);
} else {
throw new NucleusUserException("Unique key on join-table " + this + " has column " + columnName + " that is not found");
}
}
candidateKeys.add(uniKey);
}
}
return candidateKeys;
}
use of org.datanucleus.metadata.UniqueMetaData in project datanucleus-rdbms by datanucleus.
the class MapTable method getExpectedCandidateKeys.
/**
* Accessor for the candidate keys for this table.
* @return The indices
*/
protected List getExpectedCandidateKeys() {
// The indices required by foreign keys (BaseTable)
List candidateKeys = super.getExpectedCandidateKeys();
if (keyMapping instanceof EmbeddedKeyPCMapping) {
// Add all candidate keys required by fields of the embedded key
EmbeddedKeyPCMapping embMapping = (EmbeddedKeyPCMapping) keyMapping;
for (int i = 0; i < embMapping.getNumberOfJavaTypeMappings(); i++) {
JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i);
UniqueMetaData umd = embFieldMapping.getMemberMetaData().getUniqueMetaData();
if (umd != null) {
CandidateKey ck = TableUtils.getCandidateKeyForField(this, umd, embFieldMapping);
if (ck != null) {
candidateKeys.add(ck);
}
}
}
} else if (mmd.getKeyMetaData() != null) {
UniqueMetaData unimd = mmd.getKeyMetaData().getUniqueMetaData();
if (unimd != null) {
CandidateKey ck = TableUtils.getCandidateKeyForField(this, unimd, keyMapping);
if (ck != null) {
candidateKeys.add(ck);
}
}
}
if (valueMapping instanceof EmbeddedValuePCMapping) {
// Add all candidate keys required by fields of the embedded value
EmbeddedValuePCMapping embMapping = (EmbeddedValuePCMapping) valueMapping;
for (int i = 0; i < embMapping.getNumberOfJavaTypeMappings(); i++) {
JavaTypeMapping embFieldMapping = embMapping.getJavaTypeMapping(i);
UniqueMetaData umd = embFieldMapping.getMemberMetaData().getUniqueMetaData();
if (umd != null) {
CandidateKey ck = TableUtils.getCandidateKeyForField(this, umd, embFieldMapping);
if (ck != null) {
candidateKeys.add(ck);
}
}
}
} else if (mmd.getValueMetaData() != null) {
UniqueMetaData unimd = mmd.getValueMetaData().getUniqueMetaData();
if (unimd != null) {
CandidateKey ck = TableUtils.getCandidateKeyForField(this, unimd, valueMapping);
if (ck != null) {
candidateKeys.add(ck);
}
}
}
return candidateKeys;
}
use of org.datanucleus.metadata.UniqueMetaData in project datanucleus-api-jdo by datanucleus.
the class KeyMetadataImpl method getUniqueMetadata.
/* (non-Javadoc)
* @see javax.jdo.metadata.KeyMetadata#getUniqueMetadata()
*/
public UniqueMetadata getUniqueMetadata() {
UniqueMetaData internalUnimd = getInternal().getUniqueMetaData();
if (internalUnimd == null) {
return null;
}
UniqueMetadataImpl unimd = new UniqueMetadataImpl(internalUnimd);
unimd.parent = this;
return unimd;
}
use of org.datanucleus.metadata.UniqueMetaData in project datanucleus-api-jdo by datanucleus.
the class KeyMetadataImpl method newUniqueMetadata.
/* (non-Javadoc)
* @see javax.jdo.metadata.KeyMetadata#newUniqueMetadata()
*/
public UniqueMetadata newUniqueMetadata() {
UniqueMetaData internalUnimd = getInternal().newUniqueMetaData();
UniqueMetadataImpl unimd = new UniqueMetadataImpl(internalUnimd);
unimd.parent = this;
return unimd;
}
Aggregations