io.ebeaninternal.server.persist.dmlbind.MatchedImportedFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ebean Show documentation
Show all versions of ebean Show documentation
composite of common runtime dependencies for all platforms
package io.ebeaninternal.server.persist.dmlbind;
import io.ebeaninternal.server.deploy.BeanDescriptor;
import io.ebeaninternal.server.deploy.BeanProperty;
import io.ebeaninternal.server.deploy.BeanPropertyAssocOne;
class MatchedImportedFactory {
/**
* Create the array of matchedImportedProperty based on the properties and descriptor.
*/
static MatchedImportedProperty[] build(BeanProperty[] props, BeanDescriptor> desc) {
MatchedImportedProperty[] matches = new MatchedImportedProperty[props.length];
for (int i = 0; i < props.length; i++) {
// find matching assoc one property for dbColumn
matches[i] = findMatch(props[i], desc);
if (matches[i] == null) {
// ok, the assoc ones are not on the bean?
return null;
}
}
return matches;
}
private static MatchedImportedProperty findMatch(BeanProperty prop, BeanDescriptor> desc) {
// find matching against the local database column
String dbColumn = prop.getDbColumn();
BeanPropertyAssocOne>[] assocOnes = desc.propertiesOne();
for (BeanPropertyAssocOne> assocOne1 : assocOnes) {
if (assocOne1.isImportedPrimaryKey()) {
// search using the ImportedId from the assoc one
BeanProperty foreignMatch = assocOne1.getImportedId().findMatchImport(dbColumn);
if (foreignMatch != null) {
return new MatchedImportedEmbedded(prop, assocOne1, foreignMatch);
}
}
}
BeanProperty[] scalar = desc.propertiesBaseScalar();
for (BeanProperty beanProperty : scalar) {
if (dbColumn.equals(beanProperty.getDbColumn())) {
return new MatchedImportedScalar(prop, beanProperty);
}
}
// there was no matching assoc one property.
// example UserRole bean missing assoc one to User?
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy