1

I have an application that uses hibernate to generate tables (since my application is still under development) for HSQL db. In my domain model I have set

@Basic
@Column(name = "about", length = 10)
private String about;

When I open my db using DBVisualizer I can see that everything is set up properly except it is not working my column accepts values that are way over 10 characters long. When I try to run the query manually in the DBVisualier it fails as it should but hibernate lets it run.

Also very strange is when I use the file (in stead of in memory db) so that I can see the db structure and I point to the DBVisualizer it somehow breaks the connection so my changes from the Hibernate are not visible from that moment on. Everything still works I just cant see that changes in the DBVisualizer but I can in the application.

Anyone has any idea about this weird behavior?

cheers all

UPDATE

Hibernate configuration

    <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
    <property name="hibernate.connection.url">jdbc:hsqldb:mem:test</property>
    <property name="hibernate.connection.username">sa</property>
    <property name="hibernate.connection.password"></property>
    <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
    <property name="hbm2ddl.auto">create</property>
    <property name="sql.enforce_strict_size">true</property>
4

1 回答 1

4

您的问题可能来自文档中描述的 HSQLDB 的限制:

HSQLDB 数据库最初是在不强制列大小和精度的传统模式下创建的。您可以设置属性:sql.enforce_strict_size=true 来启用此功能。设置此属性后,将强制执行为数字和字符类型(CHARACTER 和 VARCHAR)提供的任何列大小和精度。在定义表之前使用命令 SET PROPERTY "sql.enforce_strict_size" TRUE 一次。

(强调我的)

于 2012-05-26T11:42:33.533 回答