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 4584162
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:18:58+00:00 2026-05-21T21:18:58+00:00

hibernate and i want to provide localized error messages for hibernate annotations so i

  • 0

hibernate and i want to provide localized error messages for hibernate annotations
so i created to properties files ValidatorMessages.properties, ValidatorMessages_ar.properties

and put them in resources folder, and i am using messageSource to read from property files:

<bean id="messageSource"
        class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <property name="basenames">
            <list>
                <value>classpath:messages</value>
                <value>classpath:errors</value>
                <value>classpath:app</value>
                <value>classpath:ValidatorMessages</value>
            </list>
        </property>
        <property name="defaultEncoding" value="UTF-8" />
    </bean>

and in the class i use something like:

@NotNull(message = "{validation.notEmpty.password}")
private string password;

and when calling the validator i use:

Validator validator = Validation.buildDefaultValidatorFactory()
                .getValidator();
        Set<ConstraintViolation<MyClass> cvs = validator
                .validate(myObject);
        for (ConstraintViolation<MyClass> cv : cvs) {
            String field = cv.getPropertyPath().toString();
            result.addError(new FieldError("version", field, cv.getMessage()));
        }

        if (result.hasErrors()) {
            initModel();
            result.reject("add.version.errors");
            return "manageVersions";
        }

it works fine with english, it displays english messages correctly, but when switching to arabic it still displays the english messages instead of arabic, although that

LocaleContextHolder.getLocale() indicates that the language is changed and it’s arabic, so is there are something missing with the configuration or any ideas what might cause that ?

  • 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-05-21T21:18:59+00:00Added an answer on May 21, 2026 at 9:18 pm

    In your Spring config when you are setting up your validator bean, I think you need to set the message interpolator:

    <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
        <property name="messageInterpolator" ref="interpolator" />
    </bean>
    

    where the interpolator bean would be of type LocaleContextMessageInterpolator (see here for more info). Hibernate Validator doesn’t automatically know to look at LocaleContextHolder.

    You might also need to set validationMessageSource property but I think its defaulted properly since you are at least getting the English error messages.

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

Sidebar

Related Questions

I want to provide a custom Batcher for Hibernate to use (for this reason:
i have three table and i want to map them in hibernate 4. i
I have Maven project with Hibernate and Spring framework. I want Hibernate to create
I am using hibernate and i want to display only those records of table
I want to tell hibernate to give me a callback notification when a new
i want to integrate Struts with Hibernate. I am new to these technologies. Infortunately
I want fetch last record using hibernate criteria Can u help me?
I want to make an hibernate querycount on a table. I have to values,
I want to make searching on my database with hibernate in Java, how can
I want to test my class MyTypeDAO implemented with Hibernate 4.1 using JUnit 4.9.

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.