📄 hibernateoperations.java
字号:
* @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
* (throwing an OptimisticLockingFailureException if not found).
* @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 with the given identifier.
* @param entity the transient instance to persist
* @param id the identifier to assign
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#save(Object, java.io.Serializable)
*/
void save(Object entity, Serializable id) 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;
/**
* Persist the given transient instance with the given identifier.
* @param entityName the name of a persistent entity
* @param entity the transient instance to persist
* @param id the identifier to assign
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#save(Object, java.io.Serializable)
*/
void save(String entityName, Object entity, Serializable id) throws DataAccessException;
/**
* Update the given persistent instance,
* associating it with the current 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 Session.
* <p>Obtains the specified lock mode if the instance exists, implicitly
* checking whether the corresponding database entry still exists
* (throwing an OptimisticLockingFailureException if not found).
* @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 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 Session.
* <p>Obtains the specified lock mode if the instance exists, implicitly
* checking whether the corresponding database entry still exists
* (throwing an OptimisticLockingFailureException if not found).
* @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 Session.
* @param entity the persistent instance to save or update
* (to be associated with the Hibernate Session)
* @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 Session.
* @param entityName the name of a persistent entity
* @param entity the persistent instance to save or update
* (to be associated with the Hibernate Session)
* @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 Session.
* @param entities the persistent instances to save or update
* (to be associated with the Hibernate Session)
* @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 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 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 IdTransferringMergeEventListener if you'd 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 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 IdTransferringMergeEventListener if you'd 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
* (throwing an OptimisticLockingFailureException if not found).
* @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's 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 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 a query for persistent instances.
* @param queryString a query expressed in Hibernate's query language
* @return a List containing 0 or more persistent instances
* @throws org.springframework.dao.DataAccessException in case of Hibernate errors
* @see org.hibernate.Session#createQuery
*/
List find(String queryString) throws DataAccessException;
/**
* Execute a query for persistent instances, binding
* one value to a "?" parameter in the query string.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -