|
代碼內容
from eg.Cat |
|
代碼內容
from Cat |
|
代碼內容
from Cat as cat |
|
代碼內容
from Cat cat |
|
代碼內容
from Cat as cat inner join cat.mate as mate left outer join cat.kittens as kitten from Cat as cat left join cat.mate.kittens as kittens from Formula form full join form.parameter param |
|
代碼內容
from Cat as cat join cat.mate as mate left join cat.kittens as kitten |
|
代碼內容
from Cat as cat inner join fetch cat.mate left join fetch cat.kittens |
|
代碼內容
from Document fetch all properties order by name from Document doc fetch all properties where lower(doc.name) like ’%cats%’ |
|
代碼內容
select mate from Cat as cat inner join cat.mate as mate |
|
代碼內容
select cat.mate from Cat cat |
|
代碼內容
select cat.name from DomesticCat cat where cat.name like ’fri%’ select cust.name.firstName from Customer as cust |
|
代碼內容
select mother, offspr, mate.name from DomesticCat as mother inner join mother.mate as mate left outer join mother.kittens as offspr |
|
代碼內容
select new list(mother, offspr, mate.name) from DomesticCat as mother inner join mother.mate as mate left outer join mother.kittens as offspr |
|
代碼內容
select new Family(mother, mate, offspr) from DomesticCat as mother join mother.mate as mate left join mother.kittens as offspr |
|
代碼內容
select max(bodyWeight) as max, min(bodyWeight) as min, count(*) as n from Cat cat |
|
代碼內容
select new map( max(bodyWeight) as max, min(bodyWeight) as min, count(*) as n ) from Cat cat |
|
代碼內容
select avg(cat.weight), sum(cat.weight), max(cat.weight), count(cat) from Cat cat |
|
代碼內容
avg(...), sum(...), min(...), max(...) count(*) count(...), count(distinct ...), count(all...) |
|
代碼內容
from Cat cat join cat.kittens kitten group by cat.id, cat.weight select firstName||’ ’||initial||’ ’||upper(lastName) from Person |
|
代碼內容
select distinct cat.name from Cat cat select count(distinct cat.name), count(cat) from Cat cat |
|
代碼內容
from Cat as cat |
|
代碼內容
from java.lang.Object o |
|
代碼內容
from Named n, Named m where n.name = m.name |
|
代碼內容
from Cat where name=’Fritz’ |
|
代碼內容
from Cat as cat where cat.name=’Fritz’ |
|
代碼內容
select foo from Foo foo, Bar bar where foo.startDate = bar.date |
|
代碼內容
from Foo foo where foo.bar.baz.customer.address.city is not null |
|
代碼內容
from Cat cat, Cat rival where cat.mate = rival.mate select cat, mate from Cat cat, Cat mate where cat.mate = mate |
|
代碼內容
from Cat as cat where cat.id = 123 from Cat as cat where cat.mate.id = 69 |
|
代碼內容
from bank.Person person where person.id.country = ’AU’ and person.id.medicareNumber = 123456 from bank.Account account where account.owner.id.country = ’AU’ and account.owner.id.medicareNumber = 123456 |
|
代碼內容
from Cat cat where cat.class = DomesticCat |
|
代碼內容
store.owner.address.city // 正確 store.owner.address // 錯誤! |
|
代碼內容
from AuditLog log, Payment payment where log.item.class = ’Payment’ and log.item.id = payment.id |
|
代碼內容
from DomesticCat cat where cat.name between ’A’ and ’B’ from DomesticCat cat where cat.name in ( ’Foo’, ’Bar’, ’Baz’ ) |
|
代碼內容
from DomesticCat cat where cat.name not between ’A’ and ’B’ from DomesticCat cat where cat.name not in ( ’Foo’, ’Bar’, ’Baz’ ) |
|
代碼內容
<property name="hibernate.query.substitutions">true 1, false 0</property> |
|
代碼內容
from Cat cat where cat.alive = true |
|
代碼內容
from Cat cat where cat.kittens.size > 0 from Cat cat where size(cat.kittens) > 0 |
|
代碼內容
from Calendar cal where maxelement(cal.holidays) > current date from Order order where maxindex(order.items) > 100 from Order order where minelement(order.items) > 10000 |
|
代碼內容
select mother from Cat as mother, Cat as kit where kit in elements(foo.kittens) select p from NameList list, Person p where p.name = some elements(list.names) from Cat cat where exists elements(cat.kittens) from Player p where 3 > all elements(p.scores) from Show show where ’fizard’ in indices(show.acts) |
|
代碼內容
from Order order where order.items[0].id = 1234 select person from Person person, Calendar calendar where calendar.holidays[’national day’] = person.birthDay and person.nationality.calendar = calendar select item from Item item, Order order where order.items[ order.deliveredItemIndices[0] ] = item and order.id = 11 select item from Item item, Order order where order.items[ maxindex(order.items) ] = item and order.id = 11 在[]中的表達式甚至可以是一個(gè)算數表達式。 select item from Item item, Order order where order.items[ size(order.items) - 1 ] = item |
|
代碼內容
select item, index(item) from Order order join order.items item where index(item) < 5 |
|
代碼內容
select cust from Product prod, Store store inner join store.customers cust where prod.name = ’widget’ and store.location.name in ( ’Melbourne’, ’Sydney’ ) and prod = all elements(cust.currentOrder.lineItems) 提示: 會(huì )像如下的語(yǔ)句 SELECT cust.name, cust.address, cust.phone, cust.id, cust.current_order FROM customers cust, stores store, locations loc, store_customers sc, product prod WHERE prod.name = ’widget’ AND store.loc_id = loc.id AND loc.name IN ( ’Melbourne’, ’Sydney’ ) AND sc.store_id = store.id AND sc.cust_id = cust.id AND prod.id = ALL( SELECT item.prod_id FROM line_items item, orders o WHERE item.order_id = o.id AND cust.current_order = o.id ) |
|
代碼內容
from DomesticCat cat order by cat.name asc, cat.weight desc, cat.birthdate |
|
代碼內容
select cat.color, sum(cat.weight), count(cat) from Cat cat group by cat.color select foo.id, avg(name), max(name) from Foo foo join foo.names name group by foo.id having子句在這里也允許使用. select cat.color, sum(cat.weight), count(cat) from Cat cat group by cat.color having cat.color in (eg.Color.TABBY, eg.Color.BLACK) |
|
代碼內容
select cat from Cat cat join cat.kittens kitten group by cat having avg(kitten.weight) > 100 order by count(kitten) asc, sum(kitten.weight) desc |
|
代碼內容
from Cat as fatcat where fatcat.weight > ( select avg(cat.weight) from DomesticCat cat ) from DomesticCat as cat where cat.name = some ( select name.nickName from Name as name ) from Cat as cat where not exists ( from Cat as mate where mate.mate = cat ) from DomesticCat as cat where cat.name not in ( select name.nickName from Name as name ) |
|
代碼內容
from Cat as cat where not ( cat.name, cat.color ) in ( select cat.name, cat.color from DomesticCat cat ) |
|
代碼內容
from Person where name = (’Gavin’, ’A’, ’King’) |
|
代碼內容
from Person where name.first = ’Gavin’ and name.initial = ’A’ and name.last = ’King’) |
|
代碼內容
select order.id, sum(price.amount), count(item) from Order as order join order.lineItems as item join item.product as product, Catalog as catalog join catalog.prices as price where order.paid = false and order.customer = :customer and price.product = product and catalog.effectiveDate < sysdate and catalog.effectiveDate >= all ( select cat.effectiveDate from Catalog as cat where cat.effectiveDate < sysdate ) group by order having sum(price.amount) > :minAmount order by sum(price.amount) desc |
|
代碼內容
select order.id, sum(price.amount), count(item) from Order as order join order.lineItems as item join item.product as product, Catalog as catalog join catalog.prices as price where order.paid = false and order.customer = :customer and price.product = product and catalog = :currentCatalog group by order having sum(price.amount) > :minAmount order by sum(price.amount) desc |
|
代碼內容
select count(payment), status.name from Payment as payment join payment.currentStatus as status join payment.statusChanges as statusChange where payment.status.name <> PaymentStatus.AWAITING_APPROVAL or ( statusChange.timeStamp = ( select max(change.timeStamp) from PaymentStatusChange change where change.payment = payment ) and statusChange.user <> :currentUser ) group by status.name, status.sortOrder order by status.sortOrder |
|
代碼內容
select count(payment), status.name from Payment as payment join payment.currentStatus as status where payment.status.name <> PaymentStatus.AWAITING_APPROVAL or payment.statusChanges[ maxIndex(payment.statusChanges) ].user <> :currentUser group by status.name, status.sortOrder order by status.sortOrder |
|
代碼內容
select account, payment from Account as account left outer join account.payments as payment where :currentUser in elements(account.holder.users) and PaymentStatus.UNPAID = isNull(payment.currentStatus.name, PaymentStatus.UNPAID) order by account.type.sortOrder, account.accountNumber, payment.dueDate |
|
代碼內容
select account, payment from Account as account join account.holder.users as user left outer join account.payments as payment where :currentUser = user and PaymentStatus.UNPAID = isNull(payment.currentStatus.name, PaymentStatus.UNPAID) order by account.type.sortOrder, account.accountNumber, payment.dueDate |
|
代碼內容
select usr.id, usr.name from User as usr left join usr.messages as msg group by usr.id, usr.name order by count(msg) |
|
代碼內容
from User usr where size(usr.messages) >= 1 |
|
代碼內容
select usr.id, usr.name from User usr.name join usr.messages msg group by usr.id, usr.name having count(msg) >= 1 |
|
代碼內容
select usr.id, usr.name from User as usr left join usr.messages as msg group by usr.id, usr.name having count(msg) = 0 |
|
代碼內容
Query q = s.createQuery("from foo Foo as foo where foo.name=:name and foo.size=:size"); q.setProperties(fooBean); // fooBean包含方法getName()與getSize() List foos = q.list(); |
|
代碼內容
Query q = s.createFilter( collection, "" ); // 一個(gè)簡(jiǎn)單的過(guò)濾器 q.setMaxResults(PAGE_SIZE); q.setFirstResult(PAGE_SIZE * pageNumber); List page = q.list(); |
|
代碼內容
Collection orderedCollection = s.filter( collection, "order by this.amount" ); Collection counts = s.filter( collection, "select this.type, count(this) group by this.type" ); |
|
代碼內容
( (Integer) session.iterate("select count(*) from ....").next() ).intValue(); |
聯(lián)系客服