-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: SchemaValidator not checking column length and nullability
PostPosted: Sun Feb 17, 2008 2:19 pm 
Beginner
Beginner

Joined: Fri May 12, 2006 9:58 am
Posts: 32
Hibernate version:
3.2.6 ga

Mapping documents:
<property name="resume" length="512" not-null="true" />

Name and version of the database you are using:
MySQL 5.0 with MySQL5InnoDBDialect

Hello

I validate my schema with org.hibernate.tool.hbm2ddl.SchemaValidator
It works OK, but it does not check for column length or null/not-null constraints.

For example, if I manually change the type of the field from varchar to text, I get this nice exception:
Code:
SEVERE: Error running schema update
org.hibernate.HibernateException: Wrong column type in foobar.students for column resume. Found: text, expected: varchar(512)
        at org.hibernate.mapping.Table.validateColumns(Table.java:261)
        at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1089)
        at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
        at org.hibernate.tool.hbm2ddl.SchemaValidator.main(SchemaValidator.java:85)


But if field is different in any other aspect (length, or allowing null) the validator does not inform me.



Couldn't the org.hibernate.mapping.Table be enhanced on line 257 by adding columnInfo.getColumnSize() and columnInfo.getNullable() checks?

Is there a reason why this hasn't been implemented?

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 18, 2008 11:11 am 
Beginner
Beginner

Joined: Fri May 12, 2006 9:58 am
Posts: 32
Hello

I've enhanced it locally to support the nullability match. It helped me identify mismatches on the production database of my project.

Do you find this helpful? Should I submit a patch?

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 06, 2008 4:25 am 
Newbie

Joined: Mon Oct 16, 2006 10:23 am
Posts: 8
cherouvim wrote:
I've enhanced it locally to support the nullability match. It helped me identify mismatches on the production database of my project.


Sounds useful to me ;).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 21, 2008 1:54 am 
Beginner
Beginner

Joined: Fri May 12, 2006 9:58 am
Posts: 32
I've submitted a patch: http://opensource.atlassian.com/project ... e/HHH-3192

Hope it's helpful.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.