Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Dynamic Validations
PostPosted: Thu Nov 17, 2011 2:17 am 
Newbie

Joined: Thu Nov 17, 2011 2:05 am
Posts: 3
Hi,

Is it possible to apply validators dynamically?

For example, for an Employee Class(name, dept, salary), when an object is about to save, I want to check if
- Employee with same name does not exist in database
- Department already exist in database
- and some other validations

I cab create Constraints and Validator classes and store Fully Qualified Names to DB, load them using reflection APIs at runtime. How can I apply these Constraints and Validators to the POJO classes(Employee class in this case)? Is there a way to set Constraints to the POJO classes dynamically?


Thanks,
Pratik


Top
 Profile  
 
 Post subject: Re: Dynamic Validations
PostPosted: Fri Nov 18, 2011 6:29 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
xpratikpatel wrote:

Is it possible to apply validators dynamically?

For example, for an Employee Class(name, dept, salary), when an object is about to save, I want to check if
- Employee with same name does not exist in database
- Department already exist in database
- and some other validations


That sounds like standard Bean Validation. Where is the dynamic part?

xpratikpatel wrote:
I cab create Constraints and Validator classes and store Fully Qualified Names to DB, load them using reflection APIs at runtime. How can I apply these Constraints and Validators to the POJO classes(Employee class in this case)? Is there a way to set Constraints to the POJO classes dynamically?

Can you clarify this? I have no idea what you are talking about? Are you trying to validate proxies? Some code might help as well

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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.