hibernate学习入门3
2015-10-13 18:52
633 查看
Session 接口方法
Session接口提供多个方法,但这里列出的只有少数重要的方法,这些方法我们在本教程中会使用。您可以查看Hibernate文档Session和SessionFactory相关方法的完整列表。S.N. | 会话的方法和说明 |
1 | Transaction beginTransaction() Begin a unit of work and return the associated Transaction object. |
2 | void cancelQuery() Cancel the execution of the current query. |
3 | void clear() Completely clear the session. |
4 | Connection close() End the session by releasing the JDBC connection and cleaning up. |
5 | Criteria createCriteria(Class persistentClass) Create a new Criteria instance, for the given entity class, or a superclass of an entity class. |
6 | Criteria createCriteria(String entityName) Create a new Criteria instance, for the given entity name. |
7 | Serializable getIdentifier(Object object) Return the identifier value of the given entity as associated with this session. |
8 | Query createFilter(Object collection, String queryString) Create a new instance of Query for the given collection and filter string. |
9 | Query createQuery(String queryString) Create a new instance of Query for the given HQL query string. |
10 | SQLQuery createSQLQuery(String queryString) Create a new instance of SQLQuery for the given SQL query string. |
11 | void delete(Object object) Remove a persistent instance from the datastore. |
12 | void delete(String entityName, Object object) Remove a persistent instance from the datastore. |
13 | Session get(String entityName, Serializable id) Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance. |
14 | SessionFactory getSessionFactory() Get the session factory which created this session. |
15 | void refresh(Object object) Re-read the state of the given instance from the underlying database. |
16 | Transaction getTransaction() Get the Transaction instance associated with this session. |
17 | boolean isConnected() Check if the session is currently connected. |
18 | boolean isDirty() Does this session contain any changes which must be synchronized with the database? |
19 | boolean isOpen() Check if the session is still open. |
20 | Serializable save(Object object) Persist the given transient instance, first assigning a generated identifier. |
21 | void saveOrUpdate(Object object) Either save(Object) or update(Object) the given instance. |
22 | void update(Object object) Update the persistent instance with the identifier of the given detached instance. |
23 | void update(String entityName, Object object) Update the persistent instance with the identifier of the given detached instance. |
相关文章推荐
- java对世界各个时区(TimeZone)的通用转换处理方法(转载)
- java-注解annotation
- java-模拟tomcat服务器
- java-用HttpURLConnection发送Http请求.
- java-WEB中的监听器Lisener
- Android IPC进程间通讯机制
- Android之获取手机上的图片和视频缩略图thumbnails
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- 介绍一款信息管理系统的开源框架---jeecg
- 聚类算法之kmeans算法java版本
- java实现 PageRank算法
- PropertyChangeListener简单理解
- 插入排序
- 冒泡排序
- 堆排序