About Java and JRuby Development
JEE, Spring, Guice
Hibernate, Java Persistence (JPA)
and various Web Frameworks

Hot topics

eBook shop

PDF edition of articles

Window id concept

An approach to leverage the use of the HTTP session

Web Framework Test and Analysis

Article series on web technologies with detailed reviews.

Hibernate eBook

A continuously updated book on Hibernate and Java Persistence

Java Persistence and Hibernate book

Book cover I publish a continuously updated ebook on Hibernate and Java Persistence for more than 3 years by now.

In 2007 I have translated this ebook for the well known German publisher Galileo Press into German language. It is available as paper book in German language and can be purchased in book shops or online at Galileo Press: http://www.galileocomputing.de/978?GPP=hibernate

Hibernate and Java Persistence eBook

Extensive, easy-to-follow introduction to Hibernate. It starts from the beginning and will still be a great help when you deal with performance tuning or Hibernate architecture.

It covers the current Hibernate version 3.3 and is constantly updated. It is full of examples showing you how things look like in real code. What do you get?

The book is provided as PDF and is lizenzed to a single person only.

Ordering can be done in my Online Shop. The table of content can be found below.

http://www.laliluna.de/shop

Any questions? Please contact me.

Explanations with complete working examples

Whenever something is explained you will find a complete sample application. If a specific mapping is demonstrated you can find a sample application, too. It shows how to insert, update, delete or query the classes included in this mapping.

Larger sample applications show the implementation of real applications using Hibernate in detail. Each application has an increasing complexity.

Cache configurations, deployment configurations for particular application server rounds off the examples.

Altogether the book provides about 20 mapping examples + variations, 4 real projects and some smaller projects showing a specific configurations.

Hibernate Project Setup

Examples to set up Hibernate projects with Eclipse and MyEclipse. Automatic generation of Hibernate mappings from existing databases.

Potential problems are investigated in detail

Hibernate has some problem zones where you can easily make mistakes. These are covered in detail to help you to avoid these problems. Some topics are LazyLoading, Session and transaction handling, optimistic concurrency and version handling.

Best Practices

One chapter is completely focussing on how to implement well designed Hibernate applications. DAO patterns and business layers are discussed. Pros and cons and the logic behind this structure are explained.

Focus on important features

Deliberately, I did not explain some rare concepts which I consider to be either not stable or very rarely used. Instead I referred to the corresponding chapters of the Hibernate reference - the documentation available with Hibernate. In my opinion the Hibernate reference is far too complex for people learning Hibernate. However, it is a valuable resource for people who already know Hibernate.

What this book is not?

The texts are short and frequently you are referred to parts of sample applications. If you prefer larger narrative parts you should not read this book.

Feel free to contact me and to comment on the book in the forum at http://www.laliluna.de

Sebastian Hennebrueder

Table of Content

1 Introduction to Hibernate 1

1 Where to find what?    1
2 Basic idea of Hibernate    2
3 A first Hibernate example    3
4 Using MyEclipse for Hibernate projects    15
5 Hibernate basics    20
6 Working with Objects    26
7 A more complex example – web application    33

2 Time to jump 60

3 Best practices and DAO 61

1 Data Access Objects DAO    61
2 Weaving the application structure    62

4 Session handling and Transactions 69

1 Hibernate Session    69
2 JTA versus JDBC Transactions    70
3 Transaction handling – default pattern    70
4 JDBC transactions with ThreadLocal    71
5 JTA transaction with a single database    72
6 JDBC or JTA with the Spring framework    73
7 Conversations and Session Lifetime    73
8 Concurrent Access    77

5 Integration with other technologies 81

1 Hibernate and Spring    81
2 Hibernate and Struts    87
3 JBoss integration with Hibernate Service Bean    88

6 Performance 93

1 Debugging to analyse the performance problem    93
2 Iterating through relations efficiently – load in batches    94
3 Iterating through relations efficiently – load all    95
4 Iterating through relations efficiently – load all with a query    95
5 Reporting queries    96
6 Iterating through large resultsets    97

7 Advanced topics 98

1 Hibernate Search    98
2 Lob with Oracle and PostgreSQL    100
3 Stored Procedures    106

8 Configuration 107

1 Connection Pools    107
2 Caches    111

9 Mapping by example 117

1 Annotation or XML mapping    117
2 Annotation mapping    118
3 XML Mapping    120
4 Primary key mapping    122
5 Relation mapping    129
6 Components = Composition mapping    172
7 Inheritance    186
8 Other mappings    207

10 Querying Data 208

1 HQL    208
2 Criteria Queries    214
3 Native SQL    218

11 Annotation Reference 220

1 Entity and table annotation    221
2 Primary key annotations    222
3 Column annotations    225
4 Special    227
5 Relation annotations    229
6 Join column annotations    230
7 Components    232
8 Inheritance    233
9 Not yet described    235

12 Index 236