-->
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.  [ 7 posts ] 
Author Message
 Post subject: Constraint Violation Ex on populated List Field @NotEmpty
PostPosted: Tue Jun 17, 2014 1:46 pm 
Newbie

Joined: Tue Jun 17, 2014 1:31 pm
Posts: 6
I have couple fields within an Entity Class annotated with @NotEmpty Annotation. I am getting Constraint Violation Exception on the field of type List, when persisting the object to database. I have a another field (String) that also has the annotation which does not complain when I comment out the @NotEmpty for List field and saving object. This leads me to think it has something to do with Collections.

Error:
Exception in thread "main" javax.validation.ConstraintViolationException: Validation failed for classes [com.User] during persist time for groups [javax.validation.groups.Default, ]
List of constraint violations:[
ConstraintViolationImpl{interpolatedMessage='may not be empty', propertyPath=tickers, rootBeanClass=class com.User, messageTemplate='{org.hibernate.validator.constraints.NotEmpty.message}'}
]

//Extract of the fields
@Id
@GeneratedValue(strategy=IDENTITY)
@Column(name="id")
private Long id;

@Column(name="name", unique=true)
@Size(max=100)
@NotEmpty
private String name;

@ManyToMany
@JoinTable(name="user_game",
joinColumns = @JoinColumn(name="user_id"),
inverseJoinColumns= @JoinColumn(name="game_id"))
@NotNull
@NotEmpty
private Set<Game> games = new HashSet<Game>();

....

Version: Hibernate Validator Final 4.3.1.jar


Top
 Profile  
 
 Post subject: Re: Constraint Violation Ex on populated List Field @NotEmpty
PostPosted: Wed Jun 18, 2014 3:48 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Is this to say that you also get this constraint violation if the games set actually is not empty? Otherwise the violation seems expected to me.

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: Constraint Violation Ex on populated List Field @NotEmpty
PostPosted: Wed Jun 18, 2014 5:26 am 
Newbie

Joined: Tue Jun 17, 2014 1:31 pm
Posts: 6
Gunnar wrote:
Is this to say that you also get this constraint violation if the games set actually is not empty? Otherwise the violation seems expected to me.
--Gunnar


Correct. Constraint Violation is triggered even when games is not empty.


Top
 Profile  
 
 Post subject: Re: Constraint Violation Ex on populated List Field @NotEmpty
PostPosted: Wed Jun 18, 2014 9:13 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hum, that's odd indeed. Any chance that you provide me with a minimal test case demonstrating that issue? I could have a look into it then.

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: Constraint Violation Ex on populated List Field @NotEmpty
PostPosted: Sun Jul 13, 2014 6:19 am 
Newbie

Joined: Tue Jun 17, 2014 1:31 pm
Posts: 6
Gunnar wrote:
Hum, that's odd indeed. Any chance that you provide me with a minimal test case demonstrating that issue? I could have a look into it then.

--Gunnar



Run the AccountTester.class http://filebin.ca/1TAIVraCeIgw.


Top
 Profile  
 
 Post subject: Re: Constraint Violation Ex on populated List Field @NotEmpty
PostPosted: Mon Jul 14, 2014 5:52 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hi,

Can you please open a JIRA ticket (https://hibernate.atlassian.net/browse/HV) and attach the test case with sources so I can build/debug myself?

Thanks,

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: Constraint Violation Ex on populated List Field @NotEmpty
PostPosted: Mon Jul 14, 2014 7:58 am 
Newbie

Joined: Tue Jun 17, 2014 1:31 pm
Posts: 6
Gunnar wrote:
Hi,

Can you please open a JIRA ticket (https://hibernate.atlassian.net/browse/HV) and attach the test case with sources so I can build/debug myself?

Thanks,

--Gunnar

Done.


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