Java Reference
In-Depth Information
SELECT b
FROM Bid b FETCH JOIN b.bidder
WHERE b.bidDate >= :bidDate
A fetch join is generally useful when you have lazy loading enabled for your relationship
but you want to eagerly load the related entities in a specific query. You can use FETCH
JOIN with both inner and outer joins.
Theta joins
Theta joins aren't very common, and are based on arbitrary persistence or association fields
in the entities being joined, rather than the relationship defined between them. For example,
in the ActionBazaar system you have a persistence field named rating that stores the
rating for a category. The values for rating include DELUXE , GOLD , STANDARD , and
PREMIUM . You also have a persistence field named star that you use to store a star rating
for an item; the values for star also include DELUXE , GOLD , STANDARD , and PREMIUM .
Assume that both persistence fields store some common values in these fields, such as
GOLD , and you want to join these two entities based on the rating and star fields of
Category and Item , respectively. To accomplish this, you use this query:
SELECT i
FROM Item i, Category c
WHERE i.star = c.rating
Although this type of join is less common in applications, it can't be ruled out.
Did you have any idea there was so much to JPQL? If you didn't know any better, you
might think it was a whole other language.... Oh wait, it is! And it's just waiting for you to
give it a test drive. We hope you were able to get your bearings so that you can get started
with JPQL and put it to work in your applications.
We're in the home stretch of this chapter with only a couple of topics left. We still need to
discuss native SQL queries, but first we'll talk about bulk updates and deletes.
11.1.6. Bulk updates and deletes
ActionBazaar categorizes its users by gold, platinum, and similar terms based on the num-
ber of successful trades in a year. At the end of the year, an application module is executed
Search WWH ::




Custom Search