@Override @Transactional(propagation=Propagation.MANDATORY) public void getLock() throws HibernateException, SQLException { String dbType = PropertiesUtil.getString("JDBC.Driver"); Session session = null; try{ session = getSession(); String sql = ""; if(dbType.contains("postgresql")) { Statement statement = session.connection().createStatement(); statement.setQueryTimeout(5); sql = "SELECT * FROM EMS_SYSTEM_DEVICE WHERE NAME='CMS' FOR UPDATE"; statement.execute(sql); }else { sql = "SELECT * FROM EMS_SYSTEM_DEVICE WHERE NAME='CMS' FOR UPDATE WAIT 5"; session.createSQLQuery(sql).list(); } }finally{ if(null != session){ releaseSession(session); } } }