Refactor BeanPropertyAssocOne findByParentIds use of raw expression

This commit is contained in:
Robin Bygrave committed 2016-07-12 16:11:51 +12:00
1 parent d8dfd66af3
commit 6b54b6ef46
3 files changed
+34 -45

No files matched your search

@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
import javax.persistence.PersistenceException;
import java.util.ArrayList;
import java.util.List;
/**
* Abstract base for properties mapped to an associated bean, list, set or map.
@@ -41,6 +42,11 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty {
String targetIdProperty;
/**
* Derived list of exported property and matching foreignKey
*/
protected ExportedProperty[] exportedProperties;
/**
* Persist settings.
*/
@@ -385,4 +391,18 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty {
+ " Perhaps an error in a @JoinColumn";
throw new PersistenceException(msg);
}
protected void bindWhereParentId(List<Object> bindValues, Object parentId) {
if (exportedProperties.length == 1) {
bindValues.add(parentId);
} else {
EntityBean parent = (EntityBean) parentId;
for (int i = 0; i < exportedProperties.length; i++) {
Object embVal = exportedProperties[i].getValue(parent);
bindValues.add(embVal);
}
}
}
}