简体   繁体   English

java.lang.UnsupportedOperationException: DROP CONSTRAINT 仅支持 Hibernate

[英]java.lang.UnsupportedOperationException: DROP CONSTRAINT is only supported for Hibernate

I am trying to drop a foreign key constraint in a table but the SQL "DROP CONSTRAINT" Statement is not supported by ucanaccess.我正在尝试在表中删除外键约束,但 ucanaccess 不支持 SQL“DROP CONSTRAINT”语句。 the error says:错误说:

java.lang.UnsupportedOperationException: DROP CONSTRAINT is only supported for Hibernate hbm2ddl.auto "create" java.lang.UnsupportedOperationException: DROP CONSTRAINT 仅支持 Hibernate hbm2ddl.auto "create"

Does anybody know a way around this?有人知道解决这个问题的方法吗?

private void dropTables() throws SQLException {
        final String RENTALS = "RENTALS";
        Statement statement = conn.createStatement();

        DatabaseMetaData metaData = conn.getMetaData();
        ResultSet rs = metaData.getTables(null, null, RENTALS, null);

        while (rs.next()) {
            if (rs.getString(3).equals(RENTALS)) {
                statement.executeUpdate("ALTER TABLE RENTALS DROP CONSTRAINT"  
                                                           + " custNumber;");
                statement.executeUpdate("ALTER TABLE RENTALS DROP CONSTRAINT" 
                                                           + " vehNumber;");
                statement.executeUpdate("DROP TABLE CUSTOMERS;");
                statement.executeUpdate("DROP TABLE VEHICLE;");
                statement.executeUpdate("DROP TABLE RENTALS;");
            }
        }
}

The error message implies that setting hbm2ddl.auto to create would solve the problem:错误消息暗示将hbm2ddl.auto设置为create可以解决问题:

<entry key="hibernate.hbm2ddl.auto" value="create">

However, you might want to think twice before doing this, as this means that all the tables associated with your Hibernate entities will be created and dropped each time you start the application.但是,您可能需要在执行此操作之前三思而后行,因为这意味着每次启动应用程序时都会创建和删除与您的 Hibernate 实体关联的所有表。

暂无
暂无

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

相关问题 “ java.lang.UnsupportedOperationException:尚不支持。” - “java.lang.UnsupportedOperationException: Not supported yet.” “java.lang.UnsupportedOperationException:尚不支持。” - “java.lang.UnsupportedOperationException: Not supported yet.” java.lang.UnsupportedOperationException:尚不支持 - java.lang.UnsupportedOperationException: Not supported yet Java Dropbox HttpServletRequest(java.lang.UnsupportedOperationException:尚不支持。) - Java Dropbox HttpServletRequest ( java.lang.UnsupportedOperationException: Not supported yet.) 由java.lang.UnsupportedOperationException引起:AdapterView不支持addView(View,layoutParams) - Caused by java.lang.UnsupportedOperationException: addView(View,layoutParams) is not supported in the AdapterView DBFit java.lang.UnsupportedOperationException: 不支持类型 İNT - DBFit java.lang.UnsupportedOperationException: Type İNT is not supported java.lang.UnsupportedOperationException:option不是受支持的字段类型 - java.lang.UnsupportedOperationException: option is not a supported field type Duke Fast Deduplication:java.lang.UnsupportedOperationException:尚不支持操作? - Duke Fast Deduplication: java.lang.UnsupportedOperationException: Operation not yet supported? Tomcat连接池-java.lang.UnsupportedOperationException:BasicDataSource不支持 - Tomcat Connection Pooling - java.lang.UnsupportedOperationException: Not supported by BasicDataSource java.lang.UnsupportedOperationException: &#39;posix:permissions&#39; 不支持作为 Windows 上的初始属性 - java.lang.UnsupportedOperationException: 'posix:permissions' not supported as initial attribute on Windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM