HSQLDB自动更新架构

时间:2015-12-09 10:16:53

标签: java hibernate hsqldb

例如,我有以下实体:

    /* CUSTOMIZE THE CAROUSEL
-------------------------------------------------- */
#myCarousel .carousel-caption {
    left:0;
    right:0;
    bottom:0;
    text-align:left;
    padding:10px;
    background:rgba(0,0,0,0.6);
    text-shadow:none;
    font-family: 'Droid Sans', sans-serif;
    color: #FFFFFF;
}

#myCarousel .list-group {
    position:absolute;
    top:0;
    right:0;
    font-family: 'Pontano Sans', sans-serif;
}
#myCarousel .list-group-item {
    border-radius:0px;
    cursor:pointer;
}
#myCarousel .list-group .active {
    background-color:#6D9755;   
}

#myCarousel .item {
    height: 300px;  
}
.carousel-controls {display:none;} 

如果我决定将<button value="SomeValue"></button> 媒体资源的名称更改为<button>SomeValue</button>

@Entity
public class MyClass {

    @Id
    @GeneratedValue
    private Integer Id;
    private String value;
    private boolean check = false; // <-- HERE!
    // getters & setters

}

我已经使用:

配置了hsqldb
check

由于validate设置为@Entity public class MyClass { @Id @GeneratedValue private Integer Id; private String value; private boolean validate = false; // <-- HERE! // getters & setters } ,如果我对代码进行了任何更改,是否应该更新架构?

我在尝试访问<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig" autowire="no" > <property name="poolName" value="springHikariCP" /> <property name="dataSourceClassName" value="org.hsqldb.jdbc.JDBCDataSource" /> <property name="dataSourceProperties"> <props> <prop key="url">jdbc:hsqldb:file:${user.home}/db/data;hsqldb.lock_file=false</prop> <prop key="user">sa</prop> <prop key="password"></prop> </props> </property> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="packagesToScan" value="com.example.domain" /> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" /> </property> <property name="jpaProperties" ref="hibernateProperties" /> </bean> <bean name="hibernateProperties" autowire="byName" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="properties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> // <-- HERE! <prop key="hibernate.default_schema">PUBLIC</prop> <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</prop> <prop key="hibernate.connection.CharSet">utf8</prop> <prop key="hibernate.connection.characterEncoding">utf8</prop> <prop key="hibernate.connection.useUnicode">true</prop> </props> </property> </bean> 时遇到此错误,因为架构未更新:

hibernate.hbm2ddl.auto

更新:

打开sql日志后我看到了:

update

我不知道为什么不在语句中添加validate。此外,它正在尝试添加新列而不是更新它

2 个答案:

答案 0 :(得分:0)

此错误表示您对目前正在处理的架构没有足够的权限。

检查以下行。

Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: MYCLAS0_.VERIFY

验证您是否具有此上述架构的更新架构权限。使用此link了解更多相关信息。

答案 1 :(得分:0)

因为boolean不能是null,我注意到validate=false对象的初始化没有任何影响。所以我强迫它在JPA中用:

@Column(columnDefinition = "boolean default false")
private boolean validate = false;