Subversion Repositories WebE

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
33 PointedEar 1
/*
2
 * Hibernate, Relational Persistence for Idiomatic Java
3
 *
4
 * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
5
 * indicated by the @author tags or express copyright attribution
6
 * statements applied by the authors.  All third-party contributions are
7
 * distributed under license by Red Hat Middleware LLC.
8
 *
9
 * This copyrighted material is made available to anyone wishing to use, modify,
10
 * copy, or redistribute it subject to the terms and conditions of the GNU
11
 * Lesser General Public License, as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
16
 * for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public License
19
 * along with this distribution; if not, write to:
20
 * Free Software Foundation, Inc.
21
 * 51 Franklin Street, Fifth Floor
22
 * Boston, MA  02110-1301  USA
23
 *
24
 */
25
package org.hibernate;
26
 
27
import java.io.Serializable;
28
import java.sql.Connection;
29
 
30
/**
31
 * A command-oriented API for performing bulk operations
32
 * against a database.<br>
33
 * <br>
34
 * A stateless session does not implement a first-level cache nor
35
 * interact with any second-level cache, nor does it implement
36
 * transactional write-behind or automatic dirty checking, nor do
37
 * operations cascade to associated instances. Collections are
38
 * ignored by a stateless session. Operations performed via a
39
 * stateless session bypass Hibernate's event model and
40
 * interceptors. Stateless sessions are vulnerable to data
41
 * aliasing effects, due to the lack of a first-level cache.<br>
42
 * <br>
43
 * For certain kinds of transactions, a stateless session may
44
 * perform slightly faster than a stateful session.
45
 *
46
 * @author Gavin King
47
 */
48
public interface StatelessSession extends Serializable {
49
        /**
50
         * Close the stateless session and release the JDBC connection.
51
         */
52
        public void close();
53
 
54
        /**
55
         * Insert a row.
56
         *
57
         * @param entity a new transient instance
58
         */
59
        public Serializable insert(Object entity);
60
 
61
        /**
62
         * Insert a row.
63
         *
64
         * @param entityName The entityName for the entity to be inserted
65
         * @param entity a new transient instance
66
         * @return the identifier of the instance
67
         */
68
        public Serializable insert(String entityName, Object entity);
69
 
70
        /**
71
         * Update a row.
72
         *
73
         * @param entity a detached entity instance
74
         */
75
        public void update(Object entity);
76
 
77
        /**
78
         * Update a row.
79
         *
80
         * @param entityName The entityName for the entity to be updated
81
         * @param entity a detached entity instance
82
         */
83
        public void update(String entityName, Object entity);
84
 
85
        /**
86
         * Delete a row.
87
         *
88
         * @param entity a detached entity instance
89
         */
90
        public void delete(Object entity);
91
 
92
        /**
93
         * Delete a row.
94
         *
95
         * @param entityName The entityName for the entity to be deleted
96
         * @param entity a detached entity instance
97
         */
98
        public void delete(String entityName, Object entity);
99
 
100
        /**
101
         * Retrieve a row.
102
         *
103
         * @return a detached entity instance
104
         */
105
        public Object get(String entityName, Serializable id);
106
 
107
        /**
108
         * Retrieve a row.
109
         *
110
         * @return a detached entity instance
111
         */
112
        public Object get(Class entityClass, Serializable id);
113
 
114
        /**
115
         * Retrieve a row, obtaining the specified lock mode.
116
         *
117
         * @return a detached entity instance
118
         */
119
        public Object get(String entityName, Serializable id, LockMode lockMode);
120
 
121
        /**
122
         * Retrieve a row, obtaining the specified lock mode.
123
         *
124
         * @return a detached entity instance
125
         */
126
        public Object get(Class entityClass, Serializable id, LockMode lockMode);
127
 
128
        /**
129
         * Refresh the entity instance state from the database.
130
         *
131
         * @param entity The entity to be refreshed.
132
         */
133
        public void refresh(Object entity);
134
 
135
        /**
136
         * Refresh the entity instance state from the database.
137
         *
138
         * @param entityName The entityName for the entity to be refreshed.
139
         * @param entity The entity to be refreshed.
140
         */
141
        public void refresh(String entityName, Object entity);
142
 
143
        /**
144
         * Refresh the entity instance state from the database.
145
         *
146
         * @param entity The entity to be refreshed.
147
         * @param lockMode The LockMode to be applied.
148
         */
149
        public void refresh(Object entity, LockMode lockMode);
150
 
151
        /**
152
         * Refresh the entity instance state from the database.
153
         *
154
         * @param entityName The entityName for the entity to be refreshed.
155
         * @param entity The entity to be refreshed.
156
         * @param lockMode The LockMode to be applied.
157
         */
158
        public void refresh(String entityName, Object entity, LockMode lockMode);
159
 
160
        /**
161
         * Create a new instance of <tt>Query</tt> for the given HQL query string.
162
         * Entities returned by the query are detached.
163
         */
164
        public Query createQuery(String queryString);
165
 
166
        /**
167
         * Obtain an instance of <tt>Query</tt> for a named query string defined in
168
         * the mapping file. Entities returned by the query are detached.
169
         */
170
        public Query getNamedQuery(String queryName);
171
 
172
        /**
173
         * Create a new <tt>Criteria</tt> instance, for the given entity class,
174
         * or a superclass of an entity class. Entities returned by the query are
175
         * detached.
176
         *
177
         * @param persistentClass a class, which is persistent, or has persistent subclasses
178
         * @return Criteria
179
         */
180
        public Criteria createCriteria(Class persistentClass);
181
 
182
        /**
183
         * Create a new <tt>Criteria</tt> instance, for the given entity class,
184
         * or a superclass of an entity class, with the given alias.
185
         * Entities returned by the query are detached.
186
         *
187
         * @param persistentClass a class, which is persistent, or has persistent subclasses
188
         * @return Criteria
189
         */
190
        public Criteria createCriteria(Class persistentClass, String alias);
191
 
192
        /**
193
         * Create a new <tt>Criteria</tt> instance, for the given entity name.
194
         * Entities returned by the query are detached.
195
         *
196
         * @param entityName
197
         * @return Criteria
198
         */
199
        public Criteria createCriteria(String entityName);
200
 
201
        /**
202
         * Create a new <tt>Criteria</tt> instance, for the given entity name,
203
         * with the given alias. Entities returned by the query are detached.
204
         *
205
         * @param entityName
206
         * @return Criteria
207
         */
208
        public Criteria createCriteria(String entityName, String alias);
209
 
210
        /**
211
         * Create a new instance of <tt>SQLQuery</tt> for the given SQL query string.
212
         * Entities returned by the query are detached.
213
         *
214
         * @param queryString a SQL query
215
         * @return SQLQuery
216
         * @throws HibernateException
217
         */
218
        public SQLQuery createSQLQuery(String queryString) throws HibernateException;
219
 
220
        /**
221
         * Begin a Hibernate transaction.
222
         */
223
        public Transaction beginTransaction();
224
 
225
        /**
226
         * Get the current Hibernate transaction.
227
         */
228
        public Transaction getTransaction();
229
 
230
        /**
231
         * Returns the current JDBC connection associated with this
232
         * instance.<br>
233
         * <br>
234
         * If the session is using aggressive connection release (as in a
235
         * CMT environment), it is the application's responsibility to
236
         * close the connection returned by this call. Otherwise, the
237
         * application should not close the connection.
238
         */
239
        public Connection connection();
240
}