KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > StatelessSession


1 //$Id: StatelessSession.java,v 1.6 2005/07/18 06:46:41 oneovthafew Exp $
2
package org.hibernate;
3
4 import java.io.Serializable JavaDoc;
5 import java.sql.Connection JavaDoc;
6
7 /**
8  * A command-oriented API for performing bulk operations
9  * against a database.<br>
10  * <br>
11  * A stateless session does not implement a first-level cache nor
12  * interact with any second-level cache, nor does it implement
13  * transactional write-behind or automatic dirty checking, nor do
14  * operations cascade to associated instances. Collections are
15  * ignored by a stateless session. Operations performed via a
16  * stateless session bypass Hibernate's event model and
17  * interceptors. Stateless sessions are vulnerable to data
18  * aliasing effects, due to the lack of a first-level cache.<br>
19  * <br>
20  * For certain kinds of transactions, a stateless session may
21  * perform slightly faster than a stateful session.
22  *
23  * @author Gavin King
24  */

25 public interface StatelessSession extends Serializable JavaDoc {
26     /**
27      * Close the stateless session and release the JDBC connection.
28      */

29     public void close();
30     /**
31      * Insert a row.
32      * @param entity a new transient instance
33      */

34     public Serializable JavaDoc insert(Object JavaDoc entity);
35     /**
36      * Update a row.
37      * @param entity a detached entity instance
38      */

39     public void update(Object JavaDoc entity);
40     /**
41      * Delete a row.
42      * @param entity a detached entity instance
43      */

44     public void delete(Object JavaDoc entity);
45     /**
46      * Insert a row.
47      * @param entity a new transient instance
48      * @return the identifier of the instance
49      */

50     public Serializable JavaDoc insert(String JavaDoc entityName, Object JavaDoc entity);
51     /**
52      * Update a row.
53      * @param entity a detached entity instance
54      */

55     public void update(String JavaDoc entityName, Object JavaDoc entity);
56     /**
57      * Delete a row.
58      * @param entity a detached entity instance
59      */

60     public void delete(String JavaDoc entityName, Object JavaDoc entity);
61     /**
62      * Retrieve a row.
63      * @return a detached entity instance
64      */

65     public Object JavaDoc get(String JavaDoc entityName, Serializable JavaDoc id);
66     /**
67      * Retrieve a row.
68      * @return a detached entity instance
69      */

70     public Object JavaDoc get(Class JavaDoc entityClass, Serializable JavaDoc id);
71     /**
72      * Retrieve a row, obtaining the specified lock mode.
73      * @return a detached entity instance
74      */

75     public Object JavaDoc get(String JavaDoc entityName, Serializable JavaDoc id, LockMode lockMode);
76     /**
77      * Retrieve a row, obtaining the specified lock mode.
78      * @return a detached entity instance
79      */

80     public Object JavaDoc get(Class JavaDoc entityClass, Serializable JavaDoc id, LockMode lockMode);
81     /**
82      * Create a new instance of <tt>Query</tt> for the given HQL query string.
83      * Entities returned by the query are detached.
84      */

85     public Query createQuery(String JavaDoc queryString);
86     /**
87      * Obtain an instance of <tt>Query</tt> for a named query string defined in
88      * the mapping file. Entities returned by the query are detached.
89      */

90     public Query getNamedQuery(String JavaDoc queryName);
91     /**
92      * Create a new <tt>Criteria</tt> instance, for the given entity class,
93      * or a superclass of an entity class. Entities returned by the query are
94      * detached.
95      *
96      * @param persistentClass a class, which is persistent, or has persistent subclasses
97      * @return Criteria
98      */

99     public Criteria createCriteria(Class JavaDoc persistentClass);
100     /**
101      * Create a new <tt>Criteria</tt> instance, for the given entity class,
102      * or a superclass of an entity class, with the given alias.
103      * Entities returned by the query are detached.
104      *
105      * @param persistentClass a class, which is persistent, or has persistent subclasses
106      * @return Criteria
107      */

108     public Criteria createCriteria(Class JavaDoc persistentClass, String JavaDoc alias);
109     /**
110      * Create a new <tt>Criteria</tt> instance, for the given entity name.
111      * Entities returned by the query are detached.
112      *
113      * @param entityName
114      * @return Criteria
115      */

116     public Criteria createCriteria(String JavaDoc entityName);
117     /**
118      * Create a new <tt>Criteria</tt> instance, for the given entity name,
119      * with the given alias. Entities returned by the query are detached.
120      *
121      * @param entityName
122      * @return Criteria
123      */

124     public Criteria createCriteria(String JavaDoc entityName, String JavaDoc alias);
125     /**
126      * Create a new instance of <tt>SQLQuery</tt> for the given SQL query string.
127      * Entities returned by the query are detached.
128      *
129      * @param queryString a SQL query
130      * @return SQLQuery
131      * @throws HibernateException
132      */

133     public SQLQuery createSQLQuery(String JavaDoc queryString) throws HibernateException;
134     /**
135      * Begin a Hibernate transaction.
136      */

137     public Transaction beginTransaction();
138     /**
139      * Returns the current JDBC connection associated with this
140      * instance.
141      */

142     public Connection JavaDoc connection();
143 }
144
Popular Tags