Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的库存中有一个清单(在本例中:汽车清单)。我想查询股票并找到汽车列表中可用的最高价格。
class Stock { List<Car> cars; } class Car { int price; }
试过:
SELECT DISTINCT s.cars.price FROM Stock s;
但这总是给出“命名查询错误”。可能有什么问题,或者如何才能做得更好?
Object maxPrice = session.createQuery("select max(car.price) from Stock s join s.cars car").uniqueResult();