-->
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.  [ 8 posts ] 
Author Message
 Post subject: Validator and XML descriptors
PostPosted: Mon Mar 31, 2008 10:14 am 
Beginner
Beginner

Joined: Mon Mar 31, 2008 10:05 am
Posts: 20
Hi,

I am using hibernate validator, is there a possibility to declare the constraints in XML mapping files instead of annotations ? All Hibernate validator doc always refer to declaring the constraints through annotations.

If thats not possible, are there any plans to support this alternative in a future version ?

Please advise,
Thanks,
-Guillaume


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 07, 2008 6:08 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
When HV will be JSR 303 Bean Validation compliant there will be.
But frankly, why?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 08, 2008 8:52 am 
Beginner
Beginner

Joined: Mon Mar 31, 2008 10:05 am
Posts: 20
Hi,

We need to use different hibernate mappings for the same entity implementations, in the same school of thought we were thinking we could only declare hibernate validator constraints for use in some projects. Other projects don't necessarily care about hibernate validator rules.

In that same line of thought is it possible to disable HV even if annotations are present on the entities ?

Regards,
-Guillaume


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 10, 2008 6:42 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
it is possible to disable HV yes
But what you are saying is that you reuse the same object structure for completely unrelated concepts? That sounds very very bad. Why would a not null be applied or not depending on who uses the object?

Also check http://in.relation.to/Bloggers/BeanVali ... Validation

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 11, 2008 9:19 am 
Beginner
Beginner

Joined: Mon Mar 31, 2008 10:05 am
Posts: 20
Thanks for your reply, yes your answer deserves some deep thinking. We definitely use different mapping because relationships for example are sometimes modeled different from schema to schemas, or default fetching strategies may be different but for data constraints as hibernate validator supports, I agree it would be better to have this data validation consistent across the board otherwise we might run into issues when moving data from a schema to another.

I have to say that I hit a philosophy at my worksplace where people don't like the use of annotations very much and the requirement of having to add the library just to compile your annotated class.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 11, 2008 1:53 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
gjeudy wrote:
I have to say that I hit a philosophy at my worksplace where people don't like the use of annotations very much and the requirement of having to add the library just to compile your annotated class.


I cannot fight religions :)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 11, 2008 2:13 pm 
Beginner
Beginner

Joined: Mon Mar 31, 2008 10:05 am
Posts: 20
Yes I can try to fight on my end, this is not your job anyways. :). I think annotations have their own place and should not be considered a full replacement of XML config.

I think both approaches can co-exist but project guidelines have to be clearly defined otherwise it can quickly become a mess!

Thanks for all the tremendous work on hibernate and related modules by the way :-)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 14, 2009 10:01 pm 
Newbie

Joined: Sat Feb 14, 2009 9:49 pm
Posts: 1
Well I was looking for the same thing, here a couple of reasons why XML is preferred instead annotations:

1) I don't want to follow a whole process each time a value changes, for example, currently I'm working into an application in which the maximum length for any given username is 32, with annotations, If i need to increase this value I need to recompile the code, turn off production server, reinstall the whole site and restart, if this is allowed in XML I only need to change the file and restart the server (maybe).

2) I have a class from which other two classes extends, but for each one of this sub classes one inherited value is null in one subclass and the other is not-null, with anotations I need to rewrite both fields in each one of the subclasses.

I can find more reasons to not depend on annotations, but this are the first two it comes to my mind, and my current headache.

Anyway, thanks for the great job with hibernate!!!.

_________________
I'm here


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