-->
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.  [ 3 posts ] 
Author Message
 Post subject: Validator & DDL
PostPosted: Tue Jun 01, 2010 8:14 am 
Newbie

Joined: Mon Nov 14, 2005 5:43 am
Posts: 6
Hi,

I've used the validator in some projects (non db-specific) everything works fine. But now I'd like to use it with
hibernate (orm). Within the documentation there is the following:
Quote:
Out of the box, Hibernate Annotations (as of Hibernate 3.5.x) will translate the constraints you have defined for your entities into mapping metadata. For example, if a property of your entity is annotated @NotNull, its columns will be declared as not null in the DDL schema generated by Hibernate.


Now I have this Entity:
Code:
@Entity
@Table(name="CONTACTS")
public class Contact implements Serializable {

  @Id
  @GeneratedValue(generator = "system-uuid")
  @GenericGenerator(name = "system-uuid", strategy = "uuid")
  @Column(name="ID")
  @Length(max=36)
  private String id;

  public String getId() {
    return id;
  }

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


I would expect that the column ID would have a length of 36 but it has 255 (the default).
Within the deployment I'll see this:
Quote:
13:56:59.520 DEBUG o.h.tool.hbm2ddl.SchemaUpdate - create table CONTACTS (ID varchar(255) not null, primary key (ID))
13:57:00.381 INFO o.h.tool.hbm2ddl.SchemaUpdate - schema update complete


Within the documentation of hibernate validator it's mentioned that the ddl-generation is on by default and has to disabled explicitly.
I haven't done this and hibernate tells me that it has found the validator long before the line above.

Currently I'm using Hibernate 3.5.2-Final and Hibernate-Validator 4.0.2GA

Has anybody some ideas?

yours

marc


Top
 Profile  
 
 Post subject: Re: Validator & DDL
PostPosted: Tue Jun 01, 2010 9:13 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
At the moment there is no DDL constraint generation for @Length. I created HHH-5281 to address this.

--Hardy


Top
 Profile  
 
 Post subject: Re: Validator & DDL
PostPosted: Wed Jun 02, 2010 8:24 am 
Newbie

Joined: Mon Nov 14, 2005 5:43 am
Posts: 6
Hm. To have the ddl generated correctly and to have validation I need to define it twice, right?

@Column(name="ID", length=36)
@Length(max=36)


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

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.