Working with both Object-Oriented software and Relational Databases can be cumbersome(缓慢复杂的) and time consuming. Development costs are significantly(值得注目地) higher due to a paradigm(范例) mismatch between how data is represented in objects versus(与……相对) relational databases. Hibernate is an Object/Relational Mapping solution for Java environments. The term Object/Relational Mapping refers to the technique of mapping data from an object model representation to a relational data model representation (and visa versa( 反之亦然)). See http://en.wikipedia.org/wiki/Object-relational_mapping for a good high-level discussion.
Note
While having a strong background in SQL is not required to use Hibernate, having a basic understanding of the concepts can greatly help you understand Hibernate more fully and quickly. Probably the single best background is an understanding of data modeling principles(原则). You might want to consider these resources as a good starting point:
Hibernate not only takes care of the mapping from Java classes to database tables (and from Java data types to SQL data types), but also provides data query and retrieval(检索) facilities(工具). It can significantly reduce development time otherwise(否则) spent with manual data handling in SQL and JDBC. Hibernate’s design goal is to relieve(解除) the developer from 95% of common data persistence-related programming tasks by eliminating(消除) the need for manual, hand-crafted(手工制作的) data processing using SQL and JDBC. However, unlike many other persistence solutions, Hibernate does not hide the power of SQL from you and guarantees(保证) that your investment(投资) in relational technology and knowledge is as valid(有效的) as always.
Hibernate may not be the best solution for data-centric(中心的) applications that only use stored-procedures to implement the business logic in the database, it is most useful with object-oriented domain models and business logic in the Java-based middle-tier(中间层). However, Hibernate can certainly help you to remove or encapsulate(封装) vendor(卖主)-specific SQL code and will help with the common task of result set translation from a tabular(平坦的) representation to a graph of objects.
If you are new to Hibernate and Object/Relational Mapping or even Java, please follow these steps:
-
Read Chapter 1, Tutorial for a tutorial with step-by-step instructions. The source code for the tutorial is included in the distribution in the
doc/reference/tutorial/
directory. -
Read Chapter 2, Architecture to understand the environments where Hibernate can be used.
-
View the
eg/
directory in the Hibernate distribution. It contains a simple standalone application. Copy your JDBC driver to thelib/
directory and editetc/hibernate.properties
, specifying correct values for your database. From a command prompt in the distribution directory, typeant eg
(using Ant), or under Windows, typebuild eg
. -
Use this reference documentation as your primary source of information. Consider reading [JPwH] if you need more help with application design, or if you prefer a step-by-step tutorial. Also visit http://caveatemptor.hibernate.org and download the example application from [JPwH].
-
FAQs are answered on the Hibernate website.
-
Links to third party demos, examples, and tutorials are maintained on the Hibernate website.
-
The Community Area on the Hibernate website is a good resource for design patterns and various integration solutions (Tomcat, JBoss AS, Struts, EJB, etc.).
There are a number of ways to become involved in the Hibernate community, including
-
Trying stuff out and reporting bugs. See http://hibernate.org/issuetracker.html details.
-
Trying your hand at fixing some bugs or implementing enhancements. Again, seehttp://hibernate.org/issuetracker.html details.
-
http://hibernate.org/community.html lists a few ways to engage in the community.
-
There are forums for users to ask questions and receive help from the community.
-
There are also IRC channels for both user and developer discussions.
-
-
Helping improve or translate this documentation. Contact us on the developer mailing list if you have interest.
-
Evangelizing Hibernate within your organization.