This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes help with bean validation error in JPA when trying to persist an Entity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "help with bean validation error in JPA when trying to persist an Entity" Watch "help with bean validation error in JPA when trying to persist an Entity" New topic
Author

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

caleb momanyi
Ranch Hand

Joined: Jun 17, 2012
Posts: 43

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?
ntumba lobo
Ranch Hand

Joined: Oct 21, 2008
Posts: 180
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


SCJP 5 , SCWCD 5, SCEA 5
caleb momanyi
Ranch Hand

Joined: Jun 17, 2012
Posts: 43

I removed all validation annotations beggining with @NOTNULL and it worked.
Iomanip Ganimides
Greenhorn

Joined: Jun 05, 2014
Posts: 1
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help with bean validation error in JPA when trying to persist an Entity
 
Similar Threads
Unable to produce JSON response for an arraylist contaning java beans
get generated key
Could not resolve a persistence unit corresponding to the persistence-context-ref-name
Problem retrieving data from relational databse using persistence
HTTP Status 403 - Access to the requested resource has been denied