-->
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: Hibernate/jpa not validating field
PostPosted: Mon Jun 27, 2011 8:52 pm 
Newbie

Joined: Mon Jun 27, 2011 8:06 pm
Posts: 2
Hi guys,
I'm running Hibernate 4.2.0.final and jpa and I'm trying to validate a String field in a class thats annotated with @NotNull.
The ValidatorImpl class checks to see if validation is required by calling isReachable on JpaTraversableResolver. However the resolver does a check that the field is loaded which comes back false and the validation is skipped.
I'm not sure if I'm doing something wrong here. I would expect the field to be loaded if it isn't already??


Top
 Profile  
 
 Post subject: Re: Hibernate/jpa not validating field
PostPosted: Tue Jun 28, 2011 5:29 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
The idea is that if the field is persisted, but not loaded there is no need to load it. The assumption is that a persistent field has passed validation and there is no need to access/load from the db.
That said, can you provide the annotated classes and some more context around your usecase? Are you using byte code enhanced classes? I am a little surprised that a string is lazy loaded.

--Hardy


Top
 Profile  
 
 Post subject: Re: Hibernate/jpa not validating field
PostPosted: Wed Jun 29, 2011 8:24 pm 
Newbie

Joined: Mon Jun 27, 2011 8:06 pm
Posts: 2
Thanks for the reply hardy. Turns out that it was a bug in my boss's openjpa plugin. When the field was loaded if it was null the bit wasn't set to say that it was loaded thus was never validated.
Easy fix.
Thanks for your help


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.