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.SimpleIterator
Nested 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
ConstructorDescriptionToOneRelationAdapter
(Entity sourceEntity, RelationModel relationModel, EntityFacadeListenerManager entityFacadeListenerManager, EntityInterceptor entityInterceptor, PropertyAccessorService propertyAccessorService) -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all entities in this relation.@Nullable Entity
get()
Get the current single target entity of this relation.@Nullable Entity
get
(int index, boolean eager) Get the entity at the specified index.void
Set the relation's entities to the specified single entity.void
Creates 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 void
setInverseRelation
(@Nullable Entity oldValue, @Nullable Entity newValue) protected void
int
size()
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, verifyTransactionIsRunning
Methods inherited from class ch.tocco.nice2.persist.core.api.entity.AbstractEntityList
contains, get, get, get, isEmpty, iterator, toList, toList
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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, toList
Methods 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:
getInnerInterceptor
in classAbstractRelationAdapter
-
setValue
-
setInverseRelation
-
size
public int size()Description copied from interface:EntityList
Get the number of entities this list contains.- Returns:
- The number of entities.
-
get
Description copied from interface:Relation
Get the current single target entity of this relation. This method may only be called for relations to a single entity (n-1).- Specified by:
get
in interfaceRelation
- Overrides:
get
in classAbstractRelationAdapter
- Returns:
- The current single target entity potentially in
unusable state
, ornull
.
-
get
Description copied from interface:EntityList
Get 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:Relation
Set 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:
set
in interfaceRelation
- Overrides:
set
in classAbstractRelationAdapter
- Parameters:
entity
- The entity to be set, may be in state conception.
-
set
Description copied from interface:Relation
Creates 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:Relation
Removes all entities in this relation. Does the same as calling remove() for all linked entities.
-