|
Integrating JSF, Spring and Hibernate |
|
public String getUserEmail() {
return this.userEmail;
}
public void setUserEmail(String userEmail)
{
this.userEmail = userEmail;
}
public String getUserAddress() {
return this.userAddress;
}
public void setUserAddress(String
userAddress) {
this.userAddress = userAddress;
}
}
Since we are using Hibernate for persistence,
the User business object provides getter and
setter methods for all fields.
Business Services
Business Services contains the code to interact
with the data tier. In this application we have
developed a formal service layer, client can use
these services interface. There is only one
service in this application the ServiceFinder.
The ServiceFinder service is used to get the
Spring managed beans from
WebApplicationContext.
In the next section we will learn about
Integration tier of our application. Integration
tier is also known as data access tier.
8. Implementing Data Access Layer with
Hibernate
In this application we are using Hibernate to
implement data access layer. Hibernate is an
open source O/R mapping framework that
handles all the persistence logic.
Hibernate supports all major database available
in the market. The Hibernate Query Language
is an object-oriented extension to SQL, which
can be extensively used to save and retrieve.
|
|
the data in the form of Java objects from
database. Hibernate also supports association,
inheritance, polymorphism, composition and also
the Java Collection framework.
Data Access Object (DAO)
In this application we have used the DAO
pattern. The DAO pattern abstracts and
encapsulates all access to the data source. Our
application has one DAO interface:
HibernateSpringDAO. The implementation
classes of it is HibernateSpringDAOImpl that
contains Hibernate-specific logic to manage and
persist data.
Here is the code of
HibernateSpringDAO.java file:
import
org.springframework.dao.DataAccessException;
import net.roseindia.dao.hibernate.*;
public interface HibernateSpringDAO {
/**
* Retrieve all <code>true</code>/
<code>false</code> from the datastore.
* @return a <code>true</code> or
<code>fasel</code>.
*/
public User checkUser(String strUserName)
throws
DataAccessException,java.sql.SQLException;
/**
* Retrieve all <code>true</code>/
<code>false</code> from the datastore.
* @return a <code>true</code> or
<code>fasel</code>.
*/
public User validateUser(String
strUserName,String password) throws
DataAccessException,java.sql.SQLException;
/**
* Saves User object to the datastore.
*
*/
public void
addUser(net.roseindia.dao.hibernate.User
obj) throws DataAccessException;
}
|
|
|
Jan 2008 | Java Jazz Up | 69 |
|
|
View All Topics |
All Pages of this Issue |
Pages:
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53 ,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63 ,
64,
65 ,
66 ,
67 ,
68 ,
69 ,
70 ,
71 ,
72 ,
73 ,
74 ,
75 ,
76 ,
77 ,
78 ,
79 ,
80 ,
81 ,
82 ,
83,
84 ,
85 ,
86,
87 ,
88,
89 ,
90 ,
91 ,
92 ,
93 ,
94 ,
95 ,
96 ,
97 ,
98 ,
99 ,
100 ,
101 ,
102 ,
103,
104 ,
105 ,
106,
107,
Download PDF |
|
|
|
|
|
|
|
|