Reputation: 573
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>
Upvotes: 1
Views: 3399
Reputation: 691625
Your problem probably comes from a limitation in HSQLDB, described in the documentation:
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.
(emphasis mine)
Upvotes: 4