JBoss Enterprise Web Platform 5

Hibernate Entity Manager Reference Guide

for Use with JBoss Enterprise Web Platform 5

Edition 5.1.1

Red Hat Documentation Group

Legal Notice

Copyright © 2011 Red Hat, Inc.
This document is licensed by Red Hat under the Creative Commons Attribution-ShareAlike 3.0 Unported License. If you distribute this document, or a modified version of it, you must provide attribution to Red Hat, Inc. and provide a link to the original. If the document is modified, all Red Hat trademarks must be removed.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack Logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
June, 2011

Abstract

The Hibernate Entity Manager Reference Guide for JBoss Enterprise Web Platform 5 and its patch releases.
Preface
1. Document Conventions
1.1. Typographic Conventions
1.2. Pull-quote Conventions
1.3. Notes and Warnings
2. Getting Help and Giving Feedback
2.1. Do You Need Help?
2.2. Give us Feedback
1. Architecture
1.1. Definitions
1.2. EJB container environment
1.2.1. Container-managed entity manager
1.2.2. Application-managed entity manager
1.2.3. Persistence context scope
1.2.4. Persistence context propagation
1.3. Java SE environments
2. Setup and configuration
2.1. Setup
2.2. Configuration and bootstrapping
2.2.1. Packaging
2.2.2. Bootstrapping
2.3. Event listeners
2.4. Obtaining an EntityManager in a Java SE environment
2.5. Various
3. Working with objects
3.1. Entity states
3.2. Making objects persistent
3.3. Loading an object
3.4. Querying objects
3.4.1. Executing queries
3.5. Modifying persistent objects
3.6. Modifying detached objects
3.7. Automatic state detection
3.8. Deleting managed objects
3.9. Flush the persistence context
3.9.1. In a transaction
3.9.2. Outside a transaction
3.10. Transitive persistence
3.11. Locking
4. Transactions and Concurrency
4.1. Entity manager and transaction scopes
4.1.1. Unit of work
4.1.2. Long units of work
4.1.3. Considering object identity
4.1.4. Common concurrency control issues
4.2. Database transaction demarcation
4.2.1. Non-managed environment
4.2.2. Using JTA
4.2.3. Exception handling
4.3. EXTENDED Persistence Context
4.3.1. Container Managed Entity Manager
4.3.2. Application Managed Entity Manager
4.4. Optimistic concurrency control
4.4.1. Application version checking
4.4.2. Extended entity manager and automatic versioning
4.4.3. Detached objects and automatic versioning
5. Entity listeners and Callback methods
5.1. Definition
5.2. Callbacks and listeners inheritance
5.3. XML definition
6. Batch processing
6.1. Bulk update/delete
7. EJB-QL: The Object Query Language
7.1. Case Sensitivity
7.2. The from clause
7.3. Associations and joins
7.4. The select clause
7.5. Aggregate functions
7.6. Polymorphic queries
7.7. The where clause
7.8. Expressions
7.9. The order by clause
7.10. The group by clause
7.11. Subqueries
7.12. EJB-QL examples
7.13. Bulk UPDATE & DELETE Statements
7.14. Tips & Tricks
8. Native query
8.1. Expressing the resultset
8.2. Using native SQL Queries
8.3. Named queries
A. Revision History