且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

hibernate hql-执行更新查询后返回更新的行ID列表

更新时间:2023-12-04 16:57:10

据我所知,JPA/Hibernate中没有此类功能.但是您可以创建本机查询并使用本机SQL.我不知道oracle,但是在PostgreSQL中我会写:

As far as I know there is no such functionality in JPA/Hibernate. But you can create native query and use native SQL. I do not know oracle, but in PostgreSQL I would write :

String sql = "update table set field = :values where ... returning id";
Query query = session.createNativeQuery(sql);
query.setParameter("value", value);
List ids = query.list();

可能是oracle具有类似的功能,这将对您有所帮助.

May be oracle have similar functional and this will help you.