📄 hibernateoperations.java
字号:
* Remove the given object from the {@link org.hibernate.Session} cache.
* @param entity the persistent instance to evict
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#evict
*/
void evict(Object entity) throws DataAccessException;
/**
* Force initialization of a Hibernate proxy or persistent collection.
* @param proxy a proxy for a persistent object or a persistent collection
* @throws DataAccessException if we can't initialize the proxy, for example
* because it is not associated with an active Session
* @see org.hibernate.Hibernate#initialize
*/
void initialize(Object proxy) throws DataAccessException;
/**
* Return an enabled Hibernate {@link Filter} for the given filter name.
* The returned <code>Filter</code> instance can be used to set filter parameters.
* @param filterName the name of the filter
* @return the enabled Hibernate <code>Filter</code> (either already
* enabled or enabled on the fly by this operation)
* @throws IllegalStateException if we are not running within a
* transactional Session (in which case this operation does not make sense)
*/
Filter enableFilter(String filterName) throws IllegalStateException;
//-------------------------------------------------------------------------
// Convenience methods for storing individual objects
//-------------------------------------------------------------------------
/**
* Obtain the specified lock level upon the given object, implicitly
* checking whether the corresponding database entry still exists.
* @param entity the persistent instance to lock
* @param lockMode the lock mode to obtain
* @throws org.springframework.orm.ObjectOptimisticLockingFailureException if not found
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#lock(Object, org.hibernate.LockMode)
*/
void lock(Object entity, LockMode lockMode) throws DataAccessException;
/**
* Obtain the specified lock level upon the given object, implicitly
* checking whether the corresponding database entry still exists.
* @param entityName the name of a persistent entity
* @param entity the persistent instance to lock
* @param lockMode the lock mode to obtain
* @throws org.springframework.orm.ObjectOptimisticLockingFailureException if not found
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#lock(String, Object, org.hibernate.LockMode)
*/
void lock(String entityName, Object entity, LockMode lockMode) throws DataAccessException;
/**
* Persist the given transient instance.
* @param entity the transient instance to persist
* @return the generated identifier
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#save(Object)
*/
Serializable save(Object entity) throws DataAccessException;
/**
* Persist the given transient instance.
* @param entityName the name of a persistent entity
* @param entity the transient instance to persist
* @return the generated identifier
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#save(String, Object)
*/
Serializable save(String entityName, Object entity) throws DataAccessException;
/**
* Update the given persistent instance,
* associating it with the current Hibernate {@link org.hibernate.Session}.
* @param entity the persistent instance to update
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#update(Object)
*/
void update(Object entity) throws DataAccessException;
/**
* Update the given persistent instance,
* associating it with the current Hibernate {@link org.hibernate.Session}.
* <p>Obtains the specified lock mode if the instance exists, implicitly
* checking whether the corresponding database entry still exists.
* @param entity the persistent instance to update
* @param lockMode the lock mode to obtain
* @throws org.springframework.orm.ObjectOptimisticLockingFailureException if not found
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#update(Object)
*/
void update(Object entity, LockMode lockMode) throws DataAccessException;
/**
* Update the given persistent instance,
* associating it with the current Hibernate {@link org.hibernate.Session}.
* @param entityName the name of a persistent entity
* @param entity the persistent instance to update
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#update(String, Object)
*/
void update(String entityName, Object entity) throws DataAccessException;
/**
* Update the given persistent instance,
* associating it with the current Hibernate {@link org.hibernate.Session}.
* <p>Obtains the specified lock mode if the instance exists, implicitly
* checking whether the corresponding database entry still exists.
* @param entityName the name of a persistent entity
* @param entity the persistent instance to update
* @param lockMode the lock mode to obtain
* @throws org.springframework.orm.ObjectOptimisticLockingFailureException if not found
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#update(String, Object)
*/
void update(String entityName, Object entity, LockMode lockMode) throws DataAccessException;
/**
* Save or update the given persistent instance,
* according to its id (matching the configured "unsaved-value"?).
* Associates the instance with the current Hibernate {@link org.hibernate.Session}.
* @param entity the persistent instance to save or update
* (to be associated with the Hibernate <code>Session</code>)
* @throws DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#saveOrUpdate(Object)
*/
void saveOrUpdate(Object entity) throws DataAccessException;
/**
* Save or update the given persistent instance,
* according to its id (matching the configured "unsaved-value"?).
* Associates the instance with the current Hibernate <code>Session</code>.
* @param entityName the name of a persistent entity
* @param entity the persistent instance to save or update
* (to be associated with the Hibernate <code>Session</code>)
* @throws DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#saveOrUpdate(String, Object)
*/
void saveOrUpdate(String entityName, Object entity) throws DataAccessException;
/**
* Save or update all given persistent instances,
* according to its id (matching the configured "unsaved-value"?).
* Associates the instances with the current Hibernate <code>Session</code>.
* @param entities the persistent instances to save or update
* (to be associated with the Hibernate <code>Session</code>)
* @throws DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#saveOrUpdate(Object)
*/
void saveOrUpdateAll(Collection entities) throws DataAccessException;
/**
* Persist the state of the given detached instance according to the
* given replication mode, reusing the current identifier value.
* @param entity the persistent object to replicate
* @throws DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#replicate(Object, org.hibernate.ReplicationMode)
*/
void replicate(Object entity, ReplicationMode replicationMode) throws DataAccessException;
/**
* Persist the state of the given detached instance according to the
* given replication mode, reusing the current identifier value.
* @param entityName the name of a persistent entity
* @param entity the persistent object to replicate
* @throws DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#replicate(String, Object, org.hibernate.ReplicationMode)
*/
void replicate(String entityName, Object entity, ReplicationMode replicationMode) throws DataAccessException;
/**
* Persist the given transient instance. Follows JSR-220 semantics.
* <p>Similar to <code>save</code>, associating the given object
* with the current Hibernate {@link org.hibernate.Session}.
* @param entity the persistent instance to persist
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#persist(Object)
* @see #save
*/
void persist(Object entity) throws DataAccessException;
/**
* Persist the given transient instance. Follows JSR-220 semantics.
* <p>Similar to <code>save</code>, associating the given object
* with the current Hibernate {@link org.hibernate.Session}.
* @param entityName the name of a persistent entity
* @param entity the persistent instance to persist
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#persist(String, Object)
* @see #save
*/
void persist(String entityName, Object entity) throws DataAccessException;
/**
* Copy the state of the given object onto the persistent object
* with the same identifier. Follows JSR-220 semantics.
* <p>Similar to <code>saveOrUpdate</code>, but never associates the given
* object with the current Hibernate Session. In case of a new entity,
* the state will be copied over as well.
* <p>Note that <code>merge</code> will <i>not</i> update the identifiers
* in the passed-in object graph (in contrast to TopLink)! Consider
* registering Spring's <code>IdTransferringMergeEventListener</code> if
* you would like to have newly assigned ids transferred to the original
* object graph too.
* @param entity the object to merge with the corresponding persistence instance
* @return the updated, registered persistent instance
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#merge(Object)
* @see #saveOrUpdate
* @see org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener
*/
Object merge(Object entity) throws DataAccessException;
/**
* Copy the state of the given object onto the persistent object
* with the same identifier. Follows JSR-220 semantics.
* <p>Similar to <code>saveOrUpdate</code>, but never associates the given
* object with the current Hibernate {@link org.hibernate.Session}. In
* the case of a new entity, the state will be copied over as well.
* <p>Note that <code>merge</code> will <i>not</i> update the identifiers
* in the passed-in object graph (in contrast to TopLink)! Consider
* registering Spring's <code>IdTransferringMergeEventListener</code>
* if you would like to have newly assigned ids transferred to the
* original object graph too.
* @param entityName the name of a persistent entity
* @param entity the object to merge with the corresponding persistence instance
* @return the updated, registered persistent instance
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#merge(String, Object)
* @see #saveOrUpdate
*/
Object merge(String entityName, Object entity) throws DataAccessException;
/**
* Delete the given persistent instance.
* @param entity the persistent instance to delete
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#delete(Object)
*/
void delete(Object entity) throws DataAccessException;
/**
* Delete the given persistent instance.
* <p>Obtains the specified lock mode if the instance exists, implicitly
* checking whether the corresponding database entry still exists.
* @param entity the persistent instance to delete
* @param lockMode the lock mode to obtain
* @throws org.springframework.orm.ObjectOptimisticLockingFailureException if not found
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#delete(Object)
*/
void delete(Object entity, LockMode lockMode) throws DataAccessException;
/**
* Delete all given persistent instances.
* <p>This can be combined with any of the find methods to delete by query
* in two lines of code.
* @param entities the persistent instances to delete
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#delete(Object)
*/
void deleteAll(Collection entities) throws DataAccessException;
/**
* Flush all pending saves, updates and deletes to the database.
* <p>Only invoke this for selective eager flushing, for example when
* JDBC code needs to see certain changes within the same transaction.
* Else, it is preferable to rely on auto-flushing at transaction
* completion.
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#flush
*/
void flush() throws DataAccessException;
/**
* Remove all objects from the {@link org.hibernate.Session} cache, and
* cancel all pending saves, updates and deletes.
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#clear
*/
void clear() throws DataAccessException;
//-------------------------------------------------------------------------
// Convenience finder methods for HQL strings
//-------------------------------------------------------------------------
/**
* Execute an HQL query.
* @param queryString a query expressed in Hibernate's query language
* @return a {@link List} containing the results of the query execution
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -