Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用hibernate禁用触发器_Hibernate_Database Trigger - Fatal编程技术网

如何使用hibernate禁用触发器

如何使用hibernate禁用触发器,hibernate,database-trigger,Hibernate,Database Trigger,我有一个实体规程处理案例,它有一个触发器(插入前)称为dp\u插入 我想根据某些条件禁用和启用该触发器 所以我做了如下的事情 public boolean saveDisciplinaryProceedings(DisciplinaryProceedingCase disciplinaryProceedingCase) { boolean b=false; try { currentSession = sessionFactory.get

我有一个实体
规程处理案例
,它有一个触发器
(插入前)
称为
dp\u插入

我想根据某些条件禁用和启用该触发器

所以我做了如下的事情

public boolean saveDisciplinaryProceedings(DisciplinaryProceedingCase disciplinaryProceedingCase) {

        boolean b=false;
        try {
            currentSession = sessionFactory.getCurrentSession();
            currentSession.createQuery("ALTER TRIGGER dp_insert DISABLE");// using this query to disable
        currentSession.saveOrUpdate(disciplinaryProceedingCase);
        b=true;
        }
        catch (Exception e) { 
            e.printStackTrace();
        }
        return b;

    }
但它给出了异常
org.hibernate.hql.internal.ast.QuerySyntaxException:unexpected token:ALTER靠近第1行第1列[ALTER TRIGGER dp_insert DISABLE]

请解释一下如何在hibernate中禁用触发器。
可以这样做吗?

尝试:currentSession.createNativeQuery(“ALTER TRIGGER dp\U insert DISABLE”)
ALTER TRIGGER dp\U insert DISABLE在mysql工作台中给出错误,也像意外的'alter'哦,对不起。不可能在MySQL中禁用触发器!听到这个消息很难过。但是如何实现呢?为什么要禁用触发器?请尝试:currentSession.createNativeQuery(“ALTER trigger dp_insert disable”)
ALTER trigger dp_insert disable在mysql工作台中给出错误,也像意外的'alter'哦,对不起。不可能在MySQL中禁用触发器!听到这个消息很难过。但是如何实现呢?为什么要禁用触发器?