Using hibernate/hql to truncate a table?

后端 未结 6 1344
借酒劲吻你
借酒劲吻你 2020-12-29 06:45

What is the recommended way to truncate a table using hibernate/hql?

I\'ve tried this:

 Query query = session.createQuery(\"truncate table MyTable\");
 qu         


        
6条回答
  •  囚心锁ツ
    2020-12-29 07:09

    Preventing SQL Injection you can use:

    String escapedSQL = StringEscapeUtils.escapeSql(unescapedSQL);

    from Apache Commons-Lang

    method StringEscapeUtils.escapeSql

提交回复
热议问题