-->
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: Unique contraint not dropped
PostPosted: Mon Jan 26, 2009 1:54 pm 
Newbie

Joined: Mon Jan 26, 2009 1:45 pm
Posts: 1
Using Hibernate 3 with annotations, when a unique constraint is removed from the entity annotations, the constraint is not dropped from the database. DDL generation is set to update - <property name="hibernate.hbm2ddl.auto" value="update"/>

The entity initially had @Column(unique = true) on the userName. I have removed the annotation and also set it to false. In both cases the constraint remains in the database (H2).

@Entity
public class User implements Serializable {
private Long id;
private String userName;

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
return id;
}

@Column(unique = false)
public String getUserName() {
return userName;
}

}

Is it reasonable to assume that the constraint would be dropped by the change in the annotation?

Thanks,

Greg


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2009 3:12 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
As far as I know the schema update tool can only add things to the database. It doesn't remove columns, tables, indexes or other stuff from the database.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 27, 2009 3:54 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Yes, hibernate does not remove definitions from the db. If you want the database to be as mapped in hibernate, drop it and let hibernate create it new.

_________________
-----------------
Need advanced help? http://www.viada.eu


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.