Examples of usage of Hibernate query language. Could be used in repositories with @Query annotation.
Join:
1. select night.id nid, night.night_duration, night.night_date, area.id aid, night.area_id, area.name from Night night, Area area where night.area_id = area.id
2. from Bid bid left join fetch bid.item left join fetch bid.bidder where bid.amount > 100
3. from Book book inner join book.chapters chapter where chapter.title like '%hibernate%'
4. from com.package.Venue venue inner join venue.name.translations t WHERE t.string = :name
Double join table
5. select cont from Continent cont join fetch cont.countries where cont.name = 'Europe'
Basic:
1. select p from Plane p
2. select n from Night n where n.date >= :date
Docs:
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html#queryhql-joins Join queries in HQL
No comments:
Post a Comment