Record Class DataContextChannel
java.lang.Object
java.lang.Record
org.apache.cayenne.access.DataContextChannel
- All Implemented Interfaces:
DataChannel
A
DataChannel that connects a nested ObjectContext to its parent DataContext. All channel
operations are delegated to the parent context. Note that the parent context posts channel events on its own behalf,
so listeners interested in those events should listen to the context, not to this channel.- Since:
- 5.0
-
Field Summary
Fields inherited from interface DataChannel
FLUSH_CASCADE_SYNC, FLUSH_NOCASCADE_SYNC, GRAPH_CHANGED_SUBJECT, GRAPH_FLUSHED_SUBJECT, GRAPH_ROLLEDBACK_SUBJECT, ROLLBACK_CASCADE_SYNC -
Constructor Summary
ConstructorsConstructorDescriptionDataContextChannel(DataContext context) Creates an instance of aDataContextChannelrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncontext()Returns the value of thecontextrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns an EntityResolver instance that contains runtime mapping information.Returns an EventManager associated with this channel.Returns the parent channel of this channel in the DataChannel stack, or null if this is a root channel (such as aDataDomain).final inthashCode()Returns a hash code value for this object.onIdQuery(ObjectContext childContext, ObjectId id) Resolves an object by id, returning it registered with the originating context.voidonInvalidate(ObjectContext childContext, Collection<ObjectId> objectIds) Invalidates objects with the given ids in this channel and all its parents, so that they are refetched on the next access.onQuery(ObjectContext childContext, Query query, boolean iteratedResult) Executes a query, using provided context to register persistent objects if query returns any objects.onRelationshipQuery(ObjectContext childContext, ObjectId sourceId, String relationshipName) Resolves objects related to a given object via a mapped relationship, returning them registered with the originating context.onSync(ObjectContext childContext, GraphDiff changes, int syncType) Processes synchronization request from a child ObjectContext, returning a GraphDiff that describes changes to objects made on the receiving end as a result of synchronization.final StringtoString()Returns a string representation of this record class.Methods inherited from interface DataChannel
getDataDomain
-
Constructor Details
-
DataContextChannel
Creates an instance of aDataContextChannelrecord class.- Parameters:
context- the value for thecontextrecord component
-
-
Method Details
-
getEventManager
Description copied from interface:DataChannelReturns an EventManager associated with this channel. Channel may return null if EventManager is not available for any reason.- Specified by:
getEventManagerin interfaceDataChannel
-
getEntityResolver
Description copied from interface:DataChannelReturns an EntityResolver instance that contains runtime mapping information.- Specified by:
getEntityResolverin interfaceDataChannel
-
getParent
Description copied from interface:DataChannelReturns the parent channel of this channel in the DataChannel stack, or null if this is a root channel (such as aDataDomain).- Specified by:
getParentin interfaceDataChannel
-
onQuery
Description copied from interface:DataChannelExecutes a query, using provided context to register persistent objects if query returns any objects.- Specified by:
onQueryin interfaceDataChannel- Parameters:
childContext- an ObjectContext that originated the query, used to register result objects.query- a query to execute.iteratedResult- if true, the result is returned as aResultIteratoritem, and the caller is responsible for closing it. If false, the result is fully read into a list.- Returns:
- all result sets, update counts, iterators and OUT parameters of the execution, in the order they were produced.
-
onInvalidate
Description copied from interface:DataChannelInvalidates objects with the given ids in this channel and all its parents, so that they are refetched on the next access. In a context, matching registered objects are turned HOLLOW and their uncommitted changes are discarded. At the root of the channel stack, their snapshots are evicted from the snapshot cache, and peer contexts are notified via a snapshot event. Objects unknown to a given channel are ignored.This is a callback invoked by a child context after it has invalidated its own objects. Application code should call
ObjectContext.invalidateObjects(Collection)instead.- Specified by:
onInvalidatein interfaceDataChannel- Parameters:
childContext- an ObjectContext that originated the invalidation.objectIds- ids of the objects to invalidate.
-
onIdQuery
Description copied from interface:DataChannelResolves an object by id, returning it registered with the originating context. The object is looked up in the caches down the channel stack before being fetched from the database, so the returned object may reflect a cached state.This is a callback invoked by a child context to resolve a HOLLOW object, or to look up an object it has no registered copy of. Application code should call
ObjectContext.objectForPK(ObjectId)instead.- Specified by:
onIdQueryin interfaceDataChannel- Parameters:
childContext- an ObjectContext that originated the request and that the returned object belongs to.id- id of the object to resolve.- Returns:
- the object registered with the originating context, or null if no matching row exists.
-
onRelationshipQuery
public List<Persistent> onRelationshipQuery(ObjectContext childContext, ObjectId sourceId, String relationshipName) Description copied from interface:DataChannelResolves objects related to a given object via a mapped relationship, returning them registered with the originating context.- Specified by:
onRelationshipQueryin interfaceDataChannel- Parameters:
childContext- an ObjectContext that originated the request and that the returned objects belong to.sourceId- id of the object on the source side of the relationship.relationshipName- name of the relationship to resolve.- Returns:
- related objects registered with the originating context. An empty list means that a to-one target is null, or a to-many relationship has no matching objects.
-
onSync
Description copied from interface:DataChannelProcesses synchronization request from a child ObjectContext, returning a GraphDiff that describes changes to objects made on the receiving end as a result of synchronization.- Specified by:
onSyncin interfaceDataChannel- Parameters:
childContext- an ObjectContext that initiated the sync. Can be null.changes- diff from the context that initiated the sync.syncType- One ofDataChannel.FLUSH_NOCASCADE_SYNC,DataChannel.FLUSH_CASCADE_SYNC,DataChannel.ROLLBACK_CASCADE_SYNC.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
context
Returns the value of thecontextrecord component.- Returns:
- the value of the
contextrecord component
-