Class ToOneRelationAdapter
java.lang.Object
ch.tocco.nice2.persist.core.api.entity.AbstractEntityList
ch.tocco.nice2.persist.core.impl.hibernate.pojo.relation.AbstractRelationAdapter
ch.tocco.nice2.persist.core.impl.hibernate.pojo.relation.ToOneRelationAdapter
- All Implemented Interfaces:
EntityList,Relation,Iterable<Entity>
Maps a to-one hibernate collection to the
Relation interface-
Nested Class Summary
Nested classes/interfaces inherited from class ch.tocco.nice2.persist.core.api.entity.AbstractEntityList
AbstractEntityList.SimpleIteratorNested classes/interfaces inherited from interface ch.tocco.nice2.persist.core.api.entity.EntityList
EntityList.Filter -
Field Summary
Fields inherited from class ch.tocco.nice2.persist.core.impl.hibernate.pojo.relation.AbstractRelationAdapter
entityFacadeListenerManager, relationInterceptor, relationModel, sourceEntity -
Constructor Summary
ConstructorsConstructorDescriptionToOneRelationAdapter(Entity sourceEntity, RelationModel relationModel, EntityFacadeListenerManager entityFacadeListenerManager, EntityInterceptor entityInterceptor, PropertyAccessorService propertyAccessorService) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all entities in this relation.@Nullable Entityget()Get the current single target entity of this relation.@Nullable Entityget(int index, boolean eager) Get the entity at the specified index.voidSet the relation's entities to the specified single entity.voidCreates an intersection of the currently linked ones and the given ones, and then callsRelation.remove(ch.tocco.nice2.persist.core.api.entity.Entity)andRelation.add(ch.tocco.nice2.persist.core.api.entity.Entity)in a loop.protected voidsetInverseRelation(@Nullable Entity oldValue, @Nullable Entity newValue) protected voidintsize()Get the number of entities this list contains.Methods inherited from class ch.tocco.nice2.persist.core.impl.hibernate.pojo.relation.AbstractRelationAdapter
add, expect, expectAtLeast, expectAtMost, fireRelationChangingEvent, getKey, getKeys, getManager, getModel, getPageCount, getPageSize, getRelationModel, getSource, indexOf, remove, setPageSize, unwrap, verifyTransactionIsRunningMethods inherited from class ch.tocco.nice2.persist.core.api.entity.AbstractEntityList
contains, get, get, get, isEmpty, iterator, toList, toListMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ch.tocco.nice2.persist.core.api.entity.EntityList
contains, doWithSingleResult, doWithSingleResultOr, expectOr, get, getFirstEntity, getOnlyResult, getOptionalOnlyResult, getOptionalOnlyResult, isEmpty, requireFirstEntity, spliterator, stream, toList, toListMethods inherited from interface ch.tocco.nice2.persist.core.api.entity.Relation
expectAtMostOrThrow, expectOrThrow, get, get
-
Constructor Details
-
ToOneRelationAdapter
public ToOneRelationAdapter(Entity sourceEntity, RelationModel relationModel, EntityFacadeListenerManager entityFacadeListenerManager, EntityInterceptor entityInterceptor, PropertyAccessorService propertyAccessorService)
-
-
Method Details
-
getInnerInterceptor
- Specified by:
getInnerInterceptorin classAbstractRelationAdapter
-
setValue
-
setInverseRelation
-
size
public int size()Description copied from interface:EntityListGet the number of entities this list contains.- Returns:
- The number of entities.
-
get
Description copied from interface:RelationGet the current single target entity of this relation. This method may only be called for relations to a single entity (n-1).- Specified by:
getin interfaceRelation- Overrides:
getin classAbstractRelationAdapter- Returns:
- The current single target entity potentially in
unusable state, ornull.
-
get
Description copied from interface:EntityListGet the entity at the specified index.- Parameters:
index- The index.eager-true, if a page should be eagerly loaded, if the entity's state ishollow, false otherwise.- Returns:
- The entity at the specified index potentially in
unusable state, ornull.
-
set
Description copied from interface:RelationSet the relation's entities to the specified single entity. Any other entities will be removed. This method may only be called for relations to a single entity (n-1).NOTE: This calls
Relation.remove(ch.tocco.nice2.persist.core.api.entity.Entity)andRelation.add(ch.tocco.nice2.persist.core.api.entity.Entity)internally. That's also why the interceptor does not have this.- Specified by:
setin interfaceRelation- Overrides:
setin classAbstractRelationAdapter- Parameters:
entity- The entity to be set, may be in state conception.
-
set
Description copied from interface:RelationCreates an intersection of the currently linked ones and the given ones, and then callsRelation.remove(ch.tocco.nice2.persist.core.api.entity.Entity)andRelation.add(ch.tocco.nice2.persist.core.api.entity.Entity)in a loop.- Parameters:
entities- The list of entities that will be the only linked ones.
-
clear
public void clear()Description copied from interface:RelationRemoves all entities in this relation. Does the same as calling remove() for all linked entities.
-