Java Reference
In-Depth Information
Hibernate comes remarkably close to this, at least when compared with the alternatives—
but alas, there are configuration files to create and subtle performance issues to consider.
Hibernate does, however, achieve its fundamental aim—it allows you to store POJOs in the
database. Figure 1-1 shows how Hibernate fits into your application between the client code
and the database.
Figure 1-1. The role of Hibernate in a Java application
The common term for the direct persistence of traditional Java objects is object-relational
mapping —that is, mapping the objects in Java to the relational entities in a database.
Where entity beans have to follow a myriad of awkward naming conventions, POJOs
can be any Java object at all. Hibernate allows you to persist POJOs with very few constraints.
Listing 1-2 is an example of a simple POJO to represent a message.
Listing 1-2. The POJO Used in this Chapter's Examples
public class Message {
private Message() {
}
public Message(String messageText) {
this.messageText = messageText;
}
public String getMessageText() {
return messageText;
}
Search WWH ::




Custom Search