mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
#599 - ElasticSearch - add query join support for find, findList, findPagedList, findEach, findEachWhile
This commit is contained in:
1 parent
fa451078b7
commit
b99f002968
27 files changed
+276
-87
No files matched your search
@@ -107,6 +107,28 @@ public class BeanDescriptor<T> implements MetaBeanInfo, BeanType<T> {
|
||||
|
||||
private final ConcurrentHashMap<String, ElComparator<T>> comparatorCache = new ConcurrentHashMap<String, ElComparator<T>>();
|
||||
|
||||
public void merge(EntityBean bean, EntityBean existing) {
|
||||
|
||||
EntityBeanIntercept fromEbi = bean._ebean_getIntercept();
|
||||
EntityBeanIntercept toEbi = existing._ebean_getIntercept();
|
||||
|
||||
int propertyLength = toEbi.getPropertyLength();
|
||||
String[] names = getProperties();
|
||||
|
||||
for (int i = 0; i < propertyLength; i++) {
|
||||
|
||||
if (fromEbi.isLoadedProperty(i) ) {
|
||||
BeanProperty property = getBeanProperty(names[i]);
|
||||
if (!toEbi.isLoadedProperty(i)) {
|
||||
Object val = property.getValue(bean);
|
||||
property.setValue(existing, val);
|
||||
} else if (property.isMany()) {
|
||||
property.merge(bean, existing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum EntityType {
|
||||
ORM, EMBEDDED, SQL
|
||||
}
|
||||
|
||||
@@ -1329,4 +1329,7 @@ public class BeanProperty implements ElPropertyValue, Property {
|
||||
return DocPropertyType.STRING == type && (id || discriminator);
|
||||
}
|
||||
|
||||
public void merge(EntityBean bean, EntityBean existing) {
|
||||
// do nothing unless Many property
|
||||
}
|
||||
}
|
||||
@@ -201,6 +201,27 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
|
||||
// by default not including "Many" properties in document store
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy collection value if existing is empty.
|
||||
*/
|
||||
@Override
|
||||
public void merge(EntityBean bean, EntityBean existing) {
|
||||
|
||||
Object existingCollection = getVal(existing);
|
||||
if (existingCollection instanceof BeanCollection<?>) {
|
||||
BeanCollection<?> toBC = (BeanCollection<?>)existingCollection;
|
||||
if (!toBC.isPopulated()) {
|
||||
Object fromCollection = getVal(bean);
|
||||
if (fromCollection instanceof BeanCollection<?>) {
|
||||
BeanCollection<?> fromBC = (BeanCollection<?>)fromCollection;
|
||||
if (fromBC.isPopulated()) {
|
||||
toBC.loadFrom(fromBC);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the bean to the appropriate collection on the parent bean.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user