Reputation: 131
I'm trying to use an HSQLDB in order to run some integration test. I use Spring. Hibernate is used to set up the database schema. Then I want to insert test data using liquibase.
My problem is that, while hibernate schema creation works fine, I'm getting :
liquibase.exception.DatabaseException: Error executing SQL INSERT INTO PUBLIC.OxAttributeType (id, "alias") VALUES ('1', 'varchar'): user lacks privilege or object not found: alias
When liquibase try to start it's insertion.
I think that it might be cause by the hsqldb beeing closed (and flushed) after hibernate schema creation, but I'm not sure.
Here is my configuration:
database.properties:
jdbc.driverClassName= org.hsqldb.jdbc.JDBCDriver
jdbc.url=jdbc:hsqldb:mem:oxandtestdatabase
jdbc.username: SA
jdbc.password:
Hibernate object:
@Entity
@Table(name = "oxattribute")
public class Oxattribute implements java.io.Serializable {
private Integer id;
private String alias;
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name = "alias", nullable = false, length = 30)
public String getAlias() {
return this.alias;
}
}
Spring configuration:
<bean id="hibernateProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<!-- <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> -->
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>
<bean id="liquibase" class="liquibase.integration.spring.SpringLiquibase">
<property name="dataSource" ref="dataSource" />
<property name="changeLog" value="classpath:liquibase/testData.xml" />
</bean>
So Hibernate is working, I can see in the logs:
Hibernate: create table oxattribute (id integer generated by default as identity (start with 1), alias varchar(30) not null, deletable boolean not null, description varchar(255), idOxAttributeType integer not null, idOxObject integer not null, primary key (id))
But then when liquibase start insertions:
SEVERE 07/08/14 13:59: liquibase: classpath:liquibase/testData.xml: classpath:liquibase/testData.xml::insertMetadata::GCH: Change Set classpath:liquibase/testData.xml::insertMetadata::GCH failed. Error: Error executing SQL INSERT INTO PUBLIC.OxAttributeType (id, "alias") VALUES ('1', 'varchar'): user lacks privilege or object not found: alias
liquibase.exception.DatabaseException: Error executing SQL INSERT INTO PUBLIC.OxAttributeType (id, "alias") VALUES ('1', 'varchar'): user lacks privilege or object not found: alias
For information, my code was working fine on a mysql database. Thank you for your help, Guillaume
Upvotes: 2
Views: 3608
Reputation: 2417
Change the name of the column used ("alias" is reserved term). You could try adding backticks "`". @Column(name="`alias`").
Upvotes: 3