-->
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: Is there a danger to calling buildDefaultValidator() a lot?
PostPosted: Wed Sep 30, 2009 11:03 am 
Regular
Regular

Joined: Tue May 12, 2009 6:08 am
Posts: 92
What is the danger to calling Validation.buildDefaultValidator()? Should I be sharing this resource, or is that taken care for me behind the scenes?

I really don't want to be passing references to a validator deep down in objects... so what is the best practice here? Treat it like a dao or datasource? Or treat it like a pojo?


Top
 Profile  
 
 Post subject: Re: Is there a danger to calling buildDefaultValidator() a lot?
PostPosted: Fri Oct 02, 2009 6:25 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Building might be expensive in terms of performance, and the validators are designed to be reused.
You should use it as a service, how you use services depends on your environment. (?)

That's why it's especially useful when integrated in frameworks, like Seam uses Hibernate Validator (v3)
to validate web forms mapped to pojos and Hibernate validates objects before persisting them, or after loading
from DB.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Is there a danger to calling buildDefaultValidator() a lot?
PostPosted: Fri Oct 02, 2009 8:57 am 
Regular
Regular

Joined: Tue May 12, 2009 6:08 am
Posts: 92
I would grab it from Spring, but there are only 2 ways to do this within spring.

1. Use AOP to @Autowire the pojo whenever it's instantiated (because it is not part of the layering or a factory method)
2. Use a static method to get the spring application context in order to get the bean. I don't know how safe/dangerous this is.

Thoughts?


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.