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
LOG
Fields inherited from class cz.cvut.kbss.jopa.sessions.AbstractSession
configuration
-
Method Summary
Modifier and TypeMethodDescriptionvoid
attributeChanged
(Object entity, FieldSpecification<?, ?> fieldSpec) Method is not supported.void
attributeChanged
(Object entity, Field f) Method is not supported.void
clear()
Clears this Unit of Work.void
commit()
ReadOnlyUnitOfWork
commits nothing.void
createIndirectCollection
(Object collection, Object owner, Field field) Creates an indirect collection that wraps the specified collection instance and propagates changes to this persistence context.protected void
evictAfterMerge
(EntityType<?> et, URI identifier, Descriptor descriptor) Method not supported.getCloneForOriginal
(Object original) Simply returns the specified original object.protected <T> T
getInstanceForMerge
(URI identifier, EntityType<T> et, Descriptor descriptor) Method not supported.<T> T
getManagedOriginal
(Class<T> cls, Object identifier, Descriptor descriptor) Gets managed original with the specified identifier ornull
if there is none matching.getOriginal
(Object entity) Simply returns the specified entity.<T> T
getReference
(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.boolean
Method is not supported.boolean
Method is not supported.boolean
isObjectManaged
(Object entity) Return true if the given entity is managed.boolean
isObjectNew
(Object entity) Method not supported.protected void
markCloneForDeletion
(Object entity, Object identifier) Method is not supported.<T> T
mergeDetached
(T entity, Descriptor descriptor) Method not supported.<T> T
mergeDetachedInternal
(T entity, Descriptor descriptor) Method not supported.protected ObjectChangeSet
processInferredValueChanges
(ObjectChangeSet changeSet) Method is not supported.void
putObjectIntoCache
(Object identifier, Object entity, Descriptor descriptor) Does nothing.protected <T> T
readObjectInternal
(Class<T> cls, Object identifier, Descriptor descriptor) <T> void
refreshObject
(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.void
registerNewObject
(Object entity, Descriptor descriptor) Method is not supported.void
registerOriginalForNewClone
(Object clone, Object original) Method is not supported.void
removeObject
(Object object) Method is not supported.void
removeObjectFromCache
(Object toRemove, URI context) Method not supported.void
restoreRemovedObject
(Object entity) Method is not supported.void
unregisterObject
(Object object) Detaches the specified registered object from this Unit of Work.void
Method 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, unwrap
Methods inherited from class cz.cvut.kbss.jopa.sessions.AbstractSession
getConfiguration
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface cz.cvut.kbss.jopa.sessions.ConfigurationHolder
getConfiguration
Methods inherited from interface cz.cvut.kbss.jopa.sessions.MetamodelProvider
getNamedQueryManager, getResultSetMappingManager
-
Method Details
-
clear
public void clear()Description copied from interface:UnitOfWork
Clears this Unit of Work.- Specified by:
clear
in interfaceUnitOfWork
- Overrides:
clear
in classAbstractUnitOfWork
-
commit
public void commit()ReadOnlyUnitOfWork
commits nothing. The persistence context is cleared.- Specified by:
commit
in interfaceUnitOfWork
- Overrides:
commit
in classAbstractUnitOfWork
-
readObjectInternal
- Overrides:
readObjectInternal
in classAbstractUnitOfWork
-
getManagedOriginal
Gets managed original with the specified identifier ornull
if there is none matching.Descriptor is used to check repository context validity. Note that the
ReadOnlyUnitOfWork
does not distinguish between original and cloned objects.- Overrides:
getManagedOriginal
in classAbstractUnitOfWork
- Parameters:
cls
- Return type of the originalidentifier
- Instance identifierdescriptor
- Repository descriptor- Returns:
- Original object managed by this UoW or
null
if this UoW doesn't contain a matching instance
-
unregisterObject
Detaches the specified registered object from this Unit of Work.- Specified by:
unregisterObject
in interfaceUnitOfWork
- Overrides:
unregisterObject
in classAbstractUnitOfWork
- Parameters:
object
- Entity to detach
-
registerExistingObject
Register an existing object in this Unit of Work without cloning it.- Specified by:
registerExistingObject
in interfaceUnitOfWork
- Overrides:
registerExistingObject
in 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:
registerExistingObject
in interfaceUnitOfWork
- Overrides:
registerExistingObject
in classAbstractUnitOfWork
- Parameters:
entity
- ObjectregistrationDescriptor
- Configuration of the registration- Returns:
- Registered clone of the specified object.
-
getOriginal
Simply returns the specified entity.ReadOnlyUnitOfWork
does not distinguish between original and cloned objects.- Overrides:
getOriginal
in classAbstractUnitOfWork
- Parameters:
entity
- Object- Returns:
- the specified entity.
-
isObjectManaged
Return true if the given entity is managed.- Specified by:
isObjectManaged
in interfaceUnitOfWork
- Overrides:
isObjectManaged
in classAbstractUnitOfWork
- Parameters:
entity
- Object to check- Returns:
true
when the entity is managed,false
otherwise
-
getState
Gets the lifecycle state of the specified entity.ReadOnlyUnitOfWork
- Specified by:
getState
in interfaceUnitOfWork
- Overrides:
getState
in classAbstractUnitOfWork
- Parameters:
entity
- Entity whose state to resolve- Returns:
EntityState.MANAGED
if this Unit Of Work contains the specified entity,EntityState.NOT_MANAGED
otherwise
-
getState
Description copied from interface:UnitOfWork
Gets the lifecycle state of the specified entity with respect to a repository context indicated by the specified descriptor.- Specified by:
getState
in interfaceUnitOfWork
- Overrides:
getState
in 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
readObject
and has exactly the same behavior.- Specified by:
getReference
in interfaceUnitOfWork
- Overrides:
getReference
in classAbstractUnitOfWork
- Type Parameters:
T
- Entity type- Parameters:
cls
- The type of the returned objectidentifier
- Instance identifierdescriptor
- Entity descriptor- Returns:
- The retrieved object or
null
if there is no object with the specified identifier in the specified repository
-
getCloneForOriginal
Simply returns the specified original object.ReadOnlyUnitOfWork
does not distinguish between original and cloned objects.- Specified by:
getCloneForOriginal
in interfaceUnitOfWork
- Overrides:
getCloneForOriginal
in 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.ReadOnlyUnitOfWork
simply 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.ReadOnlyUnitOfWork
should not put objects into the cache.- Specified by:
putObjectIntoCache
in interfaceUnitOfWork
- Overrides:
putObjectIntoCache
in classAbstractUnitOfWork
- Parameters:
identifier
- Object identifierentity
- Object to cachedescriptor
- Descriptor of repository context
-
commitToStorage
public void commitToStorage() -
removeObjectFromCache
public void removeObjectFromCache(Object toRemove, URI context) throws UnsupportedOperationException Method not supported.- Specified by:
removeObjectFromCache
in interfaceUnitOfWork
- Overrides:
removeObjectFromCache
in classAbstractUnitOfWork
- Parameters:
toRemove
- Object to remove from cachecontext
- Entity context URI- Throws:
UnsupportedOperationException
- Method not supported.
-
isObjectNew
Method not supported.- Specified by:
isObjectNew
in interfaceUnitOfWork
- Overrides:
isObjectNew
in classAbstractUnitOfWork
- Parameters:
entity
- Object to check- Returns:
true
when entity is managed and new,false
otherwise- Throws:
UnsupportedOperationException
- Method not supported.- See Also:
-
mergeDetached
Method not supported.- Specified by:
mergeDetached
in interfaceUnitOfWork
- Overrides:
mergeDetached
in 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:
getInstanceForMerge
in classAbstractUnitOfWork
- Throws:
UnsupportedOperationException
- Method not supported.
-
evictAfterMerge
protected void evictAfterMerge(EntityType<?> et, URI identifier, Descriptor descriptor) throws UnsupportedOperationException Method not supported.- Overrides:
evictAfterMerge
in classAbstractUnitOfWork
- Throws:
UnsupportedOperationException
- Method not supported.
-
refreshObject
Method not supported.- Specified by:
refreshObject
in interfaceUnitOfWork
- Overrides:
refreshObject
in 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:
processInferredValueChanges
in classAbstractUnitOfWork
- Throws:
UnsupportedOperationException
- Always thrown
-
registerOriginalForNewClone
public void registerOriginalForNewClone(Object clone, Object original) throws UnsupportedOperationException Method is not supported.- Overrides:
registerOriginalForNewClone
in classAbstractUnitOfWork
- Parameters:
clone
- Already registered cloneoriginal
- Original to register- Throws:
UnsupportedOperationException
- Always thrown
-
writeUncommittedChanges
Method is not supported.- Specified by:
writeUncommittedChanges
in interfaceUnitOfWork
- Overrides:
writeUncommittedChanges
in classAbstractUnitOfWork
- Throws:
UnsupportedOperationException
- Always thrown
-
hasChanges
Method is not supported.- Overrides:
hasChanges
in classAbstractUnitOfWork
- Throws:
UnsupportedOperationException
- Always thrown
-
restoreRemovedObject
Method is not supported.- Specified by:
restoreRemovedObject
in interfaceUnitOfWork
- Overrides:
restoreRemovedObject
in classAbstractUnitOfWork
- Parameters:
entity
- The object to restore- Throws:
UnsupportedOperationException
- Always thrown
-
isFlushingChanges
Method is not supported.- Specified by:
isFlushingChanges
in interfaceUnitOfWork
- Overrides:
isFlushingChanges
in classAbstractUnitOfWork
- Returns:
true
if the UoW is flushing changes,false
otherwise- 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:
markCloneForDeletion
in classAbstractUnitOfWork
- Throws:
UnsupportedOperationException
- Always thrown
-
registerNewObject
public void registerNewObject(Object entity, Descriptor descriptor) throws UnsupportedOperationException Method is not supported.- Specified by:
registerNewObject
in interfaceUnitOfWork
- Overrides:
registerNewObject
in 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
-