-->
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: Hibernate validation constrain definition
PostPosted: Thu Sep 16, 2010 12:13 pm 
Newbie

Joined: Thu Sep 16, 2010 11:45 am
Posts: 1
Hello,

I'm using hibernate's mechanism for validation of objects fields. Thus I have to specify my constraints as annotations in the bean class. Example:

Code:
  @NotEmpty
  @Length(max = 250)
  public String getName() {
    return name;
  }


Unfortunately this happens to be a problem for me because:
- From my point of view I want to have a single configuration source for everything concerning hibernate managed objects - this is - OR mapping, links, validation, predefined named queries etc. This of course should be *.hbm.xml file. If this is possible I can generate everything automatically - database schema, beans, DAO, etc.
- I need to keep my object's java code as simple and plain as possible - Pojo (Note: PLAIN with capital letters). This will help me share this object in client side and other modules (I'm OSGi based), without having to worry about the dependent libraries.

So I want to be able to set my validation constraints, using meta data in the *.hbm.xml.
I know I can do this my self, creating a custom event listener, which uses custom meta data from hbm.xml, does the validation, throws exception if necessary, etc. But I think such a feature can be part of the hibernate framework. I believe this will be useful for a lot of people.

What do you think ?


Top
 Profile  
 
 Post subject: Re: Hibernate validation constrain definition
PostPosted: Fri Sep 17, 2010 9:51 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
If you want to externalize the validator configuration you have to use constraint mapping files which you can specify in your validation.xml. Bean Validation constraints won't be configurable in the hibernate mapping files.

--Hardy


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.