private static Bindable getDiscriminator(BeanDescriptor<?> desc) { InheritInfo inheritInfo = desc.getInheritInfo(); if (inheritInfo != null) { return new BindableDiscriminator(inheritInfo); } else { return null; } }
@Override public BeanType<?> getInheritanceParent() { return getInheritInfo() == null ? null : getInheritInfo().getParent().desc(); }
@Override public List<BeanType<?>> getInheritanceChildren() { if (hasInheritance()) { return getInheritInfo().getChildren() .stream() .map(InheritInfo::desc) .collect(Collectors.toList()); } else { return Collections.emptyList(); } }
@Override public Query<T> setInheritType(Class<? extends T> type) { if (type == beanType) { return this; } InheritInfo inheritInfo = rootBeanDescriptor.getInheritInfo(); inheritInfo = inheritInfo == null ? null : inheritInfo.readType(type); if (inheritInfo == null) { throw new IllegalArgumentException("Given type " + type + " is not a subtype of " + beanType); } beanDescriptor = (BeanDescriptor<T>) rootBeanDescriptor.getBeanDescriptor(type); return this; }
@Override public void visitAllInheritanceChildren(Consumer<BeanType<?>> visitor) { if (hasInheritance()) { getInheritInfo().visitChildren(info -> visitor.accept(info.desc())); } }
/** * Visit all the other inheritance properties that are not on the root. */ protected void visitInheritanceProperties(BeanDescriptor<?> descriptor, BeanPropertyVisitor pv) { InheritInfo inheritInfo = descriptor.getInheritInfo(); if (inheritInfo != null && inheritInfo.isRoot()) { // add all properties on the children objects inheritInfo.visitChildren(new InheritChildVisitor(this, pv)); } }
@Override public void buildRawSqlSelectChain(String prefix, List<String> selectChain) { prefix = SplitName.add(prefix, name); if (!embedded) { InheritInfo inheritInfo = targetDescriptor.getInheritInfo(); if (inheritInfo != null) { // expect the discriminator column to be included in order // to determine the inheritance type so we add it to the // selectChain (so that it takes a position in the resultSet) String discriminatorColumn = inheritInfo.getDiscriminatorColumn(); String discProperty = prefix + "." + discriminatorColumn; selectChain.add(discProperty); } if (targetIdBinder == null) { throw new IllegalStateException("No Id binding property for " + getFullBeanName() + ". Probably a missing @OneToOne mapping annotation on this relationship?"); } targetIdBinder.buildRawSqlSelectChain(prefix, selectChain); } else { for (BeanProperty embeddedProp : embeddedProps) { embeddedProp.buildRawSqlSelectChain(prefix, selectChain); } } }
void initialiseTargetDescriptor(BeanDescriptorInitContext initContext) { targetDescriptor = descriptor.getBeanDescriptor(targetType); if (!isTransient) { targetIdBinder = targetDescriptor.getIdBinder(); targetInheritInfo = targetDescriptor.getInheritInfo(); saveRecurseSkippable = targetDescriptor.isSaveRecurseSkippable(); if (!targetIdBinder.isComplexId()) { targetIdProperty = targetIdBinder.getIdProperty(); } } }
if (desc.getInheritInfo() != null && prop.isLocal()) { local.add(prop);
public static void load(BeanDescriptor<?> desc, EntityBean bean, CachedBeanData cacheBeanData, PersistenceContext context) { EntityBeanIntercept ebi = bean._ebean_getIntercept(); BeanProperty idProperty = desc.getIdProperty(); if (desc.getInheritInfo() != null) { desc = desc.getInheritInfo().readType(bean.getClass()).desc(); } if (idProperty != null) { // load the id property loadProperty(bean, cacheBeanData, ebi, idProperty, context); } // load the non-many properties for (BeanProperty prop : desc.propertiesNonMany()) { loadProperty(bean, cacheBeanData, ebi, prop, context); } for (BeanPropertyAssocMany<?> prop : desc.propertiesMany()) { if (prop.isElementCollection()) { loadProperty(bean, cacheBeanData, ebi, prop, context); } else { prop.createReferenceIfNull(bean); } } ebi.setLoadedLazy(); }
protected DocStructure getDocStructure(PathProperties pathProps, final boolean includeByDefault) { final DocStructure docStructure = new DocStructure(pathProps); BeanProperty[] properties = desc.propertiesNonTransient(); for (BeanProperty property : properties) { property.docStoreInclude(includeByDefault, docStructure); } InheritInfo inheritInfo = desc.getInheritInfo(); if (inheritInfo != null) { inheritInfo.visitChildren(inheritInfo1 -> { for (BeanProperty localProperty : inheritInfo1.localProperties()) { localProperty.docStoreInclude(includeByDefault, docStructure); } }); } return docStructure; }
InheritInfo inheritInfo = desc.getInheritInfo(); if (inheritInfo == null || inheritInfo.isConcrete()) { return (T) desc.contextRef(pc, null, false, id);
private static Bindable getDiscriminator(BeanDescriptor<?> desc) { InheritInfo inheritInfo = desc.getInheritInfo(); if (inheritInfo != null) { return new BindableDiscriminator(inheritInfo); } else { return null; } }
@Override public BeanType<?> getInheritanceParent() { return getInheritInfo() == null ? null : getInheritInfo().getParent().desc(); }
@Override public List<BeanType<?>> getInheritanceChildren() { if (hasInheritance()) { return getInheritInfo().getChildren() .stream() .map(InheritInfo::desc) .collect(Collectors.toList()); } else { return Collections.emptyList(); } }
InheritInfo inheritInfo = descriptor.getInheritInfo(); if (inheritInfo != null && inheritInfo.isRoot()) {
@Override public void visitAllInheritanceChildren(Consumer<BeanType<?>> visitor) { if (hasInheritance()) { getInheritInfo().visitChildren(info -> visitor.accept(info.desc())); } }
/** * Visit all the other inheritance properties that are not on the root. */ protected void visitInheritanceProperties(BeanDescriptor<?> descriptor, BeanPropertyVisitor pv) { InheritInfo inheritInfo = descriptor.getInheritInfo(); if (inheritInfo != null && inheritInfo.isRoot()) { // add all properties on the children objects inheritInfo.visitChildren(new InheritChildVisitor(this, pv)); } }
void initialiseTargetDescriptor(BeanDescriptorInitContext initContext) { targetDescriptor = descriptor.getBeanDescriptor(targetType); if (!isTransient) { targetIdBinder = targetDescriptor.getIdBinder(); targetInheritInfo = targetDescriptor.getInheritInfo(); saveRecurseSkippable = targetDescriptor.isSaveRecurseSkippable(); if (!targetIdBinder.isComplexId()) { targetIdProperty = targetIdBinder.getIdProperty(); } } }
if (checkConstraintValues != null) { if (beanDescriptor.hasInheritance()) { InheritInfo inheritInfo = beanDescriptor.getInheritInfo(); inheritInfo.appendCheckConstraintValues(p.getName(), checkConstraintValues);