-->
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.  [ 1 post ] 
Author Message
 Post subject: @Column optional attributes
PostPosted: Mon May 02, 2011 5:36 am 
Beginner
Beginner

Joined: Tue Dec 21, 2010 5:26 am
Posts: 25
hi,

Now I'm wondering what function the optional attributes in the @Column annotation have. I always thought it was the first place to "throw an exception" if for example the length=xyz attribute for a String field is exceeded. But when I try to persist a pojo with a mapped field like this, nothing happens. The only exceptions that gets thrown is a org.postgresql.util.PSQLException. And that is (if I'm correct) the exception thrown by the database length contrain...

I had the same problem with the nullable=false/true attribute. Only database exceptions... no hibernate ones. I then applied the nullable=false to another field (which is nullable in the database) and all of a sudden: A hibernate exception. After that, this nullable attribute works as I expected. Even on the fields that are NOT NULL in the database. No matter what constallation (nullable in code / NOT NULL in database etc...) now: Hibernate is the first to point out Constraint violations defined via field annotations.

But no such luck with the length attribute yet... or am I completely wrong, and this attribute is not supposed to check possible constraint violations before committing to the database?

Any insight would be appriciated.

TL;DR
Hibernate watches out for nullable violations but nor for length ones


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

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.