-->
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: constraints declared on both fields and "getter methods
PostPosted: Sun Mar 30, 2008 12:41 am 
Newbie

Joined: Sun Mar 30, 2008 12:19 am
Posts: 15
how do constraints on both fields and getters get applied? are all constraints applied, or is it considered a validation error?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 01, 2008 11:16 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Both will be applied. This is not an error. Merely a lack of taste.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 3:08 pm 
Newbie

Joined: Mon Mar 31, 2008 12:05 pm
Posts: 11
I do think it's important to know the access strategy that will be used based upon the location of the validation annotation.

In section 3.1.2 "Field and property validation" it states that when the annotation is placed on the field level, the value will be accessed directly using field access. E.g., field.get(instance), but when its on the "read method" level, it'll be accessed by invoking the method. E.g., method.invoke(instance).

Why is this important? If you intend to execute logic within your get/is methods, the validator will invoke this logic when accessing the value. A good practice is to avoid placing logic in your 'read methods' anyhow.

Best Regards,
Richard L. Burton III


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.