This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

help with bean validation error in JPA when trying to persist an Entity

 
Ranch Hand
Posts: 43
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i get this error when trying to Persist a customer Entity in my web application using netbeans with the default glassfish server persistence provider eclipselink(JPA2.0)

error is

SEVERE: javax.validation.ConstraintViolationException: Bean Validation constraint(s) violated while executing Automatic Bean Validation on callback event:'prePersist'. Please refer to embedded ConstraintViolations for details.

the table that i want to write to has the following colums
id ==> primarykey auto increment not null int
name == varchar(45) not null
phone ==> varchar(19)
nationalIdNo ==>varchar(19)
balance ==> bigdecimal(6,2) not null default(0.00)

in my addNewCustomer i only need to set name, phone and nationalIdNo only

this is my code



why am i getting this error?
and how do you do a bean validation?
 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess would be that you have validation rules emdedded in your Customer class and the validation fails before persisting.
But it is hard to say without seeing the Customer
 
caleb momanyi
Ranch Hand
Posts: 43
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I removed all validation annotations beggining with @NOTNULL and it worked.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got the same problem, but after hours looking for the answer, Finally I Found it.... You should edit your AbstractFacade.java class and add this code



Now this method will alert you which property and why it fails the validation.
I hope this works for you, as it does for me.
 
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!