-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem with @Range constraint in Validator 4.1.0
PostPosted: Tue Aug 31, 2010 9:35 am 
Newbie

Joined: Tue Aug 31, 2010 7:28 am
Posts: 1
Hi,

I am migrating a project from Hibernate 3.3.2 with Hibernate Validator 3.1.0 to Hibernate 3.5.5 with Hibernate Validator 4.1.0. It seems that the new implementation of the @Range constraint has some flaws:

  • The resulting schema check constraint contains only the "min" or the "max" condition, but never both (see below property "anzahlAchsen" / column "anzahl_achsen")
  • The default value of Range.min is 0 (in 3.1.0 it was Long.MIN_VALUE). Thus, when defining a constraint for positive numbers, the minimum value is ignored (see below property "laengeUeberPuffer" / column "laenge_ueber_puffer")

Example Bean Class:
Code:
@Entity
public class Lok extends AbstractDbObject
{
   ...
   @NotNull
   @Range(min = 2, max = 10)
   private Integer anzahlAchsen;
   
   @NotNull
   @Range(min = 0, max = 99999)
   private Integer laengeUeberPuffer;
   ...
}

Schema created by Hibernate 3.3.2/Validator 3.1.0:
Code:
create table lok (
   ...
   anzahl_achsen number(10,0) not null check (anzahl_achsen>=2 and anzahl_achsen<=10),
   ...
   laenge_ueber_puffer number(10,0) not null check (laenge_ueber_puffer>=0 and laenge_ueber_puffer<=99999),
   ...
);

Schema created by Hibernate 3.5.5/Validator 4.1.0:
Code:
create table lok (
   ...
   anzahl_achsen number(10,0) not null check (anzahl_achsen>=2),
   ...
   laenge_ueber_puffer number(10,0) not null,
   ...
);


Regards,
Wolfgang

P.S. What happened to the PropertyConstraint interface? It was such a nice and easy way to implement database schema constraints based on bean validation! Why did you drop it?


Top
 Profile  
 
 Post subject: Re: Problem with @Range constraint in Validator 4.1.0
PostPosted: Thu Sep 02, 2010 5:21 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Fair points. Could you create a jira issue in HV? Maybe even two issues? One question is regarding the default min value of @Range and the other is about the correct DDL generation.

Regarding the PropertyConstraint - Validator 4.x is an implementation of the Bean Validation spec ( in fact the reference implementation) and PropertyConstraint is not part of it. One could image some pluggable (Hibernate specific) behavior for generating DDL.

--Hardy


Top
 Profile  
 
 Post subject: Re: Problem with @Range constraint in Validator 4.1.0
PostPosted: Thu Sep 02, 2010 5:28 am 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
I consider this a bug, so I filed a bug report: http://opensource.atlassian.com/project ... wse/HV-361

_________________
Please rate useful posts.


Schauderhaft: Softwaredevelopment, Projectmanagement, Qualitymanagement and all things "schauderhaft"


Top
 Profile  
 
 Post subject: Re: Problem with @Range constraint in Validator 4.1.0
PostPosted: Thu Sep 02, 2010 7:13 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Cheers.


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