-->
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.  [ 1 post ] 
Author Message
 Post subject: Validation of object graph child entity @Id field
PostPosted: Wed Sep 04, 2013 9:58 am 
Newbie

Joined: Wed Sep 04, 2013 9:40 am
Posts: 1
I'm using validation annotations on an entity class with a set of children. I've included @Min on the @Id field of both the parent and child entity classes, along with a validation group to limit validation of the Id to update operations only. @Valid annotation is specified for the set of children to ensure that the object graph is processed by the validator.

This works well except for the scenario where a new child is added to the set for an existing parent and the parent is validated for update: the child's Id has not yet been generated and hence a constraint violation is raised for the @Min validation.

Can anyone please advise how to handle this scenario? I'm beginning to wonder if it is usual to validate an @Id field? I've seen examples both with and without such validation.

[edit] I should clarify, this is manual validation using LocalValidatorFactoryBean. No problem with this scenario when Hibernate validates pre- the update. I assume Hibernate has dealt with generating the new Id for the new child by this point. [/edit]

Many thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.