diff --git a/annotations/src/main/docbook/en/modules/entity.xml b/annotations/src/main/docbook/en/modules/entity.xml
index 24db0a730c..8435fd9d22 100644
--- a/annotations/src/main/docbook/en/modules/entity.xml
+++ b/annotations/src/main/docbook/en/modules/entity.xml
@@ -2393,8 +2393,8 @@ public class Order {
@Entity class Order { ... }
-Customer customer = em.get(Customer.class, 1l);
-Order order = em.get(Order.class, 1l);
+Customer customer = em.find(Customer.class, 1l);
+Order order = em.find(Order.class, 1l);
customer.getOrders().remove(order); //order will be deleted by cascade
@@ -2561,9 +2561,128 @@ public class Cat implements Serializable {
the same column name, the MainCat id column has).
Plus a unique constraint on storyPart2 has been
set.
+
- Check out the JBoss EJB 3 tutorial or the Hibernate Annotations
- unit test suite for more examples.
+
+ Caching entities
+
+ Hibernate offers naturally a first level cache for entities called
+ a persistence context via the notion of Session.
+ This cache is contextual to the use case at hand. Some entities however
+ are shared by many different use cases and are barely changed. You can
+ cache these in what is called the second level cache.
+
+ By default, entities are not part of the second level cache. While
+ we do not recommend that, you can override this by setting the
+ shared-cache-mode element in your persistence.xml
+ file or by using the javax.persistence.sharedCache.mode
+ property. The following values are possible:
+
+
+
+ ENABLE_SELECTIVE (Default and recommended
+ value): entities are not cached unless explicitly marked as
+ cacheable.
+
+
+
+ DISABLE_SELECTIVE: entities are cached
+ unless explicitly marked as not cacheable.
+
+
+
+ ALL: all entities are always cached even if
+ marked as non cacheable.
+
+
+
+ NONE: no entity are cached even if marked
+ as cacheable. This option can make sense to disable second-level
+ cache altogether.
+
+
+
+ The cache concurrency strategy used by default can be set with the
+ hibernate.cache.default_cache_concurrency_strategy
+ property:
+
+
+
+ read-only
+
+
+
+ read-write
+
+
+
+ nonstrict-read-write
+
+
+
+ transactional
+
+
+
+
+ It is recommended to define the cache concurrency strategy per
+ entity rather than using a global one. Use the
+ @org.hibernate.annotations.Cache annotation for
+ that.
+
+
+ @Entity @Cacheable
+@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+public class Forest { ... }
+
+ Hibernate also let's you cache the content of a collection or the
+ identifiers if the collection contains other entities. Use the
+ @Cache annotation on the collection
+ property.
+
+ @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
+@JoinColumn(name="CUST_ID")
+@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+public SortedSet<Ticket> getTickets() {
+ return tickets;
+}
+
+ @org.hibernate.annotations.Cache defines the
+ caching strategy and region of a given second level cache.
+
+
+
+
+
+
+
+
+
+
+ @Cache(
+ CacheConcurrencyStrategy usage();
+ String region() default "";
+ String include() default "all";
+)
+
+
+
+ usage: the given cache concurrency strategy (NONE,
+ READ_ONLY, NONSTRICT_READ_WRITE, READ_WRITE, TRANSACTIONAL)
+
+
+
+ region (optional): the cache region (default to the fqcn of
+ the class or the fq role name of the collection)
+
+
+
+ include (optional): all to include all
+ properties, non-lazy to only include non lazy properties (default
+ all).
+
+
+
@@ -3934,66 +4053,6 @@ public Collection<Employer> getEmployers()
previous example.
-
- Cache
-
- In order to optimize your database accesses, you can activate the
- so called second level cache of Hibernate. This cache is configurable on
- a per entity and per collection basis.
-
- @org.hibernate.annotations.Cache defines the
- caching strategy and region of a given second level cache. This
- annotation can be applied on the root entity (not the sub entities), and
- on the collections.
-
- @Entity
-@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
-public class Forest { ... }
-
- @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
- @JoinColumn(name="CUST_ID")
- @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- public SortedSet<Ticket> getTickets() {
- return tickets;
- }
-
-
-
-
-
-
-
-
-
-
-
-
- @Cache(
- CacheConcurrencyStrategy usage();
- String region() default "";
- String include() default "all";
-)
-
-
-
- usage: the given cache concurrency strategy (NONE,
- READ_ONLY, NONSTRICT_READ_WRITE, READ_WRITE, TRANSACTIONAL)
-
-
-
- region (optional): the cache region (default to the fqcn of
- the class or the fq role name of the collection)
-
-
-
- include (optional): all to include all
- properties, non-lazy to only include non lazy properties (default
- all).
-
-
-
-
-
Filters
diff --git a/annotations/src/main/docbook/en/modules/setup.xml b/annotations/src/main/docbook/en/modules/setup.xml
index 3f05fff044..c5050228fd 100644
--- a/annotations/src/main/docbook/en/modules/setup.xml
+++ b/annotations/src/main/docbook/en/modules/setup.xml
@@ -92,7 +92,7 @@
We recommend you use Hibernate Validator and the
- Bean VAlidation specification capabilities. Download Hibernate Validator 4
+ Bean Validation specification capabilities. Download Hibernate Validator 4
or above from the Hibernate website and add
hibernate-validator.jar and
validation-api.jar in your classpath. Alternatively
@@ -317,4 +317,4 @@ private static final SessionFactory sessionFactory;
url="http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#configuration-logging">Logging
in the Hibernate Core documentation.
-
\ No newline at end of file
+