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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:48:25+00:00 2026-06-03T04:48:25+00:00

I am using hibernate validator to validate a form. However the validator does not

  • 0

I am using hibernate validator to validate a form. However the validator does not seem to be working. Below is the model

    package com.wallstreet.model;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Entity;
import org.hibernate.validator.constraints.Range;
import org.hibernate.validator.constraints.NotEmpty;


@Entity
public class Company {

public static final String[] COLUMN_NAMES = { "Company Id", "Share Id",
        "Name", "Primary Industry", "Secondary Industry",
        "Price", "Activity",  "Rise  Probability",
        "Move Amount Proabbility", "Range Percent"};
public static final int NO_COLUMNS = COLUMN_NAMES.length;

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "COMPANY_ID")
@NotEmpty
private int id;

@NotEmpty   
@Column(name = "SHARE_ID", unique = true)
private String shareID;

@NotEmpty
@Column(name = "COMPANY_NAME", unique = true)
private String companyName;

@NotEmpty
@Column(name = "PRIMARY_INDUSTRY")
private String primaryIndustry;

@Column(name = "SECONDARY_INDUSTRY")
private String secondaryIndustry;

@NotEmpty
@Range(min = 0)
@Column(name = "CURRENT_PRICE")
private double currentPrice;

@Range(min = 0, max=1)
@Column(name = "ACTIVITY")
private double activity;

@Range(min = 0, max=1)
@Column(name = "RISE_PROBABILITY")
private double riseProbability;

@Range(min = 0, max=1)
@Column(name = "MOVE_AMOUNT_PROBABILITY")
private double moveAmountProbability;

@Range(min = 0)
@Column(name = "RANGE_PERCENT")
private double rangePercent;

public Company() {
}

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

public String getShareID() {
    return shareID;
}

public void setShareID(String shareID) {
    this.shareID = shareID;
}

public String getCompanyName() {
    return companyName;
}

public void setCompanyName(String companyName) {
    this.companyName = companyName;
}

public String getPrimaryIndustry() {
    return primaryIndustry;
}

public void setPrimaryIndustry(String primaryIndustry) {
    this.primaryIndustry = primaryIndustry;
}

public String getSecondaryIndustry() {
    return secondaryIndustry;
}

public void setSecondaryIndustry(String secondaryIndustry) {
    this.secondaryIndustry = secondaryIndustry;
}

public double getCurrentPrice() {
    return currentPrice;
}

public void setCurrentPrice(double currentPrice) {
    this.currentPrice = currentPrice;
}

public double getActivity() {
    return activity;
}

public void setActivity(double activity) {
    this.activity = activity;
}

public double getRiseProbability() {
    return riseProbability;
}

public void setRiseProbability(double riseProbability) {
    this.riseProbability = riseProbability;
}

public double getMoveAmountProbability() {
    return moveAmountProbability;
}

public void setMoveAmountProbability(double moveAmountProbability) {
    this.moveAmountProbability = moveAmountProbability;
}

public double getRangePercent() {
    return rangePercent;
}

public void setRangePercent(double rangePercent) {
    this.rangePercent = rangePercent;
}

}

Below is my Controller

@RequestMapping(value="admin/registercompanies.html", method= RequestMethod.POST)
public ModelAndView saveCompany(@Valid Company company,BindingResult result, SessionStatus status){
    if(result.hasErrors()){
        System.out.println("1");
        return new ModelAndView("admin/company/register");
    }
    else{
        companyService.addCompany(company);
        return new ModelAndView("admin/company/registered");
    }
}

1 is not being printed out and the company is being registered.

  • 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-03T04:48:26+00:00Added an answer on June 3, 2026 at 4:48 am

    Perhaps you have forgotten to declare something in your configuration files. Could you add your dispatcher-servlet configuration file? Here is what mine looks like for reference and my validation works fine.

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://www.springframework.org/schema/mvc 
            http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
    
    
    
        <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" 
            p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" /> 
        <context:annotation-config />
    
        <context:component-scan base-package="com.dlinx90" />
    
        <mvc:annotation-driven /> 
    
        <import resource="hibernate-context.xml" />
    
        <mvc:interceptors>  
            <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>  
        </mvc:interceptors>  
    
        <bean class="org.springframework.web.servlet.i18n.CookieLocaleResolver"  
            id="localeResolver" /> 
    
        <bean class="org.springframework.context.support.ResourceBundleMessageSource"  
            id="messageSource">  
            <property name="basename" value="messages" />  
        </bean>
    
    </beans>
    

    Hope this helps!

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

Sidebar

Related Questions

I am trying to validate my form Data using Hibernate Validator in my Spring
I'm using Hibernate validator 4.1 to validate my Entity. I have a dashboard that
I am using Hibernate validator for form validation in my web-app. I am using
I create form and controller this form have some validation constrains using Hibernate validator.
I'm using Hibernate Validator 4.0.2, Spring 3.0 and Hibernate 3.3.2 (which, as I understand
When using Hibernate 2nd level cache and query cache and not specifying anything inside
I'm using Hibernate's JPA impl to model some tables. I'm having trouble mapping a
I'm not using hibernate and that's not a valid alternative at all. I developed
I'm using JPA 2.0/Hibernate validation to validate my models. I now have a situation
I have problem with using Hibernate Validator with GWT 2.4. When module is starting

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.