These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]

Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem with Validator Annotations in ddl generation
PostPosted: Fri Jun 28, 2013 6:32 am 

Joined: Fri Jun 28, 2013 6:21 am
Posts: 1

I'm using Hibernate Tools 4.0.0-CR1 and Hibernate 4.2 (including Hibernate Validator) via the following build.xml target to generate my DDL:

    <target name="schemaexport" depends="jar" description="Exports a generated schema to DB and files">
        <path id="lib.path">
            <fileset refid="lib" />
            <pathelement location="${jboss.home}/modules/org/apache/xerces/main/xercesImpl-2.9.1-jbossas-1.jar"/>
            <pathelement location="${jar.dir}" />

        <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask"

        <hibernatetool destdir="${basedir}">
            <classpath refid="lib.path"/>
            <jpaconfiguration persistenceunit="TIC" propertyfile="hibernate-console.properties" />
            <hbm2ddl outputfilename="${dist.dir}/db_ddl.sql" format="true"/>

        <concat destfile="${dist.dir}/tic.sql" fixlastline="yes">
            <filelist dir="${dist.dir}" files="db_ddl.sql" />
            <filelist dir="${jar.dir}" files="import.sql" />

My hibernate-console.properties is as follows:


I double-checked that the jars are in my lib.path...

A sample entity looks like this:

public class Title implements Serializable {
    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Size(max = 50) @NotEmpty @Column(length = 50)
    private String titlename;

    /** User visible short version of the title. */
    @Size(max = 50)
    private String short;

The problem here is that hbm2ddl generates a proper "varchar(50)" for "titlename" but a generic "varchar(255)" for "short". I encountered similar problems with @NotNull and basically every other bean validation annotation. According to http://docs.jboss.org/hibernate/validator/4.2/reference/en-US/html_single/#validator-checkconstraints-db this should just work[tm]. What am I doing wrong?

Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.