Java Hibernate HQL queries with nolock

前端 未结 3 1657
执念已碎
执念已碎 2021-02-05 21:07

Is there a way to run these queries as if I added a (NOLOCK) hint to them?

3条回答
  •  故里飘歌
    2021-02-05 21:54

    In latest version of Hibernate you have to do it this way:

      Session session = (Session) em.getDelegate();
            session.doWork(new Work() {
                @Override
                public void execute(Connection connection) throws SQLException {
                    connection.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
                }
            });
    

提交回复
热议问题