-->
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.  [ 3 posts ] 
Author Message
 Post subject: Why does Hibernate Validator ignore @Column size constraints
PostPosted: Wed Nov 21, 2012 5:15 am 
Newbie

Joined: Fri Nov 06, 2009 6:05 am
Posts: 12
In http://stackoverflow.com/q/13477431/131929 I asked why a JUnit test doesn't fail if the size constraint in @Column is violated. I was told that Bean Validators ignore JPA entities. I find that odd. Why is that so?

_________________
my2cents @ http://www.frightanic.com/


Top
 Profile  
 
 Post subject: Re: Why does Hibernate Validator ignore @Column size constraints
PostPosted: Wed Nov 21, 2012 4:38 pm 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
It's not right that Bean Validation ignores JPA entities. If you put Bean Validation constraint annotations (@Size, @Pattern etc.) to a JPA entity and you validate this entity (e.g. automatically upon persisting the entity) these constraints will be validated.

But Bean Validation doesn't examine any other annotations such as JPA's @Column. The goal of the Bean Validation spec is to define a generic validation solution to be used in all application layers, be it frontend or backend. Therefore it isn't aware of annotations specific to one application layer or technology such as JPA.

Hth,

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: Why does Hibernate Validator ignore @Column size constraints
PostPosted: Thu Nov 22, 2012 3:17 am 
Newbie

Joined: Fri Nov 06, 2009 6:05 am
Posts: 12
Thanks for the explanation, makes sense now.

Gunnar wrote:
It's not right that Bean Validation ignores JPA entities.


Sorry, my bad...I meant to write "JPA annotations" instead of "JPA entities".

_________________
my2cents @ http://www.frightanic.com/


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