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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:07:52+00:00 2026-05-31T05:07:52+00:00

In my current Hibernate 4.1 + JPA 2 + Spring 3.1.1 configuration the generated

  • 0

In my current Hibernate 4.1 + JPA 2 + Spring 3.1.1 configuration the generated create table statement doesn’t take JSR 303 @javax.validation.constraints.NotNull annotation into consideration.

Class declaration:

@Entity
public class MenuItem implements Serializable {
    @Id @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    private String title;

    @NotNull    // <--- JSR 303 constraint annotation
    private String description;

    ...
}

Generated create table statement:

create table menu_item (
    id bigint generated by default as identity,
    description varchar(255),   // <--- should be not null
    price binary(255),
    title varchar(255),
    primary key (id)
)

However, if I add JPA @javax.persistence.Column annotation, the create table statement is generated correctly.

Class declaration:

@Entity
public class MenuItem implements Serializable {
    @Id @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    private String title;

    @NotNull                 // <--- JSR 303 constraint annotation
    @Column(nullable=false)  // <--- JPA annotation
    private String description;

    ...
}

Generated create table statement:

create table menu_item (
    id bigint generated by default as identity,
    description varchar(255) not null,   // <--- generated not null
    price binary(255),
    title varchar(255),
    primary key (id)
)

Is it possible to configure Hibernate 4.1 + JPA 2 + Spring 3.1.1 to generate DB schema only from JSR 303 annotations?

  • 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-31T05:07:52+00:00Added an answer on May 31, 2026 at 5:07 am

    No, it is not possible. Only in the case if we widen definition of configure to implement it is possible. JPA 2 itself gives about two pages in specification to Bean validation. Also about DB schema generation from mappings it is not too strict:

    It is permitted, but not required, that DDL generation be supported by
    an implementation of this specification.

    Also I am not aware about Hibernate or Spring providing such a functionality. It is of course bit repetitive to use both @NotNull & nullable=false.

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

Sidebar

Related Questions

Hibernate's validator is my JSR-303 provider in my Spring MVC application. When I use
I have a Spring/JPA/Groovy/Hibernate stack, (note: not grails ), and I'm finding that I'm
I'm still struggling with changing my Spring Application to use Hibernate with JPA to
I would like to perform @Range based hibernate validation checks (org.hibernate.validator.RangeValidator) in my JPA
My current workplace uses the standard Spring/Hibernate/JSP mix to serve content to its Flex
I'm trying to access the current hibernate session in a test case, and getting
My current setup using hibernate uses the hibernate.reveng.xml file to generate the various hbm.xml
In my current adventure of learning hibernate and setting it up to use an
Current Application Server Configuration: IIS 6.0 Windows 2003 Server Standard Edition SP2 .NET Framework
This question is related to Hibernate using JPA (annotated Entities) and liquibase . I

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.