查询表最大id的记录
我想要查询auction_bid表里最大id的一条记录!下面是代码
public AuctionBid getMaxBid( ) {
Session session=null;
AuctionBid bid=null;
String hql="select top 1 {b.*} from auction_bid b order by ab_id desc";
try {
session=this.getSession();
SQLQuery q=session.createSQLQuery(hql).addEntity("b",AuctionBid.class);
List<AuctionBid>l=q.list();
bid=l.get(0);
} catch (HibernateException e) {
e.printStackTrace();
}
return bid;
}
下面是报错
Caused by: java.sql.SQLException: ORA-00923: 未找到要求的 FROM 关键字
映设文件也写了!
at org.hibernate.loader.Loader.list(Loader.java:2124)Hibernate: select top 1 b.AB_ID as AB1_2_0_, b.AU_USER_ID as AU2_2_0_, b.AP_PROD_ID as AP3_2_0_, b.AB_INDEX as AB4_2_0_, b.AB_CREATE_TIME as AB5_2_0_, b.AB_PRICE as AB6_2_0_ from auction_bid b order by ab_id desc
请问是什么原因?