KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > pss > runtime > hibernate > lib > CatalogBase


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Alex Andrushchak.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.pss.runtime.hibernate.lib;
28
29
30 /**
31  * CatalogBase is a base class for Hibernate Catalog.
32  * It implements the org.objectweb.openccm.services.pss.api.Catalog interface.
33  *
34  * @author <a HREF="mailto:pretend@ukr.net">Alex Andrushchak</a>
35  *
36  * @version 0.1
37  */

38
39 public abstract class CatalogBase
40               extends org.objectweb.openccm.pss.runtime.common.lib.CatalogBase
41            implements org.objectweb.openccm.pss.runtime.hibernate.api.CatalogBase
42 {
43     // ==================================================================
44
//
45
// Internal state.
46
//
47
// ==================================================================
48

49     /**
50      * Hibernate session reference.
51      */

52     private net.sf.hibernate.Session _hibernate_session;
53
54     // ==================================================================
55
//
56
// Constructor.
57
//
58
// ==================================================================
59

60     /**
61      * The default constructor.
62      *
63      * @param id - The catalog id.
64      * @param pm - The associted Hibernate Session.
65      */

66     public CatalogBase(int id, net.sf.hibernate.Session session)
67     {
68         super(id);
69         _hibernate_session = session;
70     }
71
72     // ==================================================================
73
//
74
// Internal methods.
75
//
76
// ==================================================================
77

78     // ==================================================================
79
//
80
// Public methods.
81
//
82
// ==================================================================
83

84     // ==================================================================
85
//
86
// Methods for org.omg.CosPersistentState.Catalog
87
//
88
// ==================================================================
89

90     // ==================================================================
91
//
92
// Methods for org.objectweb.openccm.pss.runtime.common.api.CatalogBase
93
//
94
// ==================================================================
95

96     // ==================================================================
97
//
98
// Methods for org.objectweb.openccm.pss.runtime.hibernate.api.CatalogBase
99
//
100
// ==================================================================
101

102     /**
103      * Get the Hibernate Persistence Manager.
104      *
105      * @return The associated persistence manager.
106      */

107     public net.sf.hibernate.Session
108     get_hibernate_session()
109     {
110         return _hibernate_session;
111     }
112
113     /**
114      * Begin a transaction in the Hibernate session.
115      */

116     public void
117     begin_tx()
118     {
119         try {
120             get_hibernate_session().beginTransaction();
121         } catch (net.sf.hibernate.HibernateException ex) {
122             throw new RuntimeException JavaDoc(ex);
123         }
124     }
125
126     /**
127      * Commit a transaction in the Hibernate session.
128      */

129     public void
130     commit_tx()
131     {
132         try {
133             net.sf.hibernate.Transaction t = get_hibernate_session().beginTransaction();
134             t.commit();
135         } catch (net.sf.hibernate.HibernateException ex) {
136             throw new RuntimeException JavaDoc(ex);
137         }
138     }
139
140     /**
141      * Rollback a transaction in the Hibernate session
142      */

143     public void
144     rollback_tx()
145     {
146         try {
147             net.sf.hibernate.Transaction t = get_hibernate_session().beginTransaction();
148             t.rollback();
149         } catch (net.sf.hibernate.HibernateException ex) {
150             throw new RuntimeException JavaDoc(ex);
151         }
152     }
153 }
154
Popular Tags