-->
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: elementType of ConstraintViolation
PostPosted: Thu Feb 04, 2010 8:06 am 
Newbie

Joined: Tue Feb 02, 2010 9:00 am
Posts: 19
Hi,

Is there a way to get elementType of ConstraintViolation ?

Note that there is a private field in ConstraintViolationImpl declared as elementType.

I have to separates errors according to Type or Field but I do not know how to separate them now.

Thanks


Top
 Profile  
 
 Post subject: Re: elementType of ConstraintViolation
PostPosted: Thu Feb 04, 2010 8:23 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
The Bean Validation spec does separate the type in the ConstraintViolation. For implementation purposes we need however the type. I would normally not recommend to place constraint annotations on field and property. A consistent constraint placement is recommended. I assume that in your case the field and property return different values. I would be very careful with that.

All this said, one way to potentially solve your problems is to use the Payload functionality. Define a payload for the constraints you place on the field level and one for the ones you place on the property level. Payloads are passed through the system unmodified. You get access to the payload via the ConstraintDescriptor contained in the ConstraintViolation.

--Hardy


Top
 Profile  
 
 Post subject: Re: elementType of ConstraintViolation
PostPosted: Thu Feb 04, 2010 8:36 am 
Newbie

Joined: Tue Feb 02, 2010 9:00 am
Posts: 19
hardy.ferentschik wrote:
The Bean Validation spec does separate the type in the ConstraintViolation. For implementation purposes we need however the type. I would normally not recommend to place constraint annotations on field and property. A consistent constraint placement is recommended. I assume that in your case the field and property return different values. I would be very careful with that.

All this said, one way to potentially solve your problems is to use the Payload functionality. Define a payload for the constraints you place on the field level and one for the ones you place on the property level. Payloads are passed through the system unmodified. You get access to the payload via the ConstraintDescriptor contained in the ConstraintViolation.

--Hardy


Hi,

I need to validate two field together. From your explanations and other posts, I have to use type constraints or property constraints. But after validating my domain entity, I have a ConstraintViolation set in which I have no idea which exception is coming from where.

Thanks


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.