Hibernate(Persitence)

Páginas: 564 (140810 palabras) Publicado: 11 de junio de 2012
Java Persistence with Hibernate
REVISED EDITION OF HIBERNATE IN ACTION
CHRISTIAN BAUER AND GAVIN KING

MANNING
Greenwich (74° w. long.)

For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact: Special Sales Department Manning PublicationsCo. Cherokee Station PO Box 20386 New York, NY 10021

Fax: (609) 877-8256 email: orders@manning.com

©2007 by Manning Publications Co. All rights reserved.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher.

Many of thedesignations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps.

Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed onacid-free paper, and we exert our best efforts to that end.

Manning Publications Co. 209 Bruce Park Avenue Greenwich, CT 06830

Copyeditor: Tiffany Taylor Typesetters: Dottie Marsico Cover designer: Leslie Haimes

ISBN 1-932394-88-5 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – VHG – 10 09 08 07 06

brief contents
PART 1 GETTING STARTED WITH HIBERNATE AND EJB 3.0.........1
1 2 3
■ ■ ■

Understanding object/relational persistence Starting a project 37 Domain models and metadata 105

3

PART 2

MAPPING CONCEPTS AND STRATEGIES ........................ 155
4 5 6 7 8
■ ■ ■ ■ ■

Mapping persistent classes

157 191 240 277

Inheritance and custom types

Mapping collections and entity associations Advanced entity association mappings Legacy databasesand custom SQL 322

PART 3

CONVERSATIONAL OBJECT PROCESSING .....................381
9 10 11 12
■ ■ ■ ■

Working with objects

383 433 476 517

Transactions and concurrency Implementing conversations Modifying objects efficiently

v

vi

BRIEF CONTENTS

13 14 15 16 17

■ ■ ■ ■ ■

Optimizing fetching and caching Querying with HQL and JPA QL Advanced query optionsIntroducing JBoss Seam SQL fundamentals 818 822 663

559 614 697

Creating and testing layered applications 747

appendix A appendix B

Mapping quick reference

contents
foreword to the revised edition xix foreword to the first edition xxi preface to the revised edition xxiii preface to the first edition xxv acknowledgments xxviii about this book xxix about the cover illustration xxxiii

PART1 GETTING STARTED WITH HIBERNATE AND EJB 3.0 .......................................................1

1

Understanding object/relational persistence 3
1.1 What is persistence?


5
■ ■

Relational databases 5 Understanding SQL 6 Using SQL in Java 7 Persistence in object-oriented applications 8

1.2

The paradigm mismatch

10


The problem of granularity 12 The problem ofsubtypes The problem of identity 14 Problems relating to associations 16 The problem of data navigation 18 The cost of the mismatch 19
■ ■

13

vii

viii

CONTENTS

1.3

Persistence layers and alternatives
■ ■

20

Layered architecture 20 Hand-coding a persistence layer with SQL/JDBC 22 Using serialization 23 Object-oriented database systems 23 Other options 24


1.4Object/relational mapping 24
What is ORM? 25 Generic ORM problems 27 Why ORM? 28 Introducing Hibernate, EJB3, and JPA 31
■ ■

1.5

Summary

35

2

Starting a project
2.1

37
38


Starting a Hibernate project


Selecting a development process 39 Setting up the project 41 Hibernate configuration and startup 49 Running and testing the application


60

2.2

Starting a Java...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • hibernate
  • HIBERNATE
  • Hibernate
  • hibernate
  • Hibernate
  • Tutorial Hibernate
  • Hibernate referencia
  • Practica Hibernate

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS