Query Optimization in Hibernate: by Singaram
Query Optimization in Hibernate: by Singaram
in Hibernate
by Singaram
Hibernate
and
3
Message Class
4
Message Class (continued)
5
Hibernate Property File
6
Hibernate Mapping File
7
Initialization
8
Retrieving a Message
9
overview
Retrieving object from database is one of the most interesting and
complex parts of working with hibernate. Hibernate provides the
following ways for getting objects out of the database:
Retrieving by identifier.
10
Retrieving Object by Identifier
Retrieving by identifier:
11
Hibernate Query Language
12
Using Criteria Object
• Once the desired criteria tree is built it’s executed against the DB.
13
QBE – Query by Example
Application supplies instance of the queried class with Criterion
property value set, the Query then returns all persistent instances
with matching property values.
14
Fetching Strategies
16
Setting the fetch depth
We can set the maximum fetch depth globally. This setting
controls the number of outer-joined tables that hibernate will
use in a single query.
17
The Query Cache
Query result sets may also be cached. This is only useful for
queries that are run frequently with the same parameters.
To use the query cache you must first enable it:
hibernate.cache.use_query_cache=true
18
Tuning Object retrieval
If join operation are too complex and slow set outer join to
false for <many-to-one>
19
Thank You!