Class BeanPropertyAssocMany<T>

All Implemented Interfaces:
io.ebean.core.type.ScalarDataReader<Object>, io.ebean.plugin.ExpressionPath, io.ebean.plugin.Property, io.ebean.plugin.PropertyAssocMany, SpiQueryManyJoin, ElPropertyDeploy, ElPropertyValue, STreeProperty, STreePropertyAssoc, STreePropertyAssocMany
Direct Known Subclasses:
BeanPropertySimpleCollection

public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements STreePropertyAssocMany, io.ebean.plugin.PropertyAssocMany
Property mapped to a List Set or Map.
  • Constructor Details

  • Method Details

    • initialise

      public void initialise(io.ebeaninternal.server.deploy.BeanDescriptorInitContext initContext)
      Description copied from class: BeanPropertyAssoc
      Initialise post construction.
      Overrides:
      initialise in class BeanPropertyAssoc<T>
    • asMany

      public BeanPropertyAssocMany<?> asMany()
      Description copied from interface: STreePropertyAssocMany
      Return as BeanPropertyAssocMany.
      Specified by:
      asMany in interface STreePropertyAssocMany
    • isManyToManyWithHistory

      public boolean isManyToManyWithHistory()
      Description copied from interface: STreePropertyAssocMany
      Return true if this is a ManyToMany with history.
      Specified by:
      isManyToManyWithHistory in interface STreePropertyAssocMany
    • registerColumn

      public void registerColumn(BeanDescriptor<?> desc, String prefix)
      Overrides:
      registerColumn in class BeanProperty
    • rawCollection

      public Collection rawCollection(io.ebean.bean.EntityBean bean)
      Return the underlying collection of beans.
    • merge

      public void merge(io.ebean.bean.EntityBean bean, io.ebean.bean.EntityBean existing)
      Copy collection value if existing is empty.
      Overrides:
      merge in class BeanProperty
    • addBeanToCollectionWithCreate

      public void addBeanToCollectionWithCreate(io.ebean.bean.EntityBean parentBean, io.ebean.bean.EntityBean detailBean, boolean withCheck)
      Add the bean to the appropriate collection on the parent bean.
      Specified by:
      addBeanToCollectionWithCreate in interface STreePropertyAssocMany
    • isSkipSaveBeanCollection

      public boolean isSkipSaveBeanCollection(io.ebean.bean.EntityBean bean, boolean insertedParent)
      Return true if this is considered 'empty' from a save perspective.
    • resetMany

      public void resetMany(io.ebean.bean.EntityBean bean)
      Reset the many properties to be empty and ready for reloading.

      Used in bean refresh.

    • buildElPropertyValue

      public ElPropertyValue buildElPropertyValue(String propName, String remainder, ElPropertyChainBuilder chain, boolean propertyDeploy)
      Overrides:
      buildElPropertyValue in class BeanProperty
    • buildRawSqlSelectChain

      public void buildRawSqlSelectChain(String prefix, List<String> selectChain)
      Description copied from interface: STreeProperty
      For RawSql build the select chain.
      Specified by:
      buildRawSqlSelectChain in interface STreeProperty
      Overrides:
      buildRawSqlSelectChain in class BeanProperty
    • deleteByParentId

      public SpiSqlUpdate deleteByParentId(Object parentId)
      Description copied from class: BeanPropertyAssoc
      Create SqlUpdate statement to delete all child beans of the parent id.
      Specified by:
      deleteByParentId in class BeanPropertyAssoc<T>
    • deleteByParentIdList

      public SpiSqlUpdate deleteByParentIdList(List<Object> parentIdist)
      Description copied from class: BeanPropertyAssoc
      Create SqlUpdate statement to delete all child beans of the parent ids in idList.
      Specified by:
      deleteByParentIdList in class BeanPropertyAssoc<T>
    • findIdsByParentId

      public List<Object> findIdsByParentId(Object parentId, io.ebean.Transaction t, boolean includeSoftDeletes)
      Find the Id's of detail beans given a parent Id
      Specified by:
      findIdsByParentId in class BeanPropertyAssoc<T>
    • findIdsByParentId

      public List<Object> findIdsByParentId(Object parentId, io.ebean.Transaction t, boolean includeSoftDeletes, Set<Object> excludeDetailIds)
      Find the Id's of detail beans given a parent Id and optionally exclude detail IDs
    • findIdsByParentIdList

      public List<Object> findIdsByParentIdList(List<Object> parentIdList, io.ebean.Transaction t, boolean includeSoftDeletes)
      Find the Id's of detail beans given a list of parent Id's.
      Specified by:
      findIdsByParentIdList in class BeanPropertyAssoc<T>
    • isCacheDataInclude

      public boolean isCacheDataInclude()
      Exclude many properties from bean cache data.
      Overrides:
      isCacheDataInclude in class BeanProperty
    • lazyLoadMany

      public void lazyLoadMany(io.ebean.bean.EntityBean current)
      Add the loaded current bean to its associated parent.

      Helper method used by Elastic integration when loading with a persistence context.

      Specified by:
      lazyLoadMany in interface io.ebean.plugin.PropertyAssocMany
    • addWhereParentIdIn

      public void addWhereParentIdIn(SpiQuery<?> query, List<Object> parentIds)
    • setEbeanServer

      public void setEbeanServer(SpiEbeanServer server)
      Set the lazy load server to help create reference collections (that lazy load on demand).
    • intersectionTable

      public IntersectionTable intersectionTable()
      Return the intersection table helper.
    • modifyListenMode

      public io.ebean.bean.BeanCollection.ModifyListenMode modifyListenMode()
      Return the mode for listening to modifications to collections for this association.
    • appendSelect

      public void appendSelect(DbSqlContext ctx, boolean subQuery)
      Description copied from interface: STreeProperty
      Append to the select clause.
      Specified by:
      appendSelect in interface STreeProperty
      Overrides:
      appendSelect in class BeanProperty
    • loadIgnore

      public void loadIgnore(DbReadContext ctx)
      Description copied from interface: STreeProperty
      Ignore the property (moving the column index position without reading).
      Specified by:
      loadIgnore in interface STreeProperty
      Overrides:
      loadIgnore in class BeanProperty
    • load

      public void load(SqlBeanLoad sqlBeanLoad)
      Description copied from interface: STreeProperty
      Load into the bean (from the DataReader/ResultSet).
      Specified by:
      load in interface STreeProperty
      Overrides:
      load in class BeanProperty
    • readSet

      public Object readSet(DbReadContext ctx, io.ebean.bean.EntityBean bean)
      Overrides:
      readSet in class BeanProperty
    • read

      public Object read(DbReadContext ctx)
      Overrides:
      read in class BeanProperty
    • add

      public void add(io.ebean.bean.BeanCollection<?> collection, io.ebean.bean.EntityBean bean)
    • assocIsEmpty

      public String assocIsEmpty(SpiExpressionRequest request, String path)
      Description copied from interface: ElPropertyValue
      Return the logical where clause to support "Is empty".
      Specified by:
      assocIsEmpty in interface ElPropertyValue
      Overrides:
      assocIsEmpty in class BeanProperty
    • assocIdValues

      public Object[] assocIdValues(io.ebean.bean.EntityBean bean)
      Return the Id values from the given bean.
      Specified by:
      assocIdValues in interface io.ebean.plugin.ExpressionPath
      Overrides:
      assocIdValues in class BeanProperty
    • assocIdExpression

      public String assocIdExpression(String prefix, String operator)
      Return the Id expression to add to where clause etc.
      Specified by:
      assocIdExpression in interface io.ebean.plugin.ExpressionPath
      Overrides:
      assocIdExpression in class BeanProperty
    • assocIdInValueExpr

      public String assocIdInValueExpr(boolean not, int size)
      Return the logical id value expression taking into account embedded id's.
      Specified by:
      assocIdInValueExpr in interface ElPropertyValue
      Overrides:
      assocIdInValueExpr in class BeanProperty
    • assocIdInExpr

      public String assocIdInExpr(String prefix)
      Return the logical id in expression taking into account embedded id's.
      Specified by:
      assocIdInExpr in interface ElPropertyValue
      Overrides:
      assocIdInExpr in class BeanProperty
    • isMany

      public boolean isMany()
      Specified by:
      isMany in interface io.ebean.plugin.Property
      Overrides:
      isMany in class BeanProperty
    • hasOrderColumn

      public boolean hasOrderColumn()
    • isOrphanRemoval

      public boolean isOrphanRemoval()
    • isAssocMany

      public boolean isAssocMany()
      Description copied from interface: ElPropertyValue
      Return true if the property is a OneToMany or ManyToMany associated bean property.
      Specified by:
      isAssocMany in interface ElPropertyValue
      Overrides:
      isAssocMany in class BeanProperty
    • isAssocId

      public boolean isAssocId()
      Description copied from interface: ElPropertyValue
      Return true if this is an ManyToOne or OneToOne associated bean property.
      Specified by:
      isAssocId in interface ElPropertyValue
      Specified by:
      isAssocId in interface io.ebean.plugin.ExpressionPath
      Overrides:
      isAssocId in class BeanProperty
    • isAssocProperty

      public boolean isAssocProperty()
      Description copied from interface: ElPropertyValue
      Return true if any path of this path contains a Associated One or Many.
      Specified by:
      isAssocProperty in interface ElPropertyValue
      Overrides:
      isAssocProperty in class BeanProperty
    • containsMany

      public boolean containsMany()
      Returns true.
      Specified by:
      containsMany in interface ElPropertyDeploy
      Specified by:
      containsMany in interface io.ebean.plugin.ExpressionPath
      Overrides:
      containsMany in class BeanProperty
    • manyType

      public ManyType manyType()
      Return the many type.
    • hasJoinTable

      public boolean hasJoinTable()
      Return true if this is many to many.
      Specified by:
      hasJoinTable in interface STreePropertyAssocMany
    • isO2mJoinTable

      public boolean isO2mJoinTable()
      Return true if this is a one to many with a join table.
    • isManyToMany

      public boolean isManyToMany()
      Return true if this is many to many.
    • isElementCollection

      public boolean isElementCollection()
    • elementDescriptor

      public BeanDescriptor<T> elementDescriptor()
      Return the element bean descriptor (for an element collection only).
    • intersectionTableJoin

      public TableJoin intersectionTableJoin()
      ManyToMany only, join from local table to intersection table.
      Specified by:
      intersectionTableJoin in interface STreePropertyAssocMany
    • setParentToChild

      public void setParentToChild(io.ebean.bean.EntityBean parent, io.ebean.bean.EntityBean child, Object mapKeyValue)
      Set the parent bean to the child (update the relationship).
    • setParentToChild

      public boolean setParentToChild(io.ebean.bean.EntityBean parent, io.ebean.bean.EntityBean child, Object mapKeyValue, BeanDescriptor<?> parentDesc)
      Return true if the parent bean has been set to the child (updated the relationship).
    • fetchOrderBy

      public String fetchOrderBy()
      Return the order by clause used to order the fetching of the data for this list, set or map.
      Specified by:
      fetchOrderBy in interface ElPropertyDeploy
      Specified by:
      fetchOrderBy in interface SpiQueryManyJoin
    • lazyFetchOrderBy

      public String lazyFetchOrderBy()
      Return the order by for use when lazy loading the associated collection.
    • mapKey

      public String mapKey()
      Return the default mapKey when returning a Map.
    • createEmptyReference

      public void createEmptyReference(io.ebean.bean.EntityBean localBean)
      Description copied from interface: STreePropertyAssocMany
      Populate the collection for read-only disabled lazy loading (aka Java Collections non-mutable empty collection).
      Specified by:
      createEmptyReference in interface STreePropertyAssocMany
    • createReference

      public io.ebean.bean.BeanCollection<?> createReference(io.ebean.bean.EntityBean localBean, boolean forceNewReference)
      Description copied from interface: STreePropertyAssocMany
      Return a reference collection forcing a new reference on REFRESH query.
      Specified by:
      createReference in interface STreePropertyAssocMany
    • createReferenceIfNull

      public io.ebean.bean.BeanCollection<?> createReferenceIfNull(io.ebean.bean.EntityBean parentBean)
      Description copied from interface: STreePropertyAssocMany
      Return a reference collection.
      Specified by:
      createReferenceIfNull in interface STreePropertyAssocMany
    • createReference

      public io.ebean.bean.BeanCollection<?> createReference(io.ebean.bean.EntityBean parentBean)
    • createEmpty

      public io.ebean.bean.BeanCollection<T> createEmpty(io.ebean.bean.EntityBean parentBean)
    • parentId

      public Object parentId(io.ebean.bean.EntityBean parentBean)
    • addSelectExported

      public void addSelectExported(DbSqlContext ctx, String tableAlias)
      Description copied from interface: STreePropertyAssocMany
      Append exported columns to the select.
      Specified by:
      addSelectExported in interface STreePropertyAssocMany
    • buildManyDeleteChildren

      public IntersectionRow buildManyDeleteChildren(io.ebean.bean.EntityBean parentBean, Set<Object> excludeDetailIds)
    • buildManyToManyDeleteChildren

      public IntersectionRow buildManyToManyDeleteChildren(io.ebean.bean.EntityBean parentBean)
    • buildManyToManyMapBean

      public IntersectionRow buildManyToManyMapBean(io.ebean.bean.EntityBean parent, io.ebean.bean.EntityBean other)
    • intersectionBind

      public void intersectionBind(io.ebean.SqlUpdate sql, io.ebean.bean.EntityBean parentBean, io.ebean.bean.EntityBean other)
      Bind the two side of a many to many to the given SqlUpdate.
    • hasImportedId

      public boolean hasImportedId(io.ebean.bean.EntityBean otherBean)
      Return true if the otherBean has an Id value.
    • jsonWriteValue

      public void jsonWriteValue(SpiJsonWriter writeJson, Object value)
      Skip JSON write value for ToMany property.
      Overrides:
      jsonWriteValue in class BeanProperty
    • jsonWrite

      public void jsonWrite(SpiJsonWriter ctx, io.ebean.bean.EntityBean bean) throws IOException
      Description copied from class: BeanProperty
      JSON write the bean property.
      Overrides:
      jsonWrite in class BeanProperty
      Throws:
      IOException
    • jsonRead

      public void jsonRead(SpiJsonReader readJson, io.ebean.bean.EntityBean parentBean) throws IOException
      Overrides:
      jsonRead in class BeanProperty
      Throws:
      IOException
    • isIncludeCascadeSave

      public boolean isIncludeCascadeSave()
    • isIncludeCascadeDelete

      public boolean isIncludeCascadeDelete()
    • insertElementCollection

      public SpiSqlUpdate insertElementCollection()
    • isUseCache

      public boolean isUseCache()
      Only cache Many Ids if the target bean is also cached.
    • setCacheDataValue

      public void setCacheDataValue(io.ebean.bean.EntityBean bean, Object cacheData, io.ebean.bean.PersistenceContext context)
      A Many (element collection) property in bean cache to held as JSON.
      Overrides:
      setCacheDataValue in class BeanProperty
    • getCacheDataValue

      public Object getCacheDataValue(io.ebean.bean.EntityBean bean)
      Description copied from class: BeanProperty
      Return the value for this property which we hold in the L2 cache entry.

      This uses format() where possible to store the value as a string and this is done to make any resulting Java object serialisation content smaller as strings get special treatment.

      Overrides:
      getCacheDataValue in class BeanProperty
    • jsonWriteCollection

      public String jsonWriteCollection(Object value) throws IOException
      Write the collection to JSON.
      Throws:
      IOException
    • jsonReadCollection

      public Object jsonReadCollection(SpiJsonReader readJson, io.ebean.bean.EntityBean parentBean, Object targets) throws IOException
      Read the collection (JSON Array) containing entity beans.
      Throws:
      IOException
    • bindElementValue

      public void bindElementValue(io.ebean.SqlUpdate insert, Object value)
      Bind all the property values to the SqlUpdate.
    • createJoinTable

      public boolean createJoinTable()
      Returns true, if we must create a m2m join table.
    • freeze

      public void freeze(io.ebean.bean.EntityBean entityBean)
      Description copied from class: BeanProperty
      Freeze mutable types (like DbArray).
      Overrides:
      freeze in class BeanProperty