Results 1 to 4 of 4

Thread: Custom Exception messaging

  1. #1

    Default Custom Exception messaging

    I have added a unique constraint to a field in ROO generated entity as shown below -

    Code:
    @RooJavaBean
    @RooToString
    @RooEntity(finders = { "findEmployeesByEmployee_id" })
    public class Employee {
    
    	@Column(unique=true)
        private Integer employee_id;

    Now, when I try to insert same employee_id twice , the following stack message with full stack trace is thrown on user screen -

    Code:
    org.hibernate.exception.ConstraintViolationException: could not insert: [com.kreativ.kerp.domain.Employee]; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not insert: [com.kreativ.kerp.domain.Employee]
    On the same time, in apache log, it says -

    Code:
    2012-03-12 15:57:18,395 [http-8080-1] ERROR org.hibernate.util.JDBCExceptionReporter - Duplicate entry '1' for key 'employee_id'
    How can I print some useful message to user that this id must be unique instead of showing full stack trace.

  2. #2
    Join Date
    Jul 2012
    Posts
    7

    Default

    I have the same problem , i would like to know it

  3. #3

    Default

    Quote Originally Posted by josema View Post
    I have the same problem , i would like to know it
    I worked this around by creating some more views with those error messages and same layout.
    So, in case of error, I redirected to the corresponding error message view.

    Not the best solution, but it worked ..

  4. #4
    Join Date
    Jul 2012
    Posts
    7

    Default

    Thanks you but I don't know how to redirect and create the view for that error messages. How can I do that? thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •