KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > amber > AmberConnection


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free Software Foundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.amber;
30
31 import java.sql.ResultSet JavaDoc;
32 import java.sql.SQLException JavaDoc;
33 import java.util.List JavaDoc;
34
35 /**
36  * Main user interface to Amber.
37  */

38 public interface AmberConnection {
39   /**
40    * Loads the entity specified by its class and primary key.
41    */

42   public Object JavaDoc load(Class JavaDoc cl, Object JavaDoc key)
43     throws AmberException;
44   
45   /**
46    * Loads the entity specified by its class and primary key.
47    */

48   public Object JavaDoc load(Class JavaDoc cl, long key)
49     throws AmberException;
50   
51   /**
52    * Loads the entity, returning the active entity
53    */

54   public Object JavaDoc makePersistent(Object JavaDoc entity)
55     throws SQLException JavaDoc;
56
57   /**
58    * Creates a new entity given the values in the object.
59    */

60   public void create(Object JavaDoc obj)
61     throws SQLException JavaDoc;
62   
63   /**
64    * Returns true if the entitiy is managed.
65    */

66   public boolean contains(Object JavaDoc entity);
67
68   /**
69    * Deletes the specified entry.
70    */

71   public void delete(Object JavaDoc obj)
72     throws SQLException JavaDoc;
73
74   /**
75    * Queries the database, returning a result set
76    *
77    * @param query the query
78    *
79    * @return the query result set.
80    */

81   public ResultSet JavaDoc query(String JavaDoc query)
82     throws SQLException JavaDoc;
83
84   /**
85    * Queries the database, returning a result set
86    *
87    * @param query the query
88    *
89    * @return the query result set.
90    */

91   public int update(String JavaDoc query)
92     throws SQLException JavaDoc;
93   
94   /**
95    * Creates a query object from a query string.
96    *
97    * The query will load the default group values for any selected
98    * entitites.
99    *
100    * @param query a query
101    */

102   public AmberQuery prepareQuery(String JavaDoc queryString)
103     throws AmberException;
104
105   /**
106    * Starts a transaction.
107    */

108   public void beginTransaction()
109     throws SQLException JavaDoc;
110
111   /**
112    * Commits a transaction.
113    */

114   public void commit()
115     throws SQLException JavaDoc;
116
117   /**
118    * Rolls a transaction back.
119    */

120   public void rollback()
121     throws SQLException JavaDoc;
122   
123   /**
124    * Flushes data from the connection.
125    */

126   public void flush()
127     throws SQLException JavaDoc;
128   
129   /**
130    * Closes the connection. Unlike JDBC, this will never throw an
131    * exception (although it may log a warning.)
132    */

133   public void close();
134
135   /**
136    * Queries the database, returning a result set
137    *
138    * @param query the query
139    *
140    * @return the query result set.
141    */

142   public List JavaDoc find(String JavaDoc query)
143     throws SQLException JavaDoc;
144 }
145
Popular Tags