KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > classic > Session


1 //$Id: Session.java,v 1.6 2005/02/12 07:19:10 steveebersole Exp $
2
package org.hibernate.classic;
3
4 import java.io.Serializable JavaDoc;
5 import java.util.Collection JavaDoc;
6 import java.util.Iterator JavaDoc;
7 import java.util.List JavaDoc;
8
9 import org.hibernate.HibernateException;
10 import org.hibernate.Query;
11 import org.hibernate.type.Type;
12
13 /**
14  * An extension of the <tt>Session</tt> API, including all
15  * deprecated methods from Hibernate2. This interface is
16  * provided to allow easier migration of existing applications.
17  * New code should use <tt>org.hibernate.Session</tt>.
18  * @author Gavin King
19  */

20 public interface Session extends org.hibernate.Session {
21
22     /**
23      * Copy the state of the given object onto the persistent object with the same
24      * identifier. If there is no persistent instance currently associated with
25      * the session, it will be loaded. Return the persistent instance. If the
26      * given instance is unsaved or does not exist in the database, save it and
27      * return it as a newly persistent instance. Otherwise, the given instance
28      * does not become associated with the session.
29      * @deprecated use org.hibernate.Session#merge(Object)
30      *
31      * @param object a transient instance with state to be copied
32      * @return an updated persistent instance
33      */

34     public Object JavaDoc saveOrUpdateCopy(Object JavaDoc object) throws HibernateException;
35
36     /**
37      * Copy the state of the given object onto the persistent object with the
38      * given identifier. If there is no persistent instance currently associated
39      * with the session, it will be loaded. Return the persistent instance. If
40      * there is no database row with the given identifier, save the given instance
41      * and return it as a newly persistent instance. Otherwise, the given instance
42      * does not become associated with the session.
43      * @deprecated use org.hibernate.Session#merge(Object, java.io.Serializable)
44      *
45      * @param object a persistent or transient instance with state to be copied
46      * @param id the identifier of the instance to copy to
47      * @return an updated persistent instance
48      */

49     public Object JavaDoc saveOrUpdateCopy(Object JavaDoc object, Serializable JavaDoc id) throws HibernateException;
50
51     /**
52      * Copy the state of the given object onto the persistent object with the same
53      * identifier. If there is no persistent instance currently associated with
54      * the session, it will be loaded. Return the persistent instance. If the
55      * given instance is unsaved or does not exist in the database, save it and
56      * return it as a newly persistent instance. Otherwise, the given instance
57      * does not become associated with the session.
58      * @deprecated use org.hibernate.Session#merge(String, Object)
59      *
60      * @param object a transient instance with state to be copied
61      * @return an updated persistent instance
62      */

63     public Object JavaDoc saveOrUpdateCopy(String JavaDoc entityName, Object JavaDoc object) throws HibernateException;
64
65     /**
66      * Copy the state of the given object onto the persistent object with the
67      * given identifier. If there is no persistent instance currently associated
68      * with the session, it will be loaded. Return the persistent instance. If
69      * there is no database row with the given identifier, save the given instance
70      * and return it as a newly persistent instance. Otherwise, the given instance
71      * does not become associated with the session.
72      * @deprecated use org.hibernate.Session#merge(String, Object, java.io.Serializable)
73      *
74      * @param object a persistent or transient instance with state to be copied
75      * @param id the identifier of the instance to copy to
76      * @return an updated persistent instance
77      */

78     public Object JavaDoc saveOrUpdateCopy(String JavaDoc entityName, Object JavaDoc object, Serializable JavaDoc id) throws HibernateException;
79
80     /**
81      * Execute a query.
82      * @deprecated use <tt>createQuery()</tt>
83      *
84      * @param query a query expressed in Hibernate's query language
85      * @return a distinct list of instances (or arrays of instances)
86      * @throws HibernateException
87      */

88     public List JavaDoc find(String JavaDoc query) throws HibernateException;
89             
90     /**
91      * Execute a query with bind parameters.
92      * @deprecated use <tt>createQuery()</tt>
93      *
94      * Bind a value to a "?" parameter in the query string.
95      *
96      * @param query the query string
97      * @param value a value to be bound to a "?" placeholder (JDBC IN parameter).
98      * @param type the Hibernate type of the value
99      * @see org.hibernate.Hibernate for access to <tt>Type</tt> instances
100      * @return a distinct list of instances (or arrays of instances)
101      * @throws HibernateException
102      */

103     public List JavaDoc find(String JavaDoc query, Object JavaDoc value, Type type) throws HibernateException;
104     
105     /**
106      * Execute a query with bind parameters.
107      * @deprecated use <tt>createQuery()</tt>
108      *
109      * Binding an array of values to "?" parameters in the query string.
110      *
111      * @param query the query string
112      * @param values an array of values to be bound to the "?" placeholders (JDBC IN parameters).
113      * @param types an array of Hibernate types of the values
114      * @see org.hibernate.Hibernate for access to <tt>Type</tt> instances
115      * @return a distinct list of instances
116      * @throws HibernateException
117      */

118     public List JavaDoc find(String JavaDoc query, Object JavaDoc[] values, Type[] types) throws HibernateException;
119     
120     /**
121      * Execute a query and return the results in an iterator. If the query has multiple
122      * return values, values will be returned in an array of type <tt>Object[].</tt><br>
123      * <br>
124      * Entities returned as results are initialized on demand. The first SQL query returns
125      * identifiers only. So <tt>iterate()</tt> is usually a less efficient way to retrieve
126      * objects than <tt>find()</tt>.
127      *
128      * @deprecated use <tt>createQuery()</tt>
129      *
130      * @param query the query string
131      * @return an iterator
132      * @throws HibernateException
133      */

134     public Iterator JavaDoc iterate(String JavaDoc query) throws HibernateException;
135     
136     /**
137      * Execute a query and return the results in an iterator. Write the given value to "?"
138      * in the query string. If the query has multiple return values, values will be returned
139      * in an array of type <tt>Object[]</tt>.<br>
140      * <br>
141      * Entities returned as results are initialized on demand. The first SQL query returns
142      * identifiers only. So <tt>iterate()</tt> is usually a less efficient way to retrieve
143      * objects than <tt>find()</tt>.
144      *
145      * @deprecated use <tt>createQuery()</tt>
146      *
147      * @param query the query string
148      * @param value a value to be witten to a "?" placeholder in the query string
149      * @param type the hibernate type of value
150      * @return an iterator
151      * @throws HibernateException
152      */

153     public Iterator JavaDoc iterate(String JavaDoc query, Object JavaDoc value, Type type) throws HibernateException;
154     
155     /**
156      * Execute a query and return the results in an iterator. Write the given values to "?"
157      * in the query string. If the query has multiple return values, values will be returned
158      * in an array of type <tt>Object[]</tt>.<br>
159      * <br>
160      * Entities returned as results are initialized on demand. The first SQL query returns
161      * identifiers only. So <tt>iterate()</tt> is usually a less efficient way to retrieve
162      * objects than <tt>find()</tt>.
163      *
164      * @deprecated use <tt>createQuery()</tt>
165      *
166      * @param query the query string
167      * @param values a list of values to be written to "?" placeholders in the query
168      * @param types a list of Hibernate types of the values
169      * @return an iterator
170      * @throws HibernateException
171      */

172     public Iterator JavaDoc iterate(String JavaDoc query, Object JavaDoc[] values, Type[] types) throws HibernateException;
173     
174     /**
175      * Apply a filter to a persistent collection. A filter is a Hibernate query that may refer to
176      * <tt>this</tt>, the collection element. Filters allow efficient access to very large lazy
177      * collections. (Executing the filter does not initialize the collection.)
178      *
179      * @deprecated use <tt>createQuery()</tt>
180      *
181      * @param collection a persistent collection to filter
182      * @param filter a filter query string
183      * @return Collection the resulting collection
184      * @throws HibernateException
185      */

186     public Collection JavaDoc filter(Object JavaDoc collection, String JavaDoc filter) throws HibernateException;
187     
188     /**
189      * Apply a filter to a persistent collection. A filter is a Hibernate query that may refer to
190      * <tt>this</tt>, the collection element.
191      *
192      * @deprecated use <tt>createQuery()</tt>
193      *
194      * @param collection a persistent collection to filter
195      * @param filter a filter query string
196      * @param value a value to be witten to a "?" placeholder in the query string
197      * @param type the hibernate type of value
198      * @return Collection
199      * @throws HibernateException
200      */

201     public Collection JavaDoc filter(Object JavaDoc collection, String JavaDoc filter, Object JavaDoc value, Type type) throws HibernateException;
202     
203     /**
204      * Apply a filter to a persistent collection.
205      *
206      * Bind the given parameters to "?" placeholders. A filter is a Hibernate query that
207      * may refer to <tt>this</tt>, the collection element.
208      *
209      * @deprecated use <tt>createQuery()</tt>
210      *
211      * @param collection a persistent collection to filter
212      * @param filter a filter query string
213      * @param values a list of values to be written to "?" placeholders in the query
214      * @param types a list of Hibernate types of the values
215      * @return Collection
216      * @throws HibernateException
217      */

218     public Collection JavaDoc filter(Object JavaDoc collection, String JavaDoc filter, Object JavaDoc[] values, Type[] types) throws HibernateException;
219     
220     /**
221      * Delete all objects returned by the query. Return the number of objects deleted.
222      *
223      * @deprecated use <tt>createQuery()</tt>
224      *
225      * @param query the query string
226      * @return the number of instances deleted
227      * @throws HibernateException
228      */

229     public int delete(String JavaDoc query) throws HibernateException;
230     
231     /**
232      * Delete all objects returned by the query. Return the number of objects deleted.
233      *
234      * @deprecated use <tt>createQuery()</tt>
235      *
236      * @param query the query string
237      * @param value a value to be witten to a "?" placeholder in the query string.
238      * @param type the hibernate type of value.
239      * @return the number of instances deleted
240      * @throws HibernateException
241      */

242     public int delete(String JavaDoc query, Object JavaDoc value, Type type) throws HibernateException;
243     
244     /**
245      * Delete all objects returned by the query. Return the number of objects deleted.
246      *
247      * @deprecated use <tt>createQuery()</tt>
248      *
249      * @param query the query string
250      * @param values a list of values to be written to "?" placeholders in the query.
251      * @param types a list of Hibernate types of the values
252      * @return the number of instances deleted
253      * @throws HibernateException
254      */

255     public int delete(String JavaDoc query, Object JavaDoc[] values, Type[] types) throws HibernateException;
256
257
258     /**
259      * Create a new instance of <tt>Query</tt> for the given SQL string.
260      * @deprecated will be replaced with a more Query like interface in later release
261      *
262      * @param sql a query expressed in SQL
263      * @param returnAlias a table alias that appears inside <tt>{}</tt> in the SQL string
264      * @param returnClass the returned persistent class
265      */

266     public Query createSQLQuery(String JavaDoc sql, String JavaDoc returnAlias, Class JavaDoc returnClass);
267     
268     /**
269      * Create a new instance of <tt>Query</tt> for the given SQL string.
270      * @deprecated will be replaced with a more Query like interface in later release
271      *
272      * @param sql a query expressed in SQL
273      * @param returnAliases an array of table aliases that appear inside <tt>{}</tt> in the SQL string
274      * @param returnClasses the returned persistent classes
275      */

276     public Query createSQLQuery(String JavaDoc sql, String JavaDoc[] returnAliases, Class JavaDoc[] returnClasses);
277     
278     
279 }
280
Popular Tags