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.  [ 2 posts ] 
Author Message
 Post subject: How do I stop further validations after an error ?
PostPosted: Tue Oct 21, 2008 1:18 pm 
Newbie

Joined: Fri Aug 17, 2007 2:11 pm
Posts: 19
Hi

I have a field which serves as the unique identifier for my entity.

Code:
@Column(name = "TAX_CODE")
@NotNull
@Pattern(regex="^\\d*$", message="{validator.custom.digits}")
@Length(min = 5, max = 10)
@UniqueSimpleKey (tableName = "TAX", pkColumnName = "TAX_CODE")
public String getTaxCode() {
   return this.taxCode;
}



My last validator is a custom validator that fires a SQL query to check if the entered tax code already exists in the table.

My problem is that Hibernate fires all the validators and then reports errors for the first one that failed validation. So my sql query in the custom validator runs every time until all other validations are passed.
Ouch !



Can someone offer advice how to handle this situation?

Thanks
Franco


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2008 4:23 pm 
Newbie

Joined: Fri Aug 17, 2007 2:11 pm
Posts: 19
Or should I not have custom validators at column level that fire SQL queries ?

Maybe a class level validator fired on save ?

But then, if my form has 30 fields starting with this as the first field, the user will know he has typed in an already existing code only at a later stage.

I am using JBoss Seam 2.0.2 SP1

I would like to keep all validations at the entity level. Can any other experienced Hibernate guys share how they handle duplicate key validations ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 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.