English 中文(简体)
Hibernate或hsql不考虑列长度
原标题:Hibernate or hsql does not respect column length

我有一个应用程序,它使用hibernate为HSQLdb生成表(因为我的应用程序仍在开发中)。在我的域模型中,我设置了

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

当我使用DBVisualizer打开我的数据库时,我可以看到除了它不工作之外,一切都设置得很好。我的列接受的值远远超过10个字符长。当我尝试在DBVisualier中手动运行查询时,它会失败,但hibernate允许它运行。

同样非常奇怪的是,当我使用文件(而不是内存中的数据库)来查看数据库结构,并指向DBVisualizer时,它以某种方式断开了连接,因此从那一刻起,我从Hibernate中所做的更改就不可见了。一切仍然有效。我只是在DBVisualizeer中看不到这些更改,但在应用程序中可以。

有人知道这种奇怪的行为吗?

为大家欢呼

更新

休眠配置

    <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>
最佳回答

您的问题可能来自HSQLDB中的一个限制,如节文档

HSQLDB databases are initially created in a legacy mode that does not enforce column size and precision. You can set the property: sql.enforce_strict_size=true to enable this feature. When this property has been set, Any supplied column size and precision for numeric and character types (CHARACTER and VARCHAR) are enforced. Use the command, SET PROPERTY "sql.enforce_strict_size" TRUE once before defining the tables.

(重点是我的)

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签