-->
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: bad DDL for @Column(unique=true,nullable=false)
PostPosted: Sun Jul 16, 2006 6:10 am 
Newbie

Joined: Wed Mar 29, 2006 3:47 pm
Posts: 17
I am setting <property name="hibernate.hbm2ddl.auto" value="update"/> in persistence.xml. In my code, if I specify @Column(unique=true, nullable=false), then database rejects the generated DDL. I am using Derby database and set "hibernate.dialect" as "org.hibernate.dialect.DerbyDialect".

The log shows the following:

INFO: table not found: IncidentStatus
Jul 16, 2006 3:28:11 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
SEVERE: Unsuccessful: create table IncidentStatus (id varchar(255) not null, code varchar(255) not null unique, primary key (id), unique (code))
Jul 16, 2006 3:28:11 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
SEVERE: Constraints 'SQL060716032811351' and 'SQL060716032811340' have the same set of columns, which is not allowed.

Hibernate version: Hibernate EntityManager 3.2.0.CR1, Hibernate Annotations 3.2.0.CR1, Hibernate 3.2 cr3

Mapping documents:

Code:
@Entity public class Incident {
   @Id String id;

   // See FK does *not* reference PK of IncidentStatus table
   @OneToOne(cascade=CascadeType.ALL)
   @JoinColumn(name="incidentStatus", referencedColumnName="code")
   IncidentStatus incidentStatus;
}

@Entity public class IncidentStatus {
   @Id String id;

   @Column(name="code", unique=true, nullable=false)
   String code;

   @OneToOne(mappedBy="incidentStatus")
   Incident incident;
}

Name and version of the database you are using:Apache Derby, version: 10.1.1.0

The generated SQL (show_sql=true): create table IncidentStatus (id varchar(255) not null, code varchar(255) not null unique, primary key (id), unique (code))


Top
 Profile  
 
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.