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.  [ 2 posts ] 
Author Message
 Post subject: @Column attribute validation
PostPosted: Thu Jun 19, 2008 12:04 pm 
Newbie

Joined: Wed Sep 12, 2007 1:58 pm
Posts: 12
Hi,

Assume I have the following column definition:

Code:
@Column(name = "account_no", nullable = false, length = 10)
public String getAccountNo() {
    return this.accountNo;
}


If I create a new entity, set the account number to null, and try to save the entity, I get a HibernateException without ever touching the database.

If I create a new entity, set the account number to a string longer than 10 digits, and try to save the entity, I get a MysqlDataTruncation from the database.

Hibernate seems to be checking the nullable attribute before trying to save, but not checking the length attribute. Is this expected behaviour?

Thanks,
mers


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 23, 2008 10:55 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Yeah, this is actually how Hibernate will work.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.