Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/314.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
Java .HsqlException:用户缺少权限或找不到对象_Java_Spring_Hibernate_Hsqldb - Fatal编程技术网

Java .HsqlException:用户缺少权限或找不到对象

Java .HsqlException:用户缺少权限或找不到对象,java,spring,hibernate,hsqldb,Java,Spring,Hibernate,Hsqldb,第一:我可能只是犯了一个愚蠢的错误 我正在将我的一个老项目从SpringXML转换为Javaconfig。该数据库是内存中的HSQLDB数据库。不幸的是,它给了我这个错误: org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement (stacktrace) Caused by: java.sql.SQLSyntaxErrorException: user lac

第一:我可能只是犯了一个愚蠢的错误

我正在将我的一个老项目从SpringXML转换为Javaconfig。该数据库是内存中的HSQLDB数据库。不幸的是,它给了我这个错误:

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement
(stacktrace)
Caused by: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: PUBLIC.T_AUTHORITY
(stacktrace)
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: PUBLIC.T_AUTHORITY
下面是我的PersistenceConfig.java和我的SQL脚本:

@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(basePackages = "org.jason.application.repository.jpa",
        entityManagerFactoryRef = "entityManagerFactoryBean")
public class ApplicationPersistenceConfig {

    @Bean
    public JpaTransactionManager transactionManager(EntityManagerFactory emf) {

        JpaTransactionManager jpaTransactionManager = new JpaTransactionManager();
        jpaTransactionManager.setEntityManagerFactory(emf);
        return jpaTransactionManager;
    }

    @Bean
    public LocalContainerEntityManagerFactoryBean getEntityManagerFactoryBean(DataSource dataSource) {

        LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();

        entityManagerFactory.setPersistenceUnitName("default");
        entityManagerFactory.setDataSource(dataSource);
        entityManagerFactory.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
        entityManagerFactory.setJpaDialect(new HibernateJpaDialect());
        entityManagerFactory.setPackagesToScan("org.jason.application.repository.model");

        entityManagerFactory.setJpaPropertyMap(hibernateJpaProperties());

        return entityManagerFactory;
    }

    @Bean
    public DataSource getDataSource() {

        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
        dataSource.setUrl("jdbc:hsqldb:mem:testdb");
        dataSource.setUsername("sa");
        dataSource.setPassword("");
        return dataSource;
    }

    private Map<String, ?> hibernateJpaProperties() {

        HashMap<String, String> properties = new HashMap<>();
        properties.put("hibernate.hbm2ddl.import_files", "insert-data.sql");
        properties.put("hibernate.hbm2ddl.auto", "create-drop");
        properties.put("hibernate.show_sql", "false");
        properties.put("hibernate.format_sql", "false");
        properties.put("hibernate.ejb.naming_strategy", "org.hibernate.cfg.ImprovedNamingStrategy");
        properties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
        properties.put("hibernate.c3p0.min_size", "2");
        properties.put("hibernate.c3p0.max_size", "5");
        properties.put("hibernate.c3p0.timeout", "300"); // 5mins

        return properties;
    }
}
有人能看出我犯了什么愚蠢的错误吗


杰森

这是一个愚蠢的错误,就像我想的那样

以下两个hibernate属性彼此不兼容:

    properties.put("hibernate.hbm2ddl.import_files", "insert-data.sql");
    properties.put("hibernate.hbm2ddl.auto", "create-drop");
两者都具有创建模式的效果

    properties.put("hibernate.hbm2ddl.import_files", "insert-data.sql");
    properties.put("hibernate.hbm2ddl.auto", "create-drop");