• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Entity beans validation, how to know what constraint is being violated?

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm doing some tests and I need to persist some entities.

I just wanted to know if, when I get a constraint validation error, there is some way to know what constraint is being violated?

I get this


It's really hard to know what constraint is being violated when you are persisting entities with a lot of attributes and containing other objects.. :S

Thanks for your answers!
 
Ranch Hand
Posts: 34
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Frederico,

You just have to follow the javax.validation API on this, as the error message tells you: catch the exception and call getConstraintViolations() on it to iterate on the constraints your persisting entities don't respect.
Check the ConstraintViolation API for more information.

Christian Gossart
 
Federico Nafria
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Christian,

I'm just starting to use jsr303 and I would like to know if you can point me some tutorial or book. I'm particularly interested in the business and data access layer..

Thanks again,

Federico Nafria.
 
Christian Gossart
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Concerning JSR303, I cannot think of better tutorials than those of Emmanuel Bernard, who is the spec leader of this JSR. You can find them at Bean Validation Tutorials.
Also, the Java EE tutorial has a chapter on Bean Validation: Java EE tutorial.

JSR303 annotations can be part of your JPA entities, and bean validation can be triggered at any layer of your application, from the presentation layer to the data access layer.

Good reading


 
Federico Nafria
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!

I'll take a look.. ;)
 
Our first order of business must be this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic