简体   繁体   English

使用休眠/ HQL重新索引

[英]Reindexing with hibernate/HQL

We are trying to reindex our database through hibernate by using session.createQuery and executeUpdate. 我们正在尝试使用session.createQuery和executeUpdate通过休眠重新索引数据库。 For some reason this is simply just not working. 由于某种原因,这简直就是行不通。 This all is done in a job that has a timer to do this every week at a certain time. 所有这些工作都是在有计时器的工作中完成的,该计时器每周在特定时间执行一次。

  session().createQuery("ALTER INDEX indexName ON tableName REBUILD PARTITION = ALL WITH (     PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, ONLINE = OFF, SORT_IN_TEMPDB = OFF )").executeUpdate();

Is executeUpdate() the correct thing to be using? executeUpdate()是正确的东西吗? Or are there other things that are wrong with this code etc... 还是此代码有其他错误等...

Hibernate Query Language does not support arbitrary, vendor-specific SQL. Hibernate查询语言不支持任意的,特定于供应商的SQL。

You can execute native queries with Session.createSQLQuery() , but I would probably use Session.doWork() and raw JDBC. 您可以使用Session.createSQLQuery() 执行本机查询 ,但我可能会使用Session.doWork()和原始JDBC。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM