Package cz.cvut.kbss.jopa.sessions
Class ReadOnlyUnitOfWork
java.lang.Object
cz.cvut.kbss.jopa.sessions.AbstractSession
cz.cvut.kbss.jopa.sessions.AbstractUnitOfWork
cz.cvut.kbss.jopa.sessions.ReadOnlyUnitOfWork
- All Implemented Interfaces:
ConfigurationHolder,MetamodelProvider,UnitOfWork,Wrapper
-
Field Summary
Fields inherited from class cz.cvut.kbss.jopa.sessions.AbstractUnitOfWork
LOGFields inherited from class cz.cvut.kbss.jopa.sessions.AbstractSession
configuration -
Method Summary
Modifier and TypeMethodDescriptionvoidattributeChanged(Object entity, FieldSpecification<?, ?> fieldSpec) Method is not supported.voidattributeChanged(Object entity, Field f) Method is not supported.voidclear()Clears this Unit of Work.voidcommit()ReadOnlyUnitOfWorkcommits nothing.voidcreateIndirectCollection(Object collection, Object owner, Field field) Creates an indirect collection that wraps the specified collection instance and propagates changes to this persistence context.protected voidevictAfterMerge(EntityType<?> et, URI identifier, Descriptor descriptor) Method not supported.getCloneForOriginal(Object original) Simply returns the specified original object.protected <T> TgetInstanceForMerge(URI identifier, EntityType<T> et, Descriptor descriptor) Method not supported.<T> TgetManagedOriginal(Class<T> cls, Object identifier, Descriptor descriptor) Gets managed original with the specified identifier ornullif there is none matching.getOriginal(Object entity) Simply returns the specified entity.<T> TgetReference(Class<T> cls, Object identifier, Descriptor descriptor) Retrieves an object with the specified identifier.Gets the lifecycle state of the specified entity.getState(Object entity, Descriptor descriptor) Gets the lifecycle state of the specified entity with respect to a repository context indicated by the specified descriptor.booleanMethod is not supported.booleanMethod is not supported.booleanisObjectManaged(Object entity) Return true if the given entity is managed.booleanisObjectNew(Object entity) Method not supported.booleanprotected voidmarkCloneForDeletion(Object entity, Object identifier) Method is not supported.<T> TmergeDetached(T entity, Descriptor descriptor) Method not supported.<T> TmergeDetachedInternal(T entity, Descriptor descriptor) Method not supported.protected ObjectChangeSetprocessInferredValueChanges(ObjectChangeSet changeSet) Method is not supported.voidputObjectIntoCache(Object identifier, Object entity, Descriptor descriptor) Does nothing.<T> TreadObjectFromAxioms(Class<T> cls, Collection<Axiom<?>> axioms, Descriptor descriptor) Reads an object from the specified axioms.protected <T> TreadObjectInternal(Class<T> cls, Object identifier, Descriptor descriptor) <T> voidrefreshObject(T object) Method not supported.registerExistingObject(Object entity, Descriptor descriptor) Register an existing object in this Unit of Work without cloning it.registerExistingObject(Object entity, CloneRegistrationDescriptor registrationDescriptor) Register an existing object in this Unit of Work.voidregisterNewObject(Object entity, Descriptor descriptor) Method is not supported.voidregisterOriginalForNewClone(Object clone, Object original) Method is not supported.voidremoveObject(Object object) Method is not supported.voidremoveObjectFromCache(Object toRemove, URI context) Method not supported.voidrestoreRemovedObject(Object entity) Method is not supported.voidunregisterObject(Object object) Detaches the specified registered object from this Unit of Work.voidMethod is not supported.Methods inherited from class cz.cvut.kbss.jopa.sessions.AbstractUnitOfWork
acquireConnection, begin, contains, copyChangeSet, entityType, getContexts, getCriteriaBuilder, getFieldDescriptor, getLiveObjectCache, getLoadStateRegistry, getMetamodel, isActive, isConsistent, isEntityType, isInferred, isInRepository, isInTransaction, isLoaded, isLoaded, loadEntityField, readObject, readObjectWithoutRegistration, release, removeIndirectWrappersAndProxies, rollback, sparqlQueryFactory, stringify, unregisterEntityFromOntologyContext, unwrapMethods inherited from class cz.cvut.kbss.jopa.sessions.AbstractSession
getConfigurationMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface cz.cvut.kbss.jopa.sessions.ConfigurationHolder
getConfigurationMethods inherited from interface cz.cvut.kbss.jopa.sessions.MetamodelProvider
getNamedQueryManager, getResultSetMappingManager
-
Method Details
-
clear
public void clear()Description copied from interface:UnitOfWorkClears this Unit of Work.- Specified by:
clearin interfaceUnitOfWork- Overrides:
clearin classAbstractUnitOfWork
-
commit
public void commit()ReadOnlyUnitOfWorkcommits nothing. The persistence context is cleared.- Specified by:
commitin interfaceUnitOfWork- Overrides:
commitin classAbstractUnitOfWork
-
readObjectInternal
- Overrides:
readObjectInternalin classAbstractUnitOfWork
-
getManagedOriginal
Gets managed original with the specified identifier ornullif there is none matching.Descriptor is used to check repository context validity. Note that the
ReadOnlyUnitOfWorkdoes not distinguish between original and cloned objects.- Overrides:
getManagedOriginalin classAbstractUnitOfWork- Parameters:
cls- Return type of the originalidentifier- Instance identifierdescriptor- Repository descriptor- Returns:
- Original object managed by this UoW or
nullif this UoW doesn't contain a matching instance
-
readObjectFromAxioms
Description copied from interface:UnitOfWorkReads an object from the specified axioms.It is assumed the axioms correspond to the provided descriptor.
- Specified by:
readObjectFromAxiomsin interfaceUnitOfWork- Overrides:
readObjectFromAxiomsin classAbstractUnitOfWork- Type Parameters:
T- Return type- Parameters:
cls- Expected result classaxioms- Axioms representing the objectdescriptor- Entity descriptor- Returns:
- The retrieved object or
nullif no object of the expected target class can be reconstructed
-
unregisterObject
Detaches the specified registered object from this Unit of Work.- Specified by:
unregisterObjectin interfaceUnitOfWork- Overrides:
unregisterObjectin classAbstractUnitOfWork- Parameters:
object- Entity to detach
-
registerExistingObject
Register an existing object in this Unit of Work without cloning it.- Specified by:
registerExistingObjectin interfaceUnitOfWork- Overrides:
registerExistingObjectin classAbstractUnitOfWork- Parameters:
entity- Objectdescriptor- Entity descriptor identifying repository contexts- Returns:
- Registered entity
- See Also:
-
registerExistingObject
public Object registerExistingObject(Object entity, CloneRegistrationDescriptor registrationDescriptor) Register an existing object in this Unit of Work. Creates a working clone of the specified object according to the configuration.- Specified by:
registerExistingObjectin interfaceUnitOfWork- Overrides:
registerExistingObjectin classAbstractUnitOfWork- Parameters:
entity- ObjectregistrationDescriptor- Configuration of the registration- Returns:
- Registered clone of the specified object.
-
getOriginal
Simply returns the specified entity.ReadOnlyUnitOfWorkdoes not distinguish between original and cloned objects.- Overrides:
getOriginalin classAbstractUnitOfWork- Parameters:
entity- Object- Returns:
- the specified entity.
-
isObjectManaged
Return true if the given entity is managed.- Specified by:
isObjectManagedin interfaceUnitOfWork- Overrides:
isObjectManagedin classAbstractUnitOfWork- Parameters:
entity- Object to check- Returns:
truewhen the entity is managed,falseotherwise
-
getState
Gets the lifecycle state of the specified entity.ReadOnlyUnitOfWork- Specified by:
getStatein interfaceUnitOfWork- Overrides:
getStatein classAbstractUnitOfWork- Parameters:
entity- Entity whose state to resolve- Returns:
EntityState.MANAGEDif this Unit Of Work contains the specified entity,EntityState.NOT_MANAGEDotherwise
-
getState
Description copied from interface:UnitOfWorkGets the lifecycle state of the specified entity with respect to a repository context indicated by the specified descriptor.- Specified by:
getStatein interfaceUnitOfWork- Overrides:
getStatein classAbstractUnitOfWork- Parameters:
entity- Entity whose state to resolvedescriptor- Descriptor of repository contexts- Returns:
- Entity state
-
getReference
Retrieves an object with the specified identifier.A reference is not retrieved! The method is implemented via the
readObjectand has exactly the same behavior.- Specified by:
getReferencein interfaceUnitOfWork- Overrides:
getReferencein classAbstractUnitOfWork- Type Parameters:
T- Entity type- Parameters:
cls- The type of the returned objectidentifier- Instance identifierdescriptor- Entity descriptor- Returns:
- The retrieved object or
nullif there is no object with the specified identifier in the specified repository
-
getCloneForOriginal
Simply returns the specified original object.ReadOnlyUnitOfWorkdoes not distinguish between original and cloned objects.- Specified by:
getCloneForOriginalin interfaceUnitOfWork- Overrides:
getCloneForOriginalin classAbstractUnitOfWork- Parameters:
original- The original object whose clone we are looking for- Returns:
- specified original
-
createIndirectCollection
Creates an indirect collection that wraps the specified collection instance and propagates changes to this persistence context.ReadOnlyUnitOfWorksimply returns the specified collection. No special indirect collection is needed.- Parameters:
collection- Collection to be proxiedowner- Collection owner instancefield- Field filled with the collection- Returns:
- Indirect collection
-
putObjectIntoCache
Does nothing.ReadOnlyUnitOfWorkshould not put objects into the cache.- Specified by:
putObjectIntoCachein interfaceUnitOfWork- Overrides:
putObjectIntoCachein classAbstractUnitOfWork- Parameters:
identifier- Object identifierentity- Object to cachedescriptor- Descriptor of repository context
-
commitToStorage
public void commitToStorage() -
isReadOnly
public boolean isReadOnly()- Overrides:
isReadOnlyin classAbstractUnitOfWork
-
removeObjectFromCache
public void removeObjectFromCache(Object toRemove, URI context) throws UnsupportedOperationException Method not supported.- Specified by:
removeObjectFromCachein interfaceUnitOfWork- Overrides:
removeObjectFromCachein classAbstractUnitOfWork- Parameters:
toRemove- Object to remove from cachecontext- Entity context URI- Throws:
UnsupportedOperationException- Method not supported.
-
isObjectNew
Method not supported.- Specified by:
isObjectNewin interfaceUnitOfWork- Overrides:
isObjectNewin classAbstractUnitOfWork- Parameters:
entity- Object to check- Returns:
truewhen entity is managed and new,falseotherwise- Throws:
UnsupportedOperationException- Method not supported.- See Also:
-
mergeDetached
Method not supported.- Specified by:
mergeDetachedin interfaceUnitOfWork- Overrides:
mergeDetachedin classAbstractUnitOfWork- Parameters:
entity- entity instancedescriptor- Entity descriptor, specifies repository context- Returns:
- the managed instance that the state was merged to
- Throws:
UnsupportedOperationException- Method not supported.
-
mergeDetachedInternal
public <T> T mergeDetachedInternal(T entity, Descriptor descriptor) throws UnsupportedOperationException Method not supported.- Throws:
UnsupportedOperationException- Method not supported.
-
getInstanceForMerge
protected <T> T getInstanceForMerge(URI identifier, EntityType<T> et, Descriptor descriptor) throws UnsupportedOperationException Method not supported.- Overrides:
getInstanceForMergein classAbstractUnitOfWork- Throws:
UnsupportedOperationException- Method not supported.
-
evictAfterMerge
protected void evictAfterMerge(EntityType<?> et, URI identifier, Descriptor descriptor) throws UnsupportedOperationException Method not supported.- Overrides:
evictAfterMergein classAbstractUnitOfWork- Throws:
UnsupportedOperationException- Method not supported.
-
refreshObject
Method not supported.- Specified by:
refreshObjectin interfaceUnitOfWork- Overrides:
refreshObjectin classAbstractUnitOfWork- Type Parameters:
T- Object type- Parameters:
object- The object to revert- Throws:
UnsupportedOperationException- Method not supported.
-
processInferredValueChanges
protected ObjectChangeSet processInferredValueChanges(ObjectChangeSet changeSet) throws UnsupportedOperationException Method is not supported.- Overrides:
processInferredValueChangesin classAbstractUnitOfWork- Throws:
UnsupportedOperationException- Always thrown
-
registerOriginalForNewClone
public void registerOriginalForNewClone(Object clone, Object original) throws UnsupportedOperationException Method is not supported.- Overrides:
registerOriginalForNewClonein classAbstractUnitOfWork- Parameters:
clone- Already registered cloneoriginal- Original to register- Throws:
UnsupportedOperationException- Always thrown
-
writeUncommittedChanges
Method is not supported.- Specified by:
writeUncommittedChangesin interfaceUnitOfWork- Overrides:
writeUncommittedChangesin classAbstractUnitOfWork- Throws:
UnsupportedOperationException- Always thrown
-
hasChanges
Method is not supported.- Overrides:
hasChangesin classAbstractUnitOfWork- Throws:
UnsupportedOperationException- Always thrown
-
restoreRemovedObject
Method is not supported.- Specified by:
restoreRemovedObjectin interfaceUnitOfWork- Overrides:
restoreRemovedObjectin classAbstractUnitOfWork- Parameters:
entity- The object to restore- Throws:
UnsupportedOperationException- Always thrown
-
isFlushingChanges
Method is not supported.- Specified by:
isFlushingChangesin interfaceUnitOfWork- Overrides:
isFlushingChangesin classAbstractUnitOfWork- Returns:
trueif the UoW is flushing changes,falseotherwise- Throws:
UnsupportedOperationException- Always thrown
-
attributeChanged
Method is not supported.- Parameters:
entity- Entity with changes (the clone)f- The field whose value has changed- Throws:
UnsupportedOperationException- Always thrown- See Also:
-
attributeChanged
public void attributeChanged(Object entity, FieldSpecification<?, ?> fieldSpec) throws UnsupportedOperationExceptionMethod is not supported.- Parameters:
entity- Entity with changes (the clone)fieldSpec- Metamodel element representing the attribute that changed- Throws:
UnsupportedOperationException- Always thrown
-
markCloneForDeletion
protected void markCloneForDeletion(Object entity, Object identifier) throws UnsupportedOperationException Method is not supported.- Overrides:
markCloneForDeletionin classAbstractUnitOfWork- Throws:
UnsupportedOperationException- Always thrown
-
registerNewObject
public void registerNewObject(Object entity, Descriptor descriptor) throws UnsupportedOperationException Method is not supported.- Specified by:
registerNewObjectin interfaceUnitOfWork- Overrides:
registerNewObjectin classAbstractUnitOfWork- Parameters:
entity- The object to registerdescriptor- Entity descriptor- Throws:
UnsupportedOperationException- Always thrown
-
removeObject
Method is not supported.- Parameters:
object- Object to remove- Throws:
UnsupportedOperationException- Always thrown
-