• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

To restrict Javax validation

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I will have to validate my JSON, before persisting it to the database as JSON(clob). To serve this purpose, I have used javax annotations and also custom annotations on my model class. The validation is happening as expected and it works just fine.
But, if I have to retrieve the JSON and map it to my model class, javax validation will jump in again. As it does not make sense to validate a JSON, which I already did while persisting it, I want to know, if there is a way to by-pass the validation while mapping the JSON to model class.

One alternative I can think of is, to have a similar model class, without any annotations and use this to map my JSON, while retrieving it. But, its a lame alternative.

Suggestions are welcome.

Thanks,
Ashwin
 
Saloon Keeper
Posts: 26545
187
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you're trying to be too efficient.

Just because you ensured that the JSON was valid when you wrote it out to the database doesn't mean that some toe-rag can't come in and mess it up using a database utility program.

One thing that Murphy has taught me in a long and evil career is to trust no one and nothing and I'd count the cost of validation on fetched data as a small price to pay.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic