KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > connection > JRHibernateConnection


1 /*
2  * Copyright (C) 2005 - 2006 JasperSoft Corporation. All rights reserved.
3  * http://www.jaspersoft.com.
4  *
5  * Unless you have purchased a commercial license agreement from JasperSoft,
6  * the following license terms apply:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as published by
10  * the Free Software Foundation.
11  *
12  * This program is distributed WITHOUT ANY WARRANTY; and without the
13  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
18  * or write to:
19  *
20  * Free Software Foundation, Inc.,
21  * 59 Temple Place - Suite 330,
22  * Boston, MA USA 02111-1307
23  *
24  *
25  *
26  *
27  * JRHibernateConnection.java
28  *
29  * Created on 4 giugno 2003, 18.15
30  *
31  */

32
33 package it.businesslogic.ireport.connection;
34 import org.hibernate.SessionFactory;
35 import org.hibernate.cfg.Configuration;
36 import org.hibernate.classic.Session;
37 /**
38  *
39  * @author Administrator
40  */

41 public class JRHibernateConnection extends it.businesslogic.ireport.IReportConnection {
42     
43     private String JavaDoc name;
44     
45     /** Creates a new instance of JRHibernateConnection */
46     public JRHibernateConnection() {
47     }
48     
49     /** This method return an instanced connection to the database.
50      * If isJDBCConnection() return false => getConnection() return null
51      *
52      */

53     public java.sql.Connection JavaDoc getConnection() {
54             return null;
55     }
56     
57     public boolean isJDBCConnection() {
58         return false;
59     }
60     
61     public boolean isJRDataSource() {
62         return false;
63     }
64     
65     /*
66      * This method return all properties used by this connection
67      */

68     public java.util.HashMap JavaDoc getProperties()
69     {
70         java.util.HashMap JavaDoc map = new java.util.HashMap JavaDoc();
71         return map;
72     }
73     
74     public void loadProperties(java.util.HashMap JavaDoc map)
75     {
76     }
77     
78     public String JavaDoc getDescription(){ return "Hibernate connection"; }
79     
80     
81     /**
82      * Getter for property name.
83      * @return Value of property name.
84      */

85     public java.lang.String JavaDoc getName() {
86         return name;
87     }
88     
89     /**
90      * Setter for property name.
91      * @param name New value of property name.
92      */

93     public void setName(java.lang.String JavaDoc name) {
94         this.name = name;
95     }
96     
97     /**
98      * This method return an instanced JRDataDource to the database.
99      * If isJDBCConnection() return true => getJRDataSource() return false
100      */

101     public net.sf.jasperreports.engine.JRDataSource getJRDataSource() {
102         return null;
103     }
104     
105     public Session createSession() throws org.hibernate.HibernateException
106     {
107          return getSessionFactory().openSession();
108     }
109
110     public SessionFactory getSessionFactory() throws org.hibernate.HibernateException {
111         
112           return new Configuration ().configure().buildSessionFactory();
113     }
114     
115 }
116
117
Popular Tags