Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8112673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:34:58+00:00 2026-06-06T02:34:58+00:00

Well, I read several issues (here and other sites) about class level validation with

  • 0

Well, I read several issues (here and other sites) about class level validation with hibernate, I created the annotation and validation class, but when validation returns false, I get an exception (when validation returns true its ok) that the class is not valid (obviously because validation returned false), my doubt is: it was not to return a validation message as well? why is returning an exception, the code:

ValidBlock.java

@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = ValidBlockValidator.class)
public @interface ValidBlock {
    String message() default "{app.ValidBlock.message}";
    Class<?>[] groups() default {};
    Class<? extends Payload>[] payload() default {};
}

ValidBlockValidator.java

public class ValidBlockValidator implements ConstraintValidator<ValidBlock, Block> {

   @Override
   public void initialize(ValidBlock aBlock) {}

   @Override
   public boolean isValid(Block value, ConstraintValidatorContext context) {
      return false;
    }
}

I made the test and i’m pretty sure i recieved the Block object, as when validation return true is fine i just return false to test.

Block.java

@ValidBlock
public class Block{
   ...
}

and the error:

Grave: javax.validation.ConstraintViolationException: Validation
failed for classes [com.labsys.model.Block] during persist time for
groups [javax.validation.groups.Default, ] List of constraint
violations:[
ConstraintViolationImpl{interpolatedMessage='{app.ValidBlock.message}’,
propertyPath=, rootBeanClass=class com.labsys.model.Block,
messageTemplate='{app.ValidBlock.message}’} ] at
org.hibernate.cfg.beanvalidation.BeanValidationEventListener.validate(BeanValidationEventListener.java:159)
at
org.hibernate.cfg.beanvalidation.BeanValidationEventListener.onPreInsert(BeanValidationEventListener.java:94)
at
org.hibernate.action.internal.EntityInsertAction.preInsert(EntityInsertAction.java:185)
at
org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:81)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
at
org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:354)
at
org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:275)
at
org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326)
at
org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1214)
at
org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:981)

Grave: JSF1073: javax.faces.event.AbortProcessingException obtido
durante o processamento de INVOKE_APPLICATION 5:
UIComponent-ClientId=blockForm:j_idt14,
Message=javax.validation.ConstraintViolationException: Validation
failed for classes [com.labsys.model.Block] during persist time for
groups [javax.validation.groups.Default, ] List of constraint
violations:[
ConstraintViolationImpl{interpolatedMessage='{app.ValidBlock.message}’,
propertyPath=, rootBeanClass=class com.labsys.model.Block,
messageTemplate='{app.ValidBlock.message}’} ] Grave:
javax.validation.ConstraintViolationException: Validation failed for
classes [com.labsys.model.Block] during persist time for groups
[javax.validation.groups.Default, ] List of constraint violations:[
ConstraintViolationImpl{interpolatedMessage='{app.ValidBlock.message}’,
propertyPath=, rootBeanClass=class com.labsys.model.Block,
messageTemplate='{app.ValidBlock.message}’} ]

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:35:00+00:00Added an answer on June 6, 2026 at 2:35 am

    You need to create a ValidationMessages.properties file and make it available at the root of your classpath, in order for the validation framework to extrapolate your custom message.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read several topics about this as well as the API and I feel
I've read several of the questions on here as well as Google looking for
I have read a couple of tutorials on several web sites as well as
I have read several threads about memory issues in R and I can't seem
I've read several of the other questions on SO regarding Java profilers, but I
First off, I've looked at several other questions about optimizing sql queries, but I'm
I've read several other questions on this topic ( here , here , and
So I've read over several questions here about the pros and cons of using
Well - the more I read the more confused I get. So here the
A have read about A* as well as D* and similar, and i'm not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.