[hibernate-issues] [Hibernate-JIRA] Created: (HV-516) Hibernate Validator doesn't work well with hibernate persistence when generating DDL

David J. M. Karlsen (JIRA) noreply at atlassian.com
Fri Sep 2 17:08:05 EDT 2011


Hibernate Validator doesn't work well with hibernate persistence when generating DDL
------------------------------------------------------------------------------------

                 Key: HV-516
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-516
             Project: Hibernate Validator
          Issue Type: Bug
          Components: engine
    Affects Versions: 4.2.0.Final
         Environment: java6, hibernate 3.6.7
            Reporter: David J. M. Karlsen
            Priority: Critical


According to http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/#d0e4044 validation annotations should influence the DDL generation. This is not the case.

If I have the following field declaration:
{noformat}
   @Length( max=10 )
    private String test;
{noformat}

it will generate the standard 255:

{noformat}
 test varchar2(255 char),
{noformat}

It appears to be an *ancient* bug - dating back from 2007:
>From https://forum.hibernate.org/viewtopic.php?t=975612

I do have 
{noformat}
<property name="javax.persistence.validation.mode" value="callback, ddl" />
{noformat}

in my persistence.xml configuration.

It's needless to say how irritating it is to define the constraints several times for each attribute.

Any chance of getting this fixed (or correct the faulty documentation)?

It's not a blocker since it's possible to define the constraints twice - once for hibernate persistence - and once for validation - but it is very very inefficient - and can lead to inconsistencies.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list