我正在使用HSQL
withDBUnit
来运行我的单元测试。到目前为止,我可以HSQL
从创建新模式的脚本开始,然后Hibernate
创建表并DBUnit
在这些表中添加数据。但是,我一直有这些错误日志:
2013-10-10 09:38:05,559 INFO org.hibernate.tool.hbm2ddl.SchemaExport - HHH000227: Running hbm2ddl schema export
2013-10-10 09:38:05,563 ERROR org.hibernate.tool.hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table dbo.MY_TABLE drop constraint FK58568EF941C829A
2013-10-10 09:38:05,563 ERROR org.hibernate.tool.hbm2ddl.SchemaExport - user lacks privilege or object not found: DBO.MY_TABLE
2013-10-10 09:38:05,564 ERROR org.hibernate.tool.hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table dbo.MY_TABLE drop constraint FK58568EF12A53C22
2013-10-10 09:38:05,564 ERROR org.hibernate.tool.hbm2ddl.SchemaExport - user lacks privilege or object not found: DBO.MY_TABLE
2013-10-10 09:38:05,592 ERROR org.hibernate.tool.hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table dbo.MY_TABLE add constraint FK58568EF941C829A foreign key (id_my_other_table) references dbo.MY_OTHER_TABLE
2013-10-10 09:38:05,592 ERROR org.hibernate.tool.hbm2ddl.SchemaExport - The table data is read only in statement [alter table dbo.MY_TABLE add constraint FK58568EF941C829A foreign key (id_my_other_table) references dbo.MY_OTHER_TABLE]
由于某种原因,似乎只能创建约束。我检查了表格是否已正确创建,并且数据已添加org.hsqldb.util.DatabaseManagerSwing
. 我想进去看看,INFORMATION_SCHEMA.TABLE_CONSTRAINTS
但里面INFORMATION_SCHEMA
是空的。可能是原因还是这些错误?还有什么?当我使用SA
具有所有权限的用户时,他应该能够创建约束吗?
关于我的配置:
Hibernate
4.1.10.决赛
HSQLDB
2.3.0
DBUnit
2.4.9
在我的beans.xml
我有:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:file:initdata" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<value>primobox.demat.model.sql</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="javax.persistence.validation.mode">auto</prop>
<prop key="hibernate.connection.defaultNChar">true</prop>
<prop key="hibernate.connection.useUnicode">true</prop>
<prop key="hibernate.connection.characterEncoding">UTF-8</prop>
<prop key="hibernate.connection.charSet">UTF-8</prop>
</props>
</property>
</bean>
我的initdata.properties
version=2.0.0
modified=yes
files_readonly=true